[xsl] xform from node-within-node to nodelist-then-edgelist?

Subject: [xsl] xform from node-within-node to nodelist-then-edgelist?
From: Martin Whinnery <martin@xxxxxxxxxxxxxxxxxxx>
Date: 23 Mar 2004 21:46:28 +0000
Hope this isn't too dumb-ass a question..

I've got an input file, of the form..

<node>
        <node>blah blah</node>
        <node>
                <node>blah blah</node>
        </node>
<node>

so basically an outline structure.

I want to transform this into a structure suitable for display using the
touchgraph linkbrowser, which wants files of the form..

<nodelist>
        <node id="1">blah blah</node>
        <node id="2">blah blah</node>
        <node id="3">blah blah</node>
        <node id="4">blah blah</node>
</nodelist>
<edgelist>
        <edge fromid="1" toid="2">
        <edge fromid="1" toid="3">
        <edge fromid="3" toid="4">
</edgelist>

I've left a bunch of irrelevant stuff out.

Now, I can create the edges no problem, by using generate-id() to make
the node-id then passing the node-id as a parameter when I call the
template recursively on the child nodes. No probs.

What I can't seem to work out is how to delay the output of the edges
until after I have finished the nodes.

Any thoughts? Can I do this with XSLT? A friend whose opinions I respect
has suggested that FO is what I need to be using, but I can't make head
nor tail of that. Is he right? Do I need to go back and understand FO?

regards

Martin Whinnery

Current Thread