Xml 创建后在xsl中对表进行排序
我试图从XML中的两个节点集创建一个HTML表,然后按Xml 创建后在xsl中对表进行排序,xml,xslt,Xml,Xslt,我试图从XML中的两个节点集创建一个HTML表,然后按@AD对其排序 我可以使用在每个循环中进行排序,但我想对整个表进行排序 <xsl:template match="*/Sync/AP"> <table border="1"> <tr> <th>AD</th> <th>GCD</th> <th>Clear
@AD
对其排序
我可以使用
在每个循环中进行排序,但我想对整个表进行排序
<xsl:template match="*/Sync/AP">
<table border="1">
<tr>
<th>AD</th>
<th>GCD</th>
<th>ClearAttribute</th>
</tr>
<xsl:for-each select="./*">
<tr>
<td><xsl:value-of select="@AD"/></td>
<td><xsl:value-of select="@GCD"/></td>
<td><xsl:value-of select="@ClearAttribute"/></td>
</tr>
</xsl:for-each>
<!-- Also Append the Common attributes to each region -->
<xsl:for-each select="../Common/*">
<tr>
<td><xsl:value-of select="@AD"/></td>
<td><xsl:value-of select="@GCD"/></td>
<td><xsl:value-of select="@ClearAttribute"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
公元
GCD
清晰属性
不要把两个分开
。选择要显示的所有节点,并在一个步骤中对它们进行排序
联合运算符|
用于此操作:
<xsl:template match="Sync/AP">
<table border="1">
<tr>
<th>AD</th>
<th>GCD</th>
<th>ClearAttribute</th>
</tr>
<xsl:for-each select="./* | ../Common/*">
<xsl:sort select="@AD" order="ascending" />
<tr>
<td><xsl:value-of select="@AD"/></td>
<td><xsl:value-of select="@GCD"/></td>
<td><xsl:value-of select="@ClearAttribute"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
您可以改为使用此选项:
<xsl:template match="Sync/AP">
甚至这个:
<xsl:template match="AP">
除非您明确希望确保仅匹配父项为
的
能否显示XML的示例,以及预期的(排序)输出?非常感谢。谢谢你检查提姆,但托马拉克已经给了我我想要的信息。这就是我错过的。谢谢@Tomalak
<xsl:template match="AP">