If you can use XSLT 2.0 (which is much more powerful than 1.0) then there's a special construct for this:
<xsl:for-each-group select="entry" group-adjacent="cell/@row">
<row id="{current-grouping-key()}">
<xsl:for-each select="current-group()">
<cell id="{cell/@col">
<xsl:value-of select="."/>
</
</
</
</
In XSLT 1.0 it's rather trickier. For the general solution to the grouping problem go to
http://www.jenitennison.com/xslt/grouping.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference