Subject: Re: XSLT 2.0 Multi-level grouping
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 9 Jan 2008 14:24:28 +0000
|
On 09/01/2008, Robert Zegwaard <data@xxxxxxxxx> 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/
|