[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: XSLT 2.0 multi-level grouping challenge/proble
Thanks, I knew a was wandering around in some tall grass. There had to be a simpler answer. Heretofore I had only used the for-each-group construct in fairly simple problems. I hadn't used the "current-group()" function before, and that proved to be the key in clearing things up. -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Sent: Thu, 24 May 2007 16:13:49 +0100 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: XSLT 2.0 multi-level grouping challenge/problem On 5/24/07, cknell@xxxxxxxxxx <cknell@xxxxxxxxxx> 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|