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

Subject: Re: [xsl] xform from node-within-node to nodelist-then-edgelist?
From: Brian Chrisman <brian.chrisman@xxxxxx>
Date: Tue, 23 Mar 2004 15:23:31 +0100
in your match="/" template, could you first do a:
<apply-templates select="//node" mode="nodelist"/>
and then
<apply-templates select="//node" mode="edgelist"/>

?
The 'mode' attribute of the template/apply-template only came to my attention today.... as the examples I worked from previously never used it before.. saw it documented occasionally, but never really had an appreciation for it until some cool person's script ran across this mailing list earlier in the day.


Martin Whinnery wrote:

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