<?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 2011-12-09T20:47:22.916Z--><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><xsl:if test="@preface"> <a href="preface.html">Preface</a> </xsl:if></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>