mode

Syntax

mode qualified-name;

Description

Indicate the mode in which a template needs to be applied for the template to be used. If templates are applied in the specified mode, the match statement is used to determine whether the template can be used with the particular node.

This statement is comparable to the mode attribute of the <xsl:template> element. You can include this statement inside a SLAX match or apply-templates statement.

match * {
    mode "one";
    <one> .;
}
 
match * {
    mode "two";
    <two> string-length(.);
}
 
match / {
    apply-templates version {
        mode "one";
    }
    apply-templates version {
        mode "two";
    }
}
<xsl:template match="*" mode="one">
    <one>
        <xsl:value-of select="."/>
    </one>
</xsl:template>
 
<xsl:template match="*" mode="two">
    <two>
        <xsl:value-of select="string-length(.)"/>
    </two>
</xsl:template>
 
<xsl:template match="/">
    <xsl:apply-templates select="version" mode="one"/>
    <xsl:apply-templates select="version" mode="two"/>
</xsl:template>

See Example: Adding a Final then accept Term to a Firewall.

Related Topics