I want to apply a template with a mode that depends on a variable value.
<xsl:variable name="mode" select="@attribute"/>
<xsl:apply-templates mode="{$mode}"/>
I get the error that the stylesheet cannot be compiled. The value of mode should be a QName, but it is “{$mode}”.
Is there a possibilty to use modes dependent on variables?
The only option you have to use a certain mode based on an expression is to use
or the same with an
xsl:if. Themodeattribute value itself needs to be aQNamein XSLT 1.0 respectively in XSLT 2.0 allows aQNameor special tokens like#currentor#default‘. But you can’t compute amodevalue at run-time.