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

RE: Select elements between others

Subject: RE: Select elements between others
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 20 Jan 2004 12:48:58 -0000
where between
A classic "positional grouping" problem: try a search for "XSLT
positional grouping". In XSLT 2.0 this is easily handled using
<xsl:for-each-group group-starting-at="block">. In 1.0, there are two
main approaches:

(a) apply-templates to the block elements; for each block element,
apply-templates to the items related to that block, which you can select
as

following-sibling::item[generate-id(preceding-sibling::block[1]) =
generate-id(current())]

(b) treat it as a value-based grouping exercise, using Muenchian
grouping with the generate-id of the block element as the grouping key.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Joe Fawcett
> Sent: 20 January 2004 09:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Select elements between others
> 
> 
> I have received, what I consider to be, a badly designed xml 
> file: <data>
>   <block/>
>     <item>One</item>
>     <item>Two</item>
>   <block/>
>     <item>One</item>
>     <item>Two</item>
>     <item>Three</item>
>    <block/>
>     <item>One</item>
> </data>
> 
> I want to turn this into a more normal form to make it easier 
> to manage:
> 
> <data>
>   <block>
>     <item>One</item>
>     <item>Two</item>
>   </block>
>   <block>
>     <item>One</item>
>     <item>Two</item>
>     <item>Three</item>
>   </block>
>   <block>
>     <item>One</item>
>   </block>
> </data>
> 
> Thanks
> 
> Joe
> 
> _________________________________________________________________
> Sign-up for a FREE BT Broadband connection today! 
> http://www.msn.co.uk/specials/btbroadband
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.