[xsl] transforming flat data to hierarchical data. Recursion??

Subject: [xsl] transforming flat data to hierarchical data. Recursion??
From: "dave peeters" <elechi76@xxxxxxxxxxx>
Date: Fri, 06 Jun 2003 09:39:32 +0200
I'm having the following structure in an XML file

...
<Pages>
	<PAGE id="1">
		...
		<Next id="2"/>
	</PAGE>
	<PAGE id="2">
		...
		<Next id="3"/>
	</PAGE>
	<PAGE id="3">
		...
	</PAGE>
	<PAGE id="4">
		...
		<Next id="5"/>
	</PAGE>
	<PAGE id="5">
		...
	</PAGE>
	...
</Pages>
...

And need to get to the following
...
<Pages>
	<PAGE id="1">
		...
		<Next>
			<PAGE id="2">
				...
				<Next>
					<PAGE id="3">
						...
					</PAGE>
				</Next>
			</PAGE>
		</Next>
	</PAGE>
	<PAGE id="4">
		...
		<Next>
			<PAGE id="5">
				...
			</PAGE>
		</Next>
	</PAGE>
</Pages>
...

I think I need to use recursion but I cannot get the output I want.
I tried replacing every /Next/@id with its matching element using a xsl:key on the PAGE elements based on id
but that only replaces on one level and since I don't know the lenght of the linked lists I cannot use this principle.


Does anybody have an idea how to solve this
I'm not really that familiar with xslt

Kind regards
Dave

_________________________________________________________________
Hotmail: je gratis e-mail ! http://www.msn.be/hotmail


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



Current Thread