if

Syntax

if (expression) {
    /* code */
}

Description

Include a conditional construct that causes instructions to be processed if the Boolean expression held in the test attribute evaluates to TRUE.

expression—Selects the nodes to which the processor applies templates. By default, the processor applies templates to the child nodes of the current node.

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

See Example: Configuring Dual Routing Engines, Example: Preventing Import of the Full Routing Table, and Example: Automatically Configuring Logical Interfaces and IP Addresses.

Related Topics