9.5. The <xsl:if> Instruction Element

The <xsl:if> element performs a simple Boolean test, evaluating an expression in the required test attribute and returning either true or false. The content of <xsl:if>, which is a template, is instantiated if the result of evaluating the expression returns true; otherwise, it is ignored. The special kind of expression (boolean-expression) designated as the value of the test attribute can only produce a Boolean result. In other words, the expression will be evaluated and converted to a Boolean by the XSLT processor. The <xsl:if> element is an instruction element, as shown in the following element model definition:

<!-- Category: instruction -->

<xsl:if

  test = boolean-expression>

  <!-- Content: template --> ...

Get XSLT and XPATH: A Guide to XML Transformations now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.