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

RE: Grouping simple flat structure

Subject: RE: Grouping simple flat structure
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 17 Mar 2008 12:42:34 -0000
RE:  Grouping simple flat structure
There's a very early description of this problem at

http://www.stylusstudio.com/xsllist/199910/post00560.html

and a solution using the technique often called "sibling recursion" at

http://www.stylusstudio.com/xsllist/199910/post50560.html

(Interesting that these posts predate the publication of XSLT 1.0!)

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

> -----Original Message-----
> From: Ian Proudfoot [mailto:ian.proudfoot@xxxxxxxxxxx] 
> Sent: 17 March 2008 12:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Grouping simple flat structure
> 
> I have a blind spot when it comes to grouping flat XML 
> structure using XSLT 1.0. 
> 
> My source XML structure is typically as follows (simplified 
> for clarity):
> 
> <section>
>   <title/>
>   <warning/>
>   <warning/>
>   <para/>
>   <warning/>
>   <warning/>
>   <para/>
>   <para/>
> </section>
> 
> I would like to group adjacent <warning> elements to give 
> this structure:
> 
> <section>
>   <title/>
>   <w-group>
>     <warning/>
>     <warning/>
>   </w-group>
>   <para/>
>   <w-group>
>     <warning/>
>     <warning/>
>   </w-group>
>   <para/>
>   <para/>
> </section> 
> 
> I've tried using Muenchian Grouping, but I'm going wrong 
> somewhere. I started by trying to identify the start of each 
> group using <xsl:template 
> match="warning[(preceding-sibling::*[1])[not(self::warning)]]"
>... As a starting point is this correct, it does seem to > capture the
first warning in each group? After that I cannot 
> grab the following <warning> sibling elements correctly. 
> 
> 
> For this project I am stuck with XSLT 1.0 and Xalan-C 
> 
> Thanks for all help.
> Ian

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.