xsl:when

Used within an xsl:choose element to indicate one of a number of choices. With XSLT 4.0 syntax enabled, it may also appear within xsl:switch.

Content: sequence-constructor
Permitted parent elements: xsl:choose

Attributes

test

expression

XPath expression. If this is the first xsl:when element within the enclosing xsl:choose whose test condition matches the current element, the content of the xsl:when element is expanded, otherwise it is ignored.

select?

expression

XPath expression. Experimental: available only if XSLT 4.0 constructs are enabled. Provides an alternative way of supplying the return value when the test condition matches; if present, the contained sequence constructor must be empty.

Notes on the Saxon implementation

The select attribute is implemented from Saxon 10, provided syntax extensions are enabled.

Details

Note that forwards-compatibility mode in previous versions of XSLT does not handle the select attribute particularly well. If an XSLT 3.0 processor encounters an xsl:when instruction with a select attribute, and the instruction has an effective version of 4.0, the select attribute will simply be ignored, which will generally give incorrect results.

Links to W3C specifications

XSLT 2.0 Specification

XSLT 3.0 Specification

XSLT 4.0 Specification

See also

xsl:choose

xsl:switch

xsl:otherwise

xsl:if