2 users online. Create an account or sign in to join them.Users
XSLT, grouping entries
This is an open discussion with 3 replies, filed under XSLT.
Search
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d5509e292
This link gives some solutions, one particularly cute in my opinion:
<xsl:template match="data">
<table>
<xsl:for-each select="entry[position() mod $max = 1]" >
<tr>
<xsl:for-each select="self::entry |
following-sibling::entry[position() < $max]>
<td><xsl:apply-templates/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
However, I don't get the "self::entry" expression in a for loop which is already iterating over "entry" nodes. In this case I would assume that "self::entry" means tag nested in another tag, but, as this the example works, it's not the case. Strange...
Wow, I'm not the only one troubled by that :) Thank you Nick!
Create an account or sign in to comment.
Hi,
I know how to solve it, but I'm not sure my solution is the best one.
There are entries in XML.
Now, I want to have them grouped in groups of three, like:
What is the best way in your opinion to achieve this?