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(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Joe Fawcett
Sent: 20 January 2004 09:29
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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