<?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="if" subpage=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: xsl:if</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: xsl:if"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>xsl:if</h1>
      <p>The <code>xsl:if</code> element is used for conditional processing. It takes a mandatory <code>test</code>
attribute, whose value is a boolean expression. The contents of the xsl:if element are expanded only
of the expression is true.</p>
      <p>The full syntax of boolean 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:if test="@preface"&gt;
        &lt;a href="preface.html"&gt;Preface&lt;/a&gt;
&lt;/xsl:if&gt;</code>
         </pre>
      </div>
      <p>This includes a hyperlink in the output only if the current element has a <code>preface</code>
attribute.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="include.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>