【发布时间】:2017-02-06 03:44:31
【问题描述】:
我有一个需要排序的 xml 文档。我有这个工作.. 但是排序后的根元素缺少属性 我试过MS Forum post 没有用。我想要我的根节点属性。谢谢
输入 XML,然后输入 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<TestProduct ProductName="SCADA" MaxResults="20" SamplesUsed="5">
<TestCollection TestName="TestABC" Expected="Passed" Status="STABLE">
<TestInfo TestResult="Passed" Version="8.0.1.19" Time="" Duration="" />
<TestInfo TestResult="Passed" Version="8.0.1.18" Time="" Duration="" />
</TestCollection>
<!-- Lots of TestCollection's -->
</TestProduct>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="TestProduct">
<xsl:copy>
<xsl:for-each select="TestCollection">
<xsl:sort select="@TestName" order="ascending"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
【问题讨论】: