if
Syntax
if (expression) {
/* code */
} else if (expression) {
/* code */
} else {
/* code */
}/* Syntax with optional parentheses added in SLAX version 1.3 */
if expression {
/* code */
} else if expression {
/* code */
} else {
/* code */
}Description
Include a conditional construct that causes instructions to be processed if the Boolean expression evaluates to TRUE.
Optionally, you can include multiple else if statements to perform additional
conditional tests if the if expression evaluates to
FALSE. The processor only executes the instructions contained in the
first else if statement whose expression evaluates to
TRUE. The processor ignores all subsequent else if
statements.
The optional else statement includes a default set of instructions. The
processor executes the instructions if the expressions defined in all associated
if and else if statements evaluate to
FALSE.
Attributes
expression |
Specifies the expression to evaluate. Starting in SLAX version 1.3, the parentheses enclosing the statement expression are optional. |
SLAX Example
var $description2 = {
if (description) {
expr description;
} else if (../description) {
expr ../description;
} else {
expr "no description found";
}
}XSLT Equivalent
<xsl:variable name="description2">
<xsl:choose>
<xsl:when test="description">
<xsl:value-of select="description"/>
</xsl:when>
<xsl:when test="../description">
<xsl:value-of select="../description"/>
</xsl:when>
<xsl:otherwise>unknown</xsl:otherwise>
</xsl:choose>
</xsl:variable>Usage Examples
Release Information
Statement introduced in SLAX version 1.0.
Support for syntax with optional parentheses added in SLAX version 1.3.