This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

merging generic elements in a parent-child relationship


Hi!
I have this xml

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<a id="abc"/>
	<a id="abcd"/>
	<b id="b1" ida="abc"/>
	<b id="b2" ida="abc"/>
	<b id="b3" ida="abcd"/>
	<c id="c1" idb="b1"/>
</root>

this structure describes a parent-child relationship between a-b and b-c. So
I want to reformat this xml to get this

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<a id="abc">
		<b id="b1" ida="abc">
			<c id="c1" idb="b1"/>
		</b>
		<b id="b2" ida="abc"/>
	</a>
	<a id="abcd">
		<b id="b3" ida="abcd"/>
	</a>
</root>

This seems to be simple but here are the complications
1. the name of the elements to be related (a,b,c) must be generic. This
means I would like to pass them via <xsl:param>. Something like a comma
separated string
for instance, I would pass to the stylesheet this parameter: a,b,c.
2. This can go to n levels. I could have a child for <c> and a child of the
child of <c>, and so on.
   n = quantity of elements which has the comma separated param (3 in this
case).

I thought about using xsl:key in some generic way, but cannot get to the
solution. It's much more difficult than my level of xslt knowledge.

Anyway, help would be appreciated!

Matias



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]