with
Syntax
with $name = value;
Description
Specify a parameter to pass into a template. You
can use this statement when you apply templates with the apply-templates statement or invoke templates with
the call statement.
Optionally, you can specify a value for the parameter by including
an equal sign (=) and a value expression.
If no value is specified, the current value of the parameter is passed
to the template.
Attributes
name |
Name of the variable or parameter for which the value is being passed. |
value |
Value of the parameter being passed to the template. |
SLAX Example
match configuration {
var $domain = domain-name;
apply-templates system/host-name {
with $message = "Invalid host-name";
with $domain;
}
}
match host-name {
param $message = "Error";
param $domain;
<hello> $message _ ":: " _ . _ " (" _ $domain _ ")";
}XSLT Equivalent
<xsl:template match="configuration">
<xsl:apply-templates select="system/host-name">
<xsl:with-param name="message" select="'Invalid host-name'"/>
<xsl:with-param name="domain" select="$domain"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="host-name">
<xsl:param name="message" select="'Error'"/>
<xsl:param name="domain"/>
<hello>
<xsl:value-of select="concat($message, ':: ', ., ' (', $domain, ')')"/>
</hello>
</xsl:template>Usage Examples
See Example: Configure Dual Routing Engines, Example: Prevent Import of the Full Routing Table, and Example: Automatically Configure Logical Interfaces and IP Addresses.
Release Information
Statement introduced in version 1.0 of the SLAX language.