xsl:if¶
Used for conditional processing. It takes a mandatory test attribute, whose value is a boolean expression. The contents of the xsl:if
element are expanded only of the expression is true.
Available in XSLT 1.0 and later versions. Available in all Saxon editions.
- Category: instruction
- Content: sequence-constructor
- Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element
Attributes¶
test
- expression
- The boolean expression to be tested. The full syntax of boolean expressions is outlined in XPath Expression Syntax.
Examples¶
Includes a hyperlink in the output only if the current element has a preface attribute:
<xsl:if test="@preface">
<a href="preface.html">Preface</a>
</xsl:if>