2009-07-09 3 views
0

私は特定の要素(XS:単純、XS:complexTypeの)状況持つ単純には常にルートに添付さ::私は、xsことを好むだろうXSLT:特定の要素は常にルートに追加されますか?

<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> 

彼らに遭遇しているように、出力に配置されているが、どこでパターンがソースで遭遇しても問題はありません。 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> 

この時点で重複を停止することはできますか?このような

<xsl:template match="xs:simpleType"> 
    <xsl:copy> 
     <xsl:copy-of select="*[not(self::xs:annotation or self::xs:restriction)]|@*"/> 
    </xsl:copy> 
</xsl:template> 

答えて

1

何かが動作するはずです:: - 作品、感謝

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xsl:template match="/xs:schema"> 
     <xsl:copy> 
      <xsl:apply-templates/> 
      <xsl:copy-of select="//xs:simpleType"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="*[name()!='xs:simpleType' and name()!='xs:schema']"> 
     <xsl:copy> 
      <xsl:apply-templates select="*|@*"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="@*"> 
     <xsl:copy-of select="."/> 
    </xsl:template> 
</xsl:stylesheet> 
+0

steamer25

は、ここで私が現在使用しているテンプレートです。希望の出力を得るために2つのxslファイルを実行する必要があるようです。 –

関連する問題