SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
| Introduction
| xsl:analyze-string
| xsl:apply-imports
| xsl:apply-templates
| xsl:attribute
| xsl:attribute-set
| xsl:call-template
| xsl:character-map
» | xsl:choose
| xsl:comment
| xsl:copy
| xsl:copy-of
| xsl:decimal-format
| xsl:document
| xsl:element
| xsl:fallback
| xsl:for-each
| xsl:for-each-group
| xsl:function
| xsl:if
| xsl:include
| xsl:import
| xsl:import-schema
| xsl:key
| xsl:matching-substring
| xsl:message
| xsl:namespace
| xsl:namespace-alias
| xsl:next-match
| xsl:non-matching-substring
| xsl:number
| xsl:otherwise
| xsl:output
| xsl:output-character
| xsl:param
| xsl:perform-sort
| xsl:preserve-space
| xsl:processing-instruction
| xsl:result-document
| xsl:sequence
| xsl:sort
| xsl:strip-space
| xsl:stylesheet
| xsl:template
| xsl:text
| xsl:value-of
| xsl:variable
| xsl:when
| xsl:with-param
| Literal Result Elements
| XSLT Patterns
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# xsl:choose

The `xsl:choose` element is used to choose one of a number of alternative outputs. The element typically contains a number of xsl:when elements, each with a separate test condition. The first `xsl:when` element whose condition matches the current element in the source document is expanded, the others are ignored. If none of the conditions is satisfied, the xsl:otherwise child element, if any, is expanded.

The test condition in the `xsl:when` element is a boolean expression. The full syntax of expressions is outlined in XPath Expression Syntax.

Example:

    <xsl:choose>
        <xsl:when test="@cat='F'">Fiction</xsl:when>
        <xsl:when test="@cat='C'">Crime</xsl:when>
        <xsl:when test="@cat='R'">Reference</xsl:when>
        <xsl:otherwise>General</xsl:otherwise>
    </xsl:choose>

Next