[Contents] [Prev] [Next] [Index] [Report an Error]

if, else if, and else Statements

SLAX supports if, else if, and else statements. The expressions that appear in parentheses are extended XPath expressions, which support the double equal sign (==) in place of XPath’s single equal sign (=).

if (expression) {
/* If block Statement */ } else if (expression) {
/* else if block statement */ } else {
/* else block statement */ }

Depending on the presence of the else clause, an if statement is transformed into either an <xsl:if> element or an <xsl:choose> element.

if (starts-with(name, "fe-")) {
    if (mtu < 1500) {
        /* Select Fast Ethernet interfaces with low MTUs */
    }
}
else {
    if (mtu > 8096) {
        /* Select non-Fast Ethernet interfaces with high MTUs */
    }
}

The XSLT equivalent:

<xsl:choose>
    <xsl:when select="starts-with(name, 'fe-')">
        <xsl:if test="mtu &lt; 1500">
            <!- - Select Fast Ethernet interfaces with low MTUs - ->
        </xsl:if>
    </xsl:when>
    <xsl:otherwise>
        <xsl:if test="mtu &gt; 8096">
            <!- - Select non-Fast Ethernet interfaces with high MTUs - ->
        </xsl:if>
    </xsl:otherwise>
</xsl:choose>

[Contents] [Prev] [Next] [Index] [Report an Error]