[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] flat tree to expanded tree


Subject: [xsl] flat tree to expanded tree
From: "bix xslt" <bix_xslt@xxxxxxxxxxx>
Date: Thu, 12 Dec 2002 22:04:36 +0000

All,

I am working on a grouping problem that I have been placed in charge of.
From the list I've gathered that I more than likely need to use Steve
Muench's algorithm to quickly and effectively sort my somewhat complex list. However, I'm at a loss as to how to procede.

I've included the DTD and a sample XML for the problem at hand, however I feel that I should explain why this is more complex than a simple sort. In addition to sorting each of the 'proc' elements by alphabetizing, I would also like to sort by creating a collapsable tree. In addition, I am expecting my xml tree to be scattered across several files.

The 'proc' element includes two additional elements: 'exec' and 'dpnd'.

The 'dpnd' implies that there is an additional dependency on the 'proc' element. In other words, when I group the list, I need to include those items within the 'dpnd' prior to the 'proc' element that includes it.

The 'exec' has a type attribute associated with it which implies that either the list may have ('a') any order or ('i') the order has been specified explicitly.

Finally, the 'proc' element has a type attribute that states that the items within the 'exec' list might be interleaved ('r') with any other list (i.e. a dependency) or must be listed within that order ('e').

A quick DTD:

<!ELEMENT list (proc)*>
<!ELEMENT proc (exec|dpnd)*>
<!ELEMENT exec (item)*>
<!ELEMENT dpnd (item)*>
<!ELEMENT item EMPTY>

<!ATTLIST list
   mode CDATA #IMPLIED


<!ATTLIST proc id ID #REQUIRED type (r|e) 'r'


<!ATTLIST exec type (i|a) 'i'


<!ATTLIST item idr IDREF #REQUIRED


And a small xml listing to clarify the complexities:


-- file 1 --
<list mode="normal">
   <proc id="a" />
</list>

-- file 2 --
<list mode="normal">
   <proc type="r" id="b">
       <exec type="a">
           <item idr="c" />
           <item idr="d" />
       </exec>
   </proc>

   <proc type="e" id="c">
       <dpnd>
           <item idr="a" />
       </dpnd>
       <exec type="a">
           <item idr="e" />
           <item idr="f" />
       </exec>
   </proc>
</list>

-- file 3 --
<list mode="normal">
   <proc id="d">
       <dpnd>
           <item idr="g" />
       </dpnd>
   </proc>
</list>

-- file 4 --
<list mode="normal">
   <proc id="e" />
   <proc id="f" />

   <proc id="g" />
</list>


So as an output, I might have: 1) an alphabetical listing: a b c d e f g

2) a hierarchical listing (simply creating an expandable tree):

a
b
d
c
 e
 f
g

3a) an execution listing (this can be an expandable tree - preferred):
b
g
d
a
c
 e
 f

3b) an execution listing (flat list - acceptable):
b
g
d
a
c
e
f

I honestly don't know where to begin, so if any of you have references or small samples of xsl I can hack up that would be great!

Thanks,
Bix

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords