for-each on atomic sequence

S

shaun roe

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
 
S

shaun roe

shaun roe said:
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)
 

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

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top