This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
extracting tree from flat xml data
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] extracting tree from flat xml data
- From: Larry_Mason at i2 dot com
- Date: Tue, 13 Mar 2001 16:04:21 -0600
- Reply-To: xsl-list at lists dot mulberrytech dot com
Given the following xml where depth indicates the level within a tree,
<data>
<person> <node depth="0">granddad</node> </person>
<person> <node depth="1">child 1</node> </person>
<person> <node depth="1">child 2</node> </person>
<person> <node depth="2">grandchild 1</node> </person>
<person> <node depth="2">grandchild 2</node> </person>
<person> <node depth="1">child 3</node> </person>
</data>
I would like to emit the following
<table>
<tr><td id="node_1">granddad</td></tr>
<tr><td id="node_1_1"> child1</td></tr>
<tr><td id="node_1_2"> child2</td></tr>
<tr><td id="node_1_2_1"> grandchild 1</td></tr>
<tr><td id="node_1_2_2"> grandchild 2</td></tr>
<tr><td id="node_1_3"> child 3</td></tr>
</table>
The value for id is based on the relationship in the heirarchy. I have a
JSP version of this working but need an XSLT solution also. It seems some
processing of ancestors and their siblings is in order to build the value
for id but the exact magic eludes me. The logic must initiated from within
the 'node' template (no for-each processing by a "higher" template, ie data
or person ). Any suggestions?
Cheers!
Larry Mason
Senior Member Technical Staff
i2 Technologies
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list