Can you store an element name as a variable to be called at a later date?
For example :
<xsl:variable name="element">
<xsl:choose>
<xsl:when test="Argument1">strong</xsl:when>
<xsl:when test="Argument2">em</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$element}">
<a href="{$url}">
<xsl:value-of select="title"/>
</a>
</xsl:element>
So based on a predefined argument, the element to be wrapped around the anchor tag has either to be <strong> or <em>.
Or am i approaching this wrong?
Going the long way round and duplicating the anchor tag inside a choose when statement for each argument doesn't seem to work.
Thanks, Kevin
I think your posted sample should work. With XSLT 2.0 you could even do <xsl:element name="{if (Argument1) then 'strong' else if (Argument2) then 'em' else ()}">.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With