I have the following xsl that sorts my XML alphabetically:
<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')" />
<td>
<xsl:value-of select="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</td>
<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>
Now I want to split the table row every 4 columns that are output so that the output looks something like this:
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ
Can anyone suggest a better way to achieve this?
Many thanks
source
share