我有一个关于如何根据属性值排序的问题。
我有以下源文档,我想按标题类值的值对轨道项目进行排序。
希望有人可以帮助解决这个问题。
<trackList>
<track>
<location>http://localhost/vmydoc</location>
<title class="STD">Data Two</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="SH">Data Three</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="STD">Data Four</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="SH">Data Five</title>
</track>
</trackList>
最终输出应如下所示:
<trackList>
<track>
<location>http://localhost/vmydoc</location>
<title class="SH">Data Three</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="SH">Data Five</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="STD">Data Four</title>
</track>
<track>
<location>http://localhost/vmydoc</location>
<title class="STD">Data Two</title>
</track>
</trackList>
我尝试了以下方法,但它不起作用。
<xsl:for-each-group select="title" group-by="@class">
<xsl:for-each select="current-group()">
<xsl:value-of select="@class" />
</xsl:for-each>
</xsl:for-each-group>
谢谢。