我有以下 xsl 按字母顺序对我的 xml 进行排序:
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:key name="rows-by-title" match="Row" use="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
<xsl:variable name="StartRow" select="string('<tr >')" />
<xsl:template name="Meunchian" match="/dsQueryResponse/Rows">
<table>
<tr>
<xsl:for-each select="Row[count(. | key('rows-by-title', translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[1]) = 1]">
<xsl:sort select="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
<!-- Puts out the title -->
<td>
<xsl:value-of select="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</td>
<!-- Now all it's children -->
<xsl:for-each select="key('rows-by-title', translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))">
<xsl:value-of select="@Title" /><br/>
</xsl:for-each>
</xsl:for-each>
</tr>
</table>
</xsl:template>
XML:
<dsQueryResponse>
<Rows>
<Row Title="Agenda" />
<Row Title="Policy" />
<Row Title="Policy" />
<Row Title="Report" />
<Row Title="Report" />
</Rows>
</dsQueryResponse>
我现在想打破每 4 列输出的表格行,以便输出看起来像:
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ
谁能建议实现这一目标的最佳方法?
非常感谢