The <xsl:choose> instruction is a conditional construct that causes different instructions to be processed in different circumstances. The <xsl:choose> instruction contains one or more <xsl:when> elements, each of which tests an XPath expression. If the test evaluates as true, the XSLT processor executes the instructions in the <xsl:when> element. After the XSLT processor finds an XPath expression in an <xsl:when> element that evaluates as true, the XSLT processor ignores all subsequent <xsl:when> elements contained in the <xsl:choose> instruction, even if their XPath expressions evaluate as true. In other words, the XSLT processor processes only the instructions contained in the first <xsl:when> element whose test attribute evaluates as true. If none of the <xsl:when> elements’ test attributes evaluate as true, the content of the <xsl:otherwise> element, if there is one, is processed.
The <xsl:choose> instruction is similar to a switch statement in other programming languages, but the test expression can vary among <xsl:when> elements. The <xsl:when> element is the “case” of the switch statement. Any number of <xsl:when> elements can appear. The <xsl:otherwise> element is the “default” of the switch statement.
<xsl:choose>
<xsl:when test="xpath-expression">
...
</xsl:when>
<xsl:when test="another-xpath-expression">
...
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>