[jdom-interest] Transforming flat xml to hierachial xml format

Vijay Mummaneni mvbabu at hotmail.com
Thu Oct 24 11:43:23 PDT 2002


I have an xml file that has 100 "Employee" elements. The elements are
related (they are from the RDBMS table). Each element is related to another
elemnt by employee-manager relationship. Currently it is flat xml file. What
I meant is, it looks like (I used JDOM to grab the data from the database) :

  <employee id="1" name="emp1" managerId="2" />
  <employee id="2" name="emp2" managerId="5" />
  <employee id="3" name="emp3" managerId="5" />
  <employee id="4" name="emp4" managerId="2" />
  <employee id="5" name="emp5" />

I have the above tree as a JDOM document. Here is how I want to transform it 

          <folder  id="5" name="emp5" >
                         <folder  id="2" name="emp2">
                                 <leaf  id="4" name="emp4" />
                                 <leaf  id="1" name="emp1" />
                        <leaf  id="3" name="emp3" />

Can you pl suggest me a solution, for this transformation.  Is JDOM helpful
for the transormation ?


Surf the Web without missing calls! Get MSN Broadband. 

More information about the jdom-interest mailing list