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

Merging nested/adjacent nodes

Subject: Merging nested/adjacent nodes
From: chris <oneskiingfool@xxxxxxxxx>
Date: Thu, 19 May 2005 14:42:56 -0600
adjacent nodes
Hello,
I'm really stuck on this one.  It's probably a little too offbeat for
someone to just have the code handy ready to copy & paste.... but I
I'll give it a shot as I've already spent way too much time spinning
my wheels on it ;)

I basically want to merge adjacent nodes on a given attribute.  It
originally seemed would be simple enough to do with using
for-each-group and group-adjacent.  But the fact that I have mixed
nodes in there seems to screw that whole thing up.

---------------------------------------------------------------
Here's an example of a source doc.....
---------------------------------------------------------------
<employees>
	<supervisor name="jimmy">
		<supervisor name="bob">
			<employee name="grunt_1"/>
		</supervisor>
	</supervisor>
	<supervisor name="jimmy">
		<supervisor name="bob">
			<employee name="grunt_2"/>
		</supervisor>
	</supervisor>
	<supervisor name="jimmy">
		<employee name="grunt_3"/>
	</supervisor>
	<employee name="grunt_4"/>
	<supervisor name="jimmy">
		<supervisor name="bob">
			<employee name="grunt_5"/>
		</supervisor>
	</supervisor>
</employees>

---------------------------------------------------------------
.... and here's what I would want to transform the source doc into.....
---------------------------------------------------------------

<employees>
	<supervisor name="jimmy">
		<supervisor name="bob">
			<employee name="grunt_1"/>
			<employee name="grunt_2"/>
		</supervisor>
		<employee name="grunt_3"/>
	</supervisor>
	<employee name="grunt_4"/>
	<supervisor name="jimmy">
		<supervisor name="bob">
			<employee name="grunt_5"/>
		</supervisor>
	</supervisor>
</employees>
---------------------------------------------------------------

The order must be maintained and notice that the last 'supervisor'
node is not merged with the others of the same name because they're
not adjacent.
I'm using XSLT 2.0.  Any pointers would be MUCH appreciated.

Thanks!

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.