<?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 2010-10-29T18:20:48.427+01:00--><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>
&lt;xsl:choose&gt;
    &lt;xsl:when test="@cat='F'"&gt;Fiction&lt;/xsl:when&gt;
    &lt;xsl:when test="@cat='C'"&gt;Crime&lt;/xsl:when&gt;
    &lt;xsl:when test="@cat='R'"&gt;Reference&lt;/xsl:when&gt;
    &lt;xsl:otherwise&gt;General&lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
</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>