[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSLT 2.0 Multi-level grouping

Subject: RE: XSLT 2.0 Multi-level grouping
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 Jan 2008 16:27:24 -0000
RE:  XSLT 2.0  Multi-level grouping
Looks to me like

<xsl:template match="Computers">
  <xsl:for-each-group select="*" group-by="name()">
    <xsl:element name="{current-grouping-key()}">
      <xsl:for-each-group select="current-group()/*" group-by="name()">
        <xsl:element name="{current-grouping-key()}">
          <xsl:copy-of select="current-group()"/>

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Robert Zegwaard [mailto:data@xxxxxxxxx] 
> Sent: 09 January 2008 14:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT 2.0 Multi-level grouping
> 
> Hi,
> 
> I'm in need for an multi-level grouping routine using XSLT 
> 2.0 I can't figure out houw to do this.
> Can anyone give me a good hint?
> 
> Robert Zegwaard
> 
> XML (INPUT)
> ---------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <Computers>
>     <Hardware>
>         <Hardisks>
>             <Product>
>                 Seagate 200GB
>             </Product>
>             <Price>
>                 129,-
>             </Price>
>         </Hardisks>
>     </Hardware>
>     <Hardware>
>         <Hardisks>
>             <Product>
>                 Maxtor 160GB
>             </Product>
>             <Price>
>                 109,-
>             </Price>
>         </Hardisks>
>     </Hardware>
>     ...
>     <Software>
>         ...
>     </Software>
>     ...
> </Computers>
> 
> ---------------------------------------
> Desired XML (OUTPUT)
> ---------------------------------------
> <Computers>
>     <Hardware>
>         <Hardisks>
>             <Product>
>                 Seagate 200GB
>             </Product>
>             <Price>
>                 129,-
>             </Price>
>              <Product>
>                 Maxtor 160GB
>             </Product>
>             <Price>
>                 109,-
>             </Price>
>         </Hardisks>
>         <Monitors>
>             ...
>         </Monitors>
>         ...
>     </Hardware>
>     <Software>
>         <Office>
>             ...
>         </Office>
>         ...
>     </Software>
> </Computers>

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.