I have a situation where particular elements (xs:simpleType, xs:complexType) are placed in the output as they are encountered:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="HighSchoolType">
<xs:sequence>
<xs:element name="OrganizationName" type="core:OrganizationNameType"/>
<xs:element name="OPEID" type="core:OPEIDType"/>
<xs:simpleType name="OPEIDType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="OrganizationNameType"/>
</xs:schema>
I'd prefer that the xs:simpleType always be attached to the root, no matter where the pattern is encountered in the source. IE:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="HighSchoolType">
<xs:sequence>
<xs:element name="OrganizationName" type="core:OrganizationNameType"/>
<xs:element name="OPEID" type="core:OPEIDType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="OrganizationNameType"/>
<xs:simpleType name="OPEIDType"/>
</xs:schema>
Is it possible to stop duplicates at this point as well?
Here's the template I'm currently using:
<xsl:template match="xs:simpleType">
<xsl:copy>
<xsl:copy-of select="*[not(self::xs:annotation or self::xs:restriction)]|@*"/>
</xsl:copy>
</xsl:template>