Basic XSLT question - processing result tree?

Discussion in 'XML' started by LW, Sep 17, 2003.

  1. LW

    LW Guest

    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
    LW, Sep 17, 2003
    #1
    1. Advertising

  2. "LW" <> wrote in message
    news:p...
    > 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
    >
    Dimitre Novatchev, Sep 18, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nicolas Stern
    Replies:
    2
    Views:
    2,742
    Dimitre Novatchev
    Aug 13, 2003
  2. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,087
  3. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    406
    Michael Foord
    Sep 17, 2004
  4. J.Ram
    Replies:
    7
    Views:
    639
  5. Michael Tan
    Replies:
    32
    Views:
    927
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page