I am writing a function that takes a parameter. I would like to use that parameter (which should be a string) to construct a variable name. As an example:
<xsl:function name="getVarWithName">
<xsl:param name="name" />
<xsl:variable name="return"><xsl:choose>
<xsl:when test="$var$name"><xsl:value-of select="$var$name" /></xsl:when>
<xsl:otherwise>Does Not Exist</xsl:otherwise>
</xsl:choose></xsl:variable>
</xsl:function>
I would hope that calling the above function with the parameter sample
would attempt to access the variable varsample
.
Is this possible in XSL, and if so, how do I do that?