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

Algoritm for this Hierarchy?

Subject: Algoritm for this Hierarchy?
From: "Ruggier, Mario" <Mario.Ruggier@xxxxxxxxxxxxxxxx>
Date: Sun, 3 Feb 2002 05:04:23 +0100
algoritm
Hello, 

I would like to convert the list of <obj> elements to 
the hierarchical XML output, as below, but am having 
problems identifying a workable algorithm. Can anyone 
suggest a simplest (or so ;-) algorithm for this? 

Mario Ruggier 
--
SoftPlumbers SA, 26 rue Maunoir, CH-1207 Genève
Mobile +41.79.240.8636 | Office +41.22.849.1038


===================================
Input XML (<obj> elements may occur 
in any order): 

<r>
 <obj>
   <p.array size="1">
     <v>en</v>     
   </p.array>
 </obj>
  <obj>
   <p.array size="1">
     <v>it</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="1">
     <v>fr</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="2">
     <v>one</v>
     <v>en</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="2">
     <v>uno</v>
     <v>it</v>     
   </p.array>
 </obj>
  <obj>
   <p.array size="2">
     <v>un</v>
     <v>fr</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="3">
     <v>two</v>
     <v>one</v>
     <v>en</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="3">
     <v>due</v>
     <v>uno</v>
     <v>it</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="3">
     <v>doo</v>
     <v>un</v>
     <v>fr</v>     
   </p.array>
 </obj>
 <obj>
   <p.array size="4">
     <v>trois</v>
     <v>doo</v>
     <v>un</v>     
     <v>fr</v> 
   </p.array>
 </obj>
</r>

===================================
Desired Output (order of sibling <obj> 
elements is not important):

<r>
  <obj name="en">
    <obj name="one">
      <obj name="two" />
    </obj>
  </obj>
  <obj name="fr">
    <obj name="un">
      <obj name="doo">
        <obj name="trois"/>
      </obj>
    </obj>
  </obj>
  <obj name="it">
    <obj name="uno">
      <obj name="due" />
    </obj>
  </obj>
</r>

===================================


 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.