for-each on atomic sequence

Discussion in 'XML' started by shaun roe, Dec 18, 2005.

  1. shaun roe

    shaun roe Guest

    I have the following function:

    <xsl:function name="sar:Oks2CoolRel" as="xs:string">
    <xsl:param name="oksRel" as="xs:string"/>
    <xsl:variable name="relList" >
    <xsl:value-of select="tokenize($oksRel,' ')"/>
    </xsl:variable>
    <xsl:variable name="result" >
    <xsl:value-of select="' '"/>
    <xsl:for-each select="$relList">
    <xsl:value-of select="concat(.,' ',position())"/>
    </xsl:for-each>
    </xsl:variable>
    <xsl:value-of select="$result"/>
    </xsl:function>

    in xslt 2.0.

    so , I construct a sequence using 'tokenize' on a space-separated string
    and then try to iterate over it with for-each, outputting the element
    and its position.

    However I find that all I get back is the entire string followed by a
    '1'. In other words there is only one element in the sequence which is
    the whole string... whats going wrong? Doesnt tokenize construct a
    sequence?

    cheers

    shaun
     
    shaun roe, Dec 18, 2005
    #1
    1. Advertising

  2. shaun roe

    shaun roe Guest

    In article
    <>,
    shaun roe <> wrote:

    > I have the following function:
    >
    > <xsl:function name="sar:Oks2CoolRel" as="xs:string">
    > <xsl:param name="oksRel" as="xs:string"/>
    > <xsl:variable name="relList" >
    > <xsl:value-of select="tokenize($oksRel,' ')"/>
    > </xsl:variable>
    > <xsl:variable name="result" >
    > <xsl:value-of select="' '"/>
    > <xsl:for-each select="$relList">
    > <xsl:value-of select="concat(.,' ',position())"/>
    > </xsl:for-each>
    > </xsl:variable>
    > <xsl:value-of select="$result"/>
    > </xsl:function>
    >

    Found the problem: the string I'm passing is:

    "RodMUR" "MUR3003" "RodMUR" "MUR3104" "RodMUR" "MUR3004"

    and it doesnt like the quotes (don't ask why they're there: legacy code)
     
    shaun roe, Dec 18, 2005
    #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. John Blair
    Replies:
    1
    Views:
    412
    Eliyahu Goldin
    Aug 3, 2005
  2. Tjerk Wolterink

    xsl:for-each for each 3 elements problem

    Tjerk Wolterink, Nov 3, 2004, in forum: XML
    Replies:
    3
    Views:
    429
    Tjerk Wolterink
    Nov 3, 2004
  3. Daniel Poetzinger
    Replies:
    1
    Views:
    610
    Martin Honnen
    Feb 20, 2006
  4. stef mientki
    Replies:
    13
    Views:
    646
    stef mientki
    Oct 20, 2007
  5. Charles Oliver Nutter

    [ANN] atomic 0.0.1 - An atomic reference for Ruby

    Charles Oliver Nutter, Jun 8, 2010, in forum: Ruby
    Replies:
    5
    Views:
    234
    Robert Dober
    Jun 8, 2010
Loading...

Share This Page