I have the following input structure:
<complexType name="InvoiceType">
<xs:element name="AdressIn" type="AdressType"/>
<xs:element name="AdressOut" type="AdressType" />
<xs:element name="Partner" type="PartnerType" />
<xs:element name="Date" type="DateType"/>
</complexType>
All the referenced types (AdressType,PartnerType,DateType) are also contained in that document as complex types (besides many other).
What i am trying to do is to copy the types that are used within a "InvoiceType" to a new document. My Problem is, the AdressType is used more then once within InvoiceType, and thus it appears more then once in my new document. How can i prevent that? I need something like "if that is already pocessed ->skip" but that is not declarativ... maybe xslt is not the right way to achive this.
Thanx for any help!
Edit:
My XSLT i am using so far looks like that (modified to please the simple example)
<xsl:template match="xs:complexType">
<xsl:for-each select="./xs:element">
<xsl:variable name="elementType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
<xsl:copy-of copy-namespaces="no" select="/xs:schema/xs:complexType[@name=$elementType]"/>
</xsl:for-each>
I am applying that template for the InvoceType. Basically i am going threw its contents, see what types are referenced, look them up in the document via their name and copy them.