By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,390 Members | 2,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,390 IT Pros & Developers. It's quick & easy.

Basic XSLT question - processing result tree?

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

http://www.exslt.org/str/functions/s...plate.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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"LW" <la******************@yahoo.com> wrote in message
news:pa****************************@yahoo.com...
I'm using the following free implementation of an XSLT "split" function,
as a template:

http://www.exslt.org/str/functions/s...plate.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

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.