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

RE: [XSLT2] Grouping by matching properly nested pairs

Subject: RE: [XSLT2] Grouping by matching properly nested pairs
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 15 Nov 2006 23:57:55 -0000
nested pairs
I think you do want group-starting-with="start", but constrained to the
"top-level" start elements, thus:

group-starting-with="start[count(preceding-sibling::start) =
count(preceding-sibling::end)]"

then you need to do the grouping again recursively on these groups to get
the next level, and so on.

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

> -----Original Message-----
> From: Christian Roth [mailto:roth@xxxxxxxxxxxxxx] 
> Sent: 15 November 2006 21:46
> To: XSL List
> Subject:  [XSLT2] Grouping by matching properly nested pairs
> 
> (A grouping question - again...)
> 
> The task is to create a nested grouping from a flat list of 
> elements based on matching "properly nested" <start/> and 
> corresponding <end /> elements. Nesting depth is arbitrary.
> 
> Source XML:
> 
> <root>
>     <a />
>     <start />
>     <b />
>     <start />
>     <c />
>     <end />
>     <d />
>     <start />
>     <start />
>     <e />
>     <end />
>     <f />
>     <end />
>     <g />
>     <end />
> </root>
> 
> or, for better legibility indented with the intended result in mind:
> 
> <root>
>     <a />
>     <start />
>       <b />
>       <start />
>         <c />
>       <end />
>       <d />
>       <start />
>         <start />
>           <e />
>         <end />
>         <f />
>       <end />
>       <g />
>     <end />
> </root>
> 
> 
> The result should be:
> 
> <root>
>     <a />
>     <group>
>       <b />
>       <group>
>         <c />
>       </group>
>       <d />
>       <group>
>         <group>
>           <e />
>         </group>
>         <f />
>       </group>
>       <g />
>     </group>
> </root>
> 
> How is this best tackled? group-starting-with="" doesn't seem 
> to be the way to go, because it will create non-nested groups 
> on each <start />, but the groups need to be nested.
> 
> -Christian

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.