<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html> <head> <this-is section="xsl-elements" page="choose" subpage=""/> <!-- Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: xsl:choose</title> <meta name="coverage" content="Worldwide"/> <meta name="copyright" content="Copyright Saxonica Ltd"/> <meta name="title" content="Saxonica: XSLT and XQuery Processing: xsl:choose"/> <meta name="robots" content="noindex,nofollow"/> <link rel="stylesheet" href="../saxondocs.css" type="text/css"/> </head> <body class="main"> <h1>xsl:choose</h1> <p>The <code>xsl:choose</code> element is used to choose one of a number of alternative outputs. The element typically contains a number of <a class="bodylink" href="../xsl-elements/when.xml">xsl:when</a> elements, each with a separate test condition. The first <code>xsl:when</code> 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 <a class="bodylink" href="../xsl-elements/otherwise.xml">xsl:otherwise</a> child element, if any, is expanded.</p> <p>The test condition in the <code>xsl:when</code> element is a boolean expression. The full syntax of expressions is outlined in <a class="bodylink" href="../expressions/intro.xml">XPath Expression Syntax</a>.</p> <p>Example:</p> <div class="codeblock" style="border: solid thin; background-color: #B1CCC7; padding: 2px"> <pre> <code> <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> </code> </pre> </div> <table width="100%"> <tr> <td> <p align="right"><a class="nav" href="comment.xml">Next</a></p> </td> </tr> </table> </body> </html>