xsl-list
[Top] [All Lists]

RE: [xsl] XSLT 2.0 Multi-level grouping

2008-01-10 09:28:18
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(_at_)dehoog(_dot_)nl] 
Sent: 09 January 2008 14:17
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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>


--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--