[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

Subject: RE: Re: XSLT 2.0 multi-level grouping challenge/problem
From: cknell@xxxxxxxxxx
Date: Thu, 24 May 2007 12:20:24 -0400
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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.