Search code examples
xsltexslt

EXSLT String Tokenizer Context


What is the current node context inside an EXSLT Tokenizer for-each loop? I do not seem to be able to query any nodes in the documents. example:

<xsl:for-each select="str:tokenize($renderList,',')">
   <xsl:variable name ="tag" select="."/>
   <xsl:value-of select = "//tag[@name = $tag]"/>
</xsl:for-each>

If I hardcode <xsl:value-of select = "//tag[@name = 'A']"/> out side the for-each loop, the query works.

What is the context node inside the loop?


Solution

  • The problem is that in the xsl:for-each the current document isn't the original source XML document.

    This should work:

    <xsl:variable name="vDoc" select="/"/>
    <xsl:for-each select="str:tokenize($renderList,',')">
        <xsl:variable name ="tag" select="."/>
        <xsl:value-of select = "$vDoc//tag[@name = $tag]"/>
    </xsl:for-each>