Basic XSLT question - processing result tree?

L

LW

I'm using the following free implementation of an XSLT "split" function,
as a template:

http://www.exslt.org/str/functions/split/str.split.template.xsl.html

Basically, it allows me to call it like this...

<xsl:call-template name="str:split">
<xsl:with-param name="string" select="string('boy,cat,dog')" />
<xsl:with-param name="pattern" select="string(',')" />
</xsl:call-template>

....and it returns the following node...

<token>boy</token>
<token>cat</token>
<token>dog</token>

Works like a charm, but how do I take that node of <token>'s and do
further processing on it? For instance, I'd like to convert that into...

<word num="1">boy</word>
<word num="2">cat</word>
<word num="3">dog</word>

I'd prefer to avoid editing the str:split template directly, because it'd
be best if that were left generic as it is.

Seems to me I'm missing something profoundly basic here. Thanks in advance
for any help.

LW
 
D

Dimitre Novatchev

LW said:
I'm using the following free implementation of an XSLT "split" function,
as a template:

http://www.exslt.org/str/functions/split/str.split.template.xsl.html

Basically, it allows me to call it like this...

<xsl:call-template name="str:split">
<xsl:with-param name="string" select="string('boy,cat,dog')" />
<xsl:with-param name="pattern" select="string(',')" />
</xsl:call-template>

...and it returns the following node...

<token>boy</token>
<token>cat</token>
<token>dog</token>

Works like a charm, but how do I take that node of <token>'s and do
further processing on it? For instance, I'd like to convert that into...

<word num="1">boy</word>
<word num="2">cat</word>
<word num="3">dog</word>

I'd prefer to avoid editing the str:split template directly, because it'd
be best if that were left generic as it is.

Seems to me I'm missing something profoundly basic here. Thanks in advance
for any help.


Use:

<xsl:variable name="rtfSplits">
<xsl:call-template name="str:split">
<xsl:with-param name="string" select="string('boy,cat,dog')" />
<xsl:with-param name="pattern" select="string(',')" />
</xsl:call-template>
</xsl:variable>

<xsl:variable name="vSplits" select="xxx:node-set($rtfSplits)">

And then process $vSplits/* as a regular node-set.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top