Here is a variable that returns 12
, which is what I expect:
<xsl:variable name="MM">
<xsl:value-of select="../BIRTH_MONTH"/>
</xsl:variable>
I want to base the select
clause on a parameter. I figure something like this:
<!-- $which_date has the value "BIRTH" -->
<xsl:variable name="MM">
<xsl:value-of select="concat('../', $which_date, '_MONTH')"/>
</xsl:variable>
The above returns a value of ../BIRTH_MONTH
.
I thought the problem might be with concat()
, but below is a variant that also returns the un-evaluated result of ../BIRTH_MONTH
:
<!-- $which_date has the value "../BIRTH_MONTH" -->
<xsl:variable name="MM">
<xsl:value-of select="$which_date"/>
</xsl:variable>
(Insert history here of dozens of attempts based on tweaks with quotation marks, braces, etc...)
How can I use $which_date
in an expression that can be evaluated?
You want:
Here is a complete transformation:
When this transformation is applied on the following XML document (none was provided with the question):
the wanted, correct result is produced:
Update: Based on your other similar question, we see that you want a parameterized solution.
Here is one possible parameterized solution:
When this XSLT 1.0 transformation is applied on the following XML document:
the result is:
Do note:
Thus, the above supplied parameter results in American dates output.
But if we provide this parameter:
then the result of the transformation contains dates in European format: