Scope (root node, context) of XSLT "key" Element -


i have xslt key defined. need access key within for-each loop, loop processing node-set outside scope of key defined.

snippet, i've marked 2 lines, 1 works , 1 not:

<xsl:value-of select="key('name', 'use')"/> <!-- works --> <xsl:for-each select="$outofscopenodeset">     <xsl:value-of select="key('name', 'use')"/> <!-- not work --> </xsl:for-each> 

is there way access key within for-each loop?

xslt 1.0, msxsl engine.

(i not think of reasonable way provide full working example this. i'm not sure of correct terminology, such "scope" - perhaps if knew correct terminology i'd able find answer already. if question not clear enough please let me know , i'll try edit better shape.)

in xslt 1.0, keys not work across documents. seems $outofscopenodeset contains node-set root node different root node of xml document being processed (probably created exsl:node-set() function?) - while key supposed fetch value processed xml document.

to resolve problem, need return context processed xml document before calling key() function, example:

<xsl:variable name="root" select="/" /> <xsl:for-each select="$outofscopenodeset">     <xsl:variable name="use" select="some-value" />     <xsl:for-each select="$root">         <xsl:value-of select="key('name', $use)"/>     </xsl:for-each> </xsl:for-each> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -