xsl:if

xsl:if

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 <tt>if-then-else</tt> statement, however, use the <xsl:choose> element with one <xsl:when> and one <xsl:otherwise> children.

Syntax

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

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.

Optional Attributes

None.

Type

Instruction, appears within a template.

Defined

XSL section 9.1.

Gecko support

Supported

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/XSLT/if

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部