Hi all,
I have some XSLT code that, based on certain conditions, sets a variable "tag" to one of three string values (see below)
Code:
<xsl:choose>
<xsl:when test="test1">
<xsl:variable name="tag" select="'aaa'" />
</xsl:when>
<xsl:when test="test2">
<xsl:variable name="tag" select="'bbb'" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="tag" select="'ccc'" />
</xsl:otherwise>
</xsl:choose>
I then want to use the value of this "tag" variable as the name of an element, i.e.:
Code:
<xsl:element name="{$tag}">
some text
</xsl:element>
However when I test this it claims it cannot find the variable "$tag".
I have also tried putting the xsl:choose code in a separate template that just outputs the "tag" value as text, and then calling that template within the definition of the "tag" variable just before it is used in xsl:element.
In this case it says "Illegal value used for attribute name: bbb" (bbb being the value of "tag").
Any ideas how to get the value of $tag as the xsl:element name.
Thanks,
Neil Belch
Senior Software Technician
CDL
The views opinions and judgements expressed in this message are solely those of
the author. The message contents have not been reviewed or approved by CDL.