xsl-list
[Top] [All Lists]

regroup/collate like nodes

2004-10-24 08:43:15
Hi, 

I've been tackling this for a bit now but I seem
to be going in circles 

Examples are always best 

Given a document
<root>
  <a>
     <b>
        <c>
           <node1>hello</node1>
        </c>
        <d1>foo</d1>
     </b>
  </a>
  <a>
     <b>
        <c>
           <node2>world</node2>
        </c>
        <d2>bar</d2>
     </b>
  </a>
</root>

I need to group/collate the name like nodes such as

<root>
  <a>
     <b>
        <c>
           <node1>hello</node1>
           <node2>world</node2>
        </c>
        <d1>foo</d1>
        <d2>bar</d2>
     </b>
  </a>
</root>

notes...
The node names are not known so it needs to be generic.
The deepest child node is guaranteed to be unique for it's full
path .. ie, there will only be one
a/b/c/node1
but there could just easily be 
a/b/x/node1

I can see I need to walk the tree recursivley and
for each node, select/copy all other nodes that match the same
parent path and copy them in, but, also have a check that
stops it walking down a path, matched by name, that it has already done.

:-) just can't translate that to XSL..

any help would be appreciated
cheers
ramon



<Prev in Thread] Current Thread [Next in Thread>
  • regroup/collate like nodes, Ramon Buckland <=