Visit Mozilla.org

XSLT:if

From MDC

XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axes

Contents

The <xsl:if> element contains a test attribute and a template. If the test evaluates to true, the template is processed. In this it is similar to an if statement in other languages. To achieve the functionality of an if-then-else statement, however, use the <xsl:choose> element with one <xsl:when> and one <xsl:otherwise> children.

[edit] Syntax

<xsl:if test=EXPRESSION>
	TEMPLATE
</xsl:if>

[edit] Required Attributes

test
Contains an XPath expression that can be evaluated (using the rules defined for boolean( ) if necessary) to a Boolean value. If the value is true, the template is processed; if it is not, no action is taken.

[edit] Optional Attributes

None.

[edit] Type

Instruction, appears within a template.

[edit] Defined

XSL section 9.1.

[edit] Gecko support

Supported