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]

extracting tree from flat xml data



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">&nbsp;&nbsp;child1</td></tr>
<tr><td id="node_1_2">&nbsp;&nbsp;child2</td></tr>
<tr><td id="node_1_2_1">&nbsp;&nbsp;&nbsp;&nbsp;grandchild 1</td></tr>
<tr><td id="node_1_2_2">&nbsp;&nbsp;&nbsp;&nbsp;grandchild 2</td></tr>
<tr><td id="node_1_3">&nbsp;&nbsp;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


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