我有以下xsd代码段:
<xs:complexType name="HighSchoolType">
<xs:sequence>
<xs:element name="OrganizationName" type="core:OrganizationNameType"/>
<xs:group ref="core:OrganizationIDGroup" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
我一直在尝试使用:
<xsl:template match="xs:complexType">
<xsl:copy>
<xsl:choose>
<xsl:when test="*[self::xs:element]|@*">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="*[self::xs:group]|@*">
<xsl:apply-templates select="."/>
</xsl:when>
</xsl:choose>
</xsl:copy>
</xsl:template>
我不明白为什么:
<xsl:copy-of select="*[not(self::xs:annotation or self::xs:restriction)]|@*"/>
…将排除xs:comment&xs:限制节点
<xsl:when test="*[self::xs:element]|@*">
<xsl:copy-of select="."/>
</xsl:when>
…返回所有内容,同时:
<xsl:when test="*[self::xs:group]|@*">
<xsl:apply-templates select="."/>
</xsl:when>
…从不触发:
<xsl:variable name="core" select="document('CoreMain_v1.4.0.xsd')" />
<xsl:variable name="AcRec" select="document('AcademicRecord_v1.3.0.xsd')" />
<xsl:template match="xs:group[@ref]">
<xsl:variable name="name" select="substring-after(@ref, ':')" />
<xsl:choose>
<xsl:when test="substring-before(@ref, ':') = 'AcRec'">
<xsl:apply-templates select="$AcRec//*[@name=$name]" />
</xsl:when>
<xsl:when test="substring-before(@ref, ':') = 'core'">
<xsl:apply-templates select="$core//*[@name=$name]" />
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="xs:group[@name]">
<xsl:copy-of select="node()[not(self::xs:annotation|self::xs:restriction)]|@*"/>
</xsl:template>