|
next
|
Subject: Need help with grouping Author: Minollo I. Date: 15 Jun 2006 09:31 AM
|
Something along these lines may help; not sure how you need to handle the case in which multiple entries for the same "num" element are there, but you can easily change it to fit your needs:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="chapters" match="item" use="substring(num, 1, 2)"/>
<xsl:template match="/">
<xsl:for-each select="//item[generate-id() = generate-id(key('chapters', substring(num,1,2))[1])]">
<xsl:variable name="chapter" select="substring(num,1,2)"/>Chapter <xsl:value-of select="$chapter"/><xsl:text>
</xsl:text>
<xsl:for-each select="//item[substring(num,1,2) = $chapter]">
<xsl:value-of select="num"/>
<xsl:text> </xsl:text>
<xsl:value-of select="date"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
|