xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 2.0 Multi-level grouping

2008-01-09 07:25:11
On 09/01/2008, Robert Zegwaard <data(_at_)dehoog(_dot_)nl> wrote:
---------------------------------------
Desired XML (OUTPUT)
---------------------------------------
<Computers>
    <Hardware>
        <Hardisks>
            <Product>
                Seagate 200GB
            </Product>
            <Price>
                129,-
            </Price>
             <Product>
                Maxtor 160GB
            </Product>
            <Price>
                109,-
            </Price>
        </Hardisks>

Do you really want <Product> and <Price> to be associated by position?
 That's a very poor choice if you have control over it, as it makes
processing them so much harder later...

You probably want an extra element called <Harddisk> in there eg:

<Harddisks>
  <Harddisk>
    <Product>..
    <Price>..
  </Harddisk>
  <Harddisk>...
      <Product>
      <Price>...
   </
</

Either way grouping the elements is easy enough, something like:

<xsl:for-each-group select="*" group-by="name()">
  <xsl:element name="current-grouping-key()">
 ....


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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