Proposed 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
Notes on the Saxon implementation
Implemented experimentally in Saxon 11; syntax extensions must 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
elements in turn until the first match is found. If a match is found, that
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.
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 values matches.
<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>