Experimental: proposed new XSLT 4.0 instruction. Used to choose one of a number of alternative outputs, based on the value of a supplied expression.
Computes an atomic value that is compared with the
values in the
Available in the XSLT 4.0 proposal. Requires Saxon-PE or Saxon-EE. Implemented experimentally since Saxon 11. Available for all platforms.
Notes on the Saxon implementation
Available from Saxon 11; requires syntax extensions to be enabled.
select attribute contains an expression which must deliver
a single atomic value (it is atomized if necessary). This value is compared with
the values of the
test conditions in each of the contained xsl:when elements in turn until the first match is found. If a
match is found, that
xsl:when element is evaluated; if no match is found, the
xsl:otherwise element is evaluated;
if there is no
xsl:otherwise element, the
returns an empty sequence.
Unlike xsl:choose, the test condition in the
xsl:when element is an expression that can evaluate to any sequence of atomic
values. The comparison is done using the "=" operator, so the test succeeds if any of the
For more information, see Conditional instructions.
<xsl:switch select="@cat"> <xsl:when test="'F'">Fiction</xsl:when> <xsl:when test="'C'">Crime</xsl:when> <xsl:when test="'R', 'L'" select="my:f(@cat)"/> <xsl:otherwise>General</xsl:otherwise> </xsl:switch>