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

converting flat xml data into heirarchy structure

Subject: converting flat xml data into heirarchy structure
From: David Buddrige <dbuddrige@xxxxxxxxx>
Date: Mon, 9 Feb 2004 01:18:01 -0800 (PST)
heirarchy of data
Hi all,

I have a source document that is currently being
generated from an Oracle database - it is effectively
a table dump in xml format of the "scope" table..  It
has the following structure.

<scopes>
  <scope id="1" parent_id="0" details="some data"/>
  <scope id="2" parent_id="1" details="more data"/>
  <scope id="3" parent_id="1" details="info"/>
  <scope id="4" parent_id="2" details="blah"/>
  <scope id="5" parent_id="1" details="foo"/>
  <scope id="6" parent_id="2" details="log"/>
  <scope id="7" parent_id="4" details="ogg"/>
  <scope id="8" parent_id="4" details="abcd"/>
  <scope id="9" parent_id="2" details="xyz"/>
</scopes>

What I want to do is to re-organise this data so that
the xml properly represents its structure.  It forms a
tree using the parent_id to identify the parent scope
in a tree structure.

What I want to wind up with from the above data is
this:


<scopes>
 <scope id="1" parent_id="0" details="some data"/>
 <scopes>
  <scope id="2" parent_id="1" details="more data"/>
   <scopes>
    <scope id="4" parent_id="2" details="blah"/>
     <scopes>
      <scope id="7" parent_id="4" details="ogg"/>
      <scope id="8" parent_id="4" details="abcd"/>
     </scopes>
    <scope id="6" parent_id="2" details="log"/>
    <scope id="9" parent_id="2" details="xyz"/>
   </scopes>
  <scope id="3" parent_id="1" details="info"/>
  <scope id="5" parent_id="1" details="foo"/>
 </scopes>
</scopes>

Where each <scope> record has an associated <scopes>
that lists each of the <scope>
records that are related to the first scope as a
child/parent in the following format:


<scope>
  <scopes>
    ...list of child scopes here...
  </scopes>


I have been trying to fathom how to go about this,
mucking around with parameters, trying to write some
kind of recursive routine that will automatically sort
the scope records into this format, but thus far have
not been successful.  Could anyone give any hints as
to how I would go about this?

thanks heaps

David Buddrige



__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

 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.