How to pass variables between two templates in XSLT.
I cannot use a global variable since the value of the variable depends on the current evaluation of the node.
Let's say I have an XSLT kind:
<xsl:template match="product">
<xsl:variable name="pr-pos" select="count(./preceding-sibling::product)+1"/>
..
..
..
<xsl:apply-templates select="countries/country"/>
</xsl:template>
<xsl:template match="countries/country">
<tr id="country-id">
<td><a href="#" class="action" id="{concat('a-',$pr-pos)}">+</a></td>
..
..
This gives an error because $ pr-pos is not available in the second pattern.
How to pass the value of the pr-pos variable to another template? How can i do this?
source
share