我需要做什么:
<xsl:template match="xs:simpleType">
<xsl:copy>
<xsl:copy-of select="node()[not(self::xs:annotation or self::xs:restriction)]|@*"/>
</xsl:copy>
</xsl:template>
目前,事实证明:
<xs:simpleType xmlns:core="urn:org:pesc:core:CoreMain:v1.4.0" name="SINIDType">
</xs:simpleType>
我希望它看起来像:
<xs:simpleType name="SINIDType" />
最佳答案
有了这些空行,看起来您的 select 语句(正确地)选择了空白节点以及元素。尝试使用
select="*[not(self::xs:annotation or self::xs:restriction)]|@*"
它只匹配元素节点,而不匹配文本节点。
关于XSLT:将 <element></element> 转换为 <element/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1101817/