On 5/24/07, cknell(_at_)onebox(_dot_)com <cknell(_at_)onebox(_dot_)com> wrote:
Consider this multi-level grouping problem for XSLT 2.0.
Here you go:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table>
<tr>
<td>State</td>
<td>City</td>
<td>Organ</td>
<td>Count</td>
</tr>
<xsl:for-each-group select="/donors/donor" group-by="state">
<xsl:sort select="current-grouping-key()"/>
<tr>
<td><xsl:value-of select="state"/></td>
<td/>
<td/>
<td/>
</tr>
<xsl:for-each-group select="current-group()" group-by="city">
<xsl:sort select="current-grouping-key()"/>
<tr>
<td/>
<td><xsl:value-of select="city"/></td>
<td/>
<td/>
</tr>
<xsl:for-each-group select="current-group()"
group-by="organ">
<xsl:sort select="current-grouping-key()"/>
<tr>
<td/>
<td/>
<td><xsl:value-of select="organ"/></td>
<td><xsl:value-of
select="count(current-group())"/></td>
</tr>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:for-each-group>
</table>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--