RE: [xsl] Flat XML to hierarchical output ...

Subject: RE: [xsl] Flat XML to hierarchical output ...
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 20 Aug 2007 23:43:28 +0100
Search for "XSLT positional grouping".

In XSLT 2.0, use <xsl:for-each-group group-starting-with="HEADER">

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

> -----Original Message-----
> From: Tim Dexter [mailto:timothy.dexter@xxxxxxxxx] 
> Sent: 20 August 2007 23:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Flat XML to hierarchical output ...
> 
> Hi All
> 
> I have the following data structure
> 
> <REPORT>
>  <HEADER>
>   ...
>  </HEADER>
>  <LINE>
>   ...
>  </LINE>
>  <TOTAL>
>   ...
>  </TOTAL>
>  <HEADER>
>   ...
>  </HEADER>
>  <LINE>
>   ...
>  </LINE>
>  <TOTAL>
>   ...
>  </TOTAL>
>  <HEADER>
>   ...
>  </HEADER>
>  <LINE>
>   ...
>  </LINE>
>  <LINE>
>   ...
>  </LINE>
>  <LINE>
>   ...
>  </LINE>
>  <TOTAL>
>   ...
>  </TOTAL>
> </REPORT>
> 
>  Although the XML is not hierarchical there is a hierarchy 
> required in output ie HEADER  LINES TOTAL
> 
> the only thing that is guaranteed is that the data is in 
> sequential hierarchy order ie HEADER is followed by LINES by 
> TOTAL. Notice that there maybe 1 or more instances of LINE 
> following HEADER ie multi lines for a given header.
> 
> I have tried loading the HEADER-LINE-TOTAL trees into 
> variables, then looping thru the HEADER and grabbing LINE and 
> TOTAL values based on the HEADER record position(). Of course 
> a ll is fine until I hit a HEADER with multiple lines.
> 
> I'm still trying this but if anyone has come across and 
> solved a similar problem I'd greatly appreciate any input
> 
> Thanks
> 
> tim

Current Thread