Basic XSLT question - processing result tree?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • LW

    #1

    Basic XSLT question - processing result tree?

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



    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
  • Dimitre Novatchev

    #2
    Re: Basic XSLT question - processing result tree?


    "LW" <latoya5552000_ nospam@yahoo.co m> wrote in message
    news:pan.2003.0 9.17.15.56.35.2 60065@yahoo.com ...[color=blue]
    > 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.[/color]


    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:nod e-set($rtfSplits) ">

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



    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL[color=blue]
    >[/color]


    Comment

    Working...