XSL Call template with match tag doesn't copy values of passed param.
Hello Everyone,
I am new to XSLT, and tried searching for a solution to this problem over the internet but couldn't get any suitable answer, here's my problem statement:
I am trying to call a "template" with a parameter, which has got a "match" element defined, but it seems that parameter value is not getting copied when the called "template" has got a "match" element defined:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/head">
<xsl:call-template name="getKeys">
<xsl:with-param name="Keys">IndexOne</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="/head/childOne/body" name="getKeys">
<xsl:param name="Keys"/>
<xsl:for-each select="table">
<xsl:if test="$Keys='IndexOne'"> <=== The IF statement is not evaluated
to true with "match" element defined.
Do Some processing ........
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:template>
The If statement is never evaluated to true as the param "Keys" contains null (""). The code under If statements hits if I remove the "match" element in "getKeys" template tag.
The reason for using "match" element is to avoid multiple occurrences of code under the if statement while iterating through the nodes. Appreciate if anyone can suggest a solution for it. Thanks in advance.
|