Im using XSLT 1.0 and im trying call a named template from within another named template. The catch is the internal named template that gets called, is getting called from a parameter passed to the outter named template.
Here is the code im using
-------------------------------------------------
Code:
<xsl:template name="makeElement">
<xsl:param name="imax3Element"/><xsl:param name="imax2Value"/><xsl:param name="translateFunc"/>
<xsl:variable name="tempVal">
<xsl:choose>
<xsl:when test="string-length($translateFunc)>0">
<xsl:call-template name="$translateFunc">
<xsl:with-param name="imax2"><xsl:value-of select="$imax2Value"/></xsl:with-param>
</xsl:call-template>
</xsl:when><xsl:otherwise>
<xsl:value-of select="$imax2Value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($tempVal)>0">
<xsl:element name="{$imax3Element}">
<xsl:value-of select="$tempVal"/></xsl:element>
</xsl:if></xsl:template>
<xsl:template name="translatePersonType">
<xsl:param name="imax2"/>
<xsl:choose>
<xsl:when test="$imax2= 'Subscriber'">S</xsl:when>
<xsl:when test="$imax2= 'Employee'">S</xsl:when>
<xsl:when test="$imax2= 'Dependent'">D</xsl:when>
<xsl:otherwise><xsl:value-of select="$imax2"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
so when the param translateFunc of the named template makeElement is equal to translatePersonType, it should call that named Template, otherwise it should not call any Named Template.
The place it is getting stuck is: <xsl:call-template name="$translateFunc"> It says it is not allowed to have a $ in the name?
Currently I just have all the Named Templates hard coded and check the values of the string, but I want to try and make it more generic so that I do not have to hand code it every time I add a new Named Template.
does anyone have any ideas?