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

extracting tree from flat xml data

Subject: extracting tree from flat xml data
From: Larry_Mason@xxxxxx
Date: Tue, 13 Mar 2001 16:04:21 -0600
extracting 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


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.