我试着给所有元素进行排序,然后属性,其中香港专业教育学院得到了工作,但我不能想出为我的生活如何删除空属性在XSLT删除空属性
这里是那种XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates >
<xsl:sort select="local-name()"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="*[*]">
<xsl:copy>
<xsl:apply-templates select="@*" >
<xsl:sort select="local-name()" />
</xsl:apply-templates>
<xsl:apply-templates select="*" >
<xsl:sort select="local-name()"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
感谢所有帮助
属性在XML中没有顺序,所以不要指望顺序始终如预期。 – Lucero
没有按照字母顺序排序,也没有对索引位置感兴趣 –
重点在于,根据变换的目标(例如XmlWriter实现),写入的属性的顺序不一定总是对应于顺序你正在指定。我只是让你意识到这个事实。 – Lucero