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

xslt 2.0: grouping flat element structures to make lis

Subject: xslt 2.0: grouping flat element structures to make lists
From: "Derek Revill" <derek@xxxxxxxxxxxxxxxxxx>
Date: Wed, 25 May 2005 19:07:14 +0100
structures to make
Hello

Using XSLT 2.0 (running Saxon 8.4) I am grappling with a pretty standard
grouping issue, attempting to utilize some of XSLT v2 grouping possibilities
but with no success (reading the W3C spec and a scan of the archive haven't
proved helpful, MK book is on order!).

Mid flow I have:

..
..
<par class="Listbegin">Fruit</par>
<par class="Listitem>Apple</par>
<par class="Listitem>Orange</par>
<par class="Listitem>Pear</par>
<par class="Listbegin">Colours</par>
<par class="Listitem>Red</par>
<par class="Listitem>Green</par>
<par class="Listitem>Blue</par>
..
..

I just need to output

..
..
<list>
	<head>Fruit</head>
	<item>Apple</item>
	<item>Orange</item>
	<item>Pear</item>
</list>
<list>
	<head>Colours</head>
	<item>Red</item>
	<item>Green</item>
	<item>Blue</item>
</list>

Note: I'm midway through processing any section when I encounter the <par
class="Listbegin">. The signal that a list has ended can be any
following-sibling that isn't <par class="Listitem>..</par> or the end of the
parent element I'm in. Of course, lists don't always come in pairs like
above.

Should I try to match on the <par class="Listbegin"> then scoop-up all
relevant following nodes, which was my strategy up to now? Haven't been able
to find a way to scoop-up only the following nodes that are relevant.

Any advice gratefully received. Numerous attempts using for-each-group and
various group-by strategies have been fruitless, probably I just haven't
quite grasped it!

Thanks

Derek Revill

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.