Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

jcs:emit-change Template

XSLT Syntax

<xsl:call-template name="jcs:emit-change">
    <xsl:with-param name="content">
        ...
    </xsl:with-param>
    <xsl:with-param name="dot" select="expression"/>
    <xsl:with-param name="message">
        <xsl:text>message</xsl:text>
    </xsl:with-param>
    <xsl:with-param name="name" select="name($dot)"/>
    <xsl:with-param name="tag" select="'(change | transient-change)'"/>
</xsl:call-template>

SLAX Syntax

call jcs:emit-change($dot=expression, $name = name($dot), $tag = "(change | transient-change)" {
    with $content = {
        ...
} with $message = { expr "message"; } }

Description

Generate a <change> or <transient-change> element, which results in a persistent or transient change to the configuration.

Parameters

This template includes the following optional parameters:

content

Content of the persistent or transient change, relative to dot.

dot

XPath expression specifying the hierarchy level at which the change will be made. The default location is the position in the XML hierarchy that the script is currently evaluating. You can alter the default when you call the template by including a valid XPath expression either for the dot parameter in SLAX scripts or for the select attribute of the dot parameter in XSLT scripts.

message

Warning message displayed in the CLI notifying the user that the configuration has been changed. The message parameter automatically includes the edit path, which defaults to the current location in the XML hierarchy. To change the default edit path, specify a valid XPath expression either for the dot parameter in SLAX scripts or for the select attribute of the dot parameter in XSLT scripts.

name

Allows you to refer to the current element or attribute. The name() XPath function returns the name of an element or attribute. The name parameter defaults to the value name($dot), which is the name of the element in dot (which in turn defaults to “ . ”, which is the current element).

tag

Type of change to generate. By default, the jcs:emit-change template generates a persistent change, as designated by the 'change' expression. To specify a transient change, you must include the tag parameter and include the 'transient-change' expression.

Usage Examples

The following example demonstrates how to call the jcs:emit-change template in a commit script:

<xsl:template match="configuration">
    <xsl:for-each select="interfaces/interface/unit[family/iso]">
        <xsl:if test="not(family/mpls)">
            <xsl:call-template name="jcs:emit-change">
                <xsl:with-param name="message">
                    <xsl:text>Adding 'family mpls' to ISO-enabled interface</xsl:text>
                </xsl:with-param>
                <xsl:with-param name="content">
                    <family>
                        <mpls/>
                    </family>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:for-each>
</xsl:template>

When you commit a configuration that includes one or more interfaces that have IS-IS enabled but do not have the family mpls statement included at the [edit interfaces interface-name unit logical-unit-number] hierarchy level, the jcs:emit-change template adds the family mpls statement to the configuration and generates the following CLI output:

[edit]
user@host# commit
[edit interfaces interface so-1/2/3 unit 0]
    warning: Adding 'family mpls' to ISO-enabled interface
[edit interfaces interface so-1/2/3 unit 0]
    warning: Adding ISO-enabled interface so-1/2/3.0 to [protocols mpls]
[edit interfaces interface so-1/3/2 unit 0]
    warning: Adding 'family mpls' to ISO-enabled interface
[edit interfaces interface so-1/3/2 unit 0]
    warning: Adding ISO-enabled interface so-1/3/2.0 to [protocols mpls]
commit complete

The content parameter of the jcs:emit-change template provides a simpler method for specifying a change to the configuration. For example, consider the following code:

<xsl:with-param name="content">
    <family>
        <mpls/>
    </family>
</xsl:with-param>

The jcs:emit-change template converts the content parameter into a <change> request. The <change> request inserts the provided partial configuration content into the complete hierarchy of the current context node. Thus, the jcs:emit-change template changes the hierarchy information in the content parameter into the following code:

<change>
    <interfaces>
        <interface>
            <name><xsl:value-of select="name"/></name>
            <unit>
                <name><xsl:value-of select="unit/name"/></name>
                <family>
                    <mpls/>
                </family>
            </unit>
        </interface>
    </interfaces>
</change>

If a transient change is required, the tag parameter can be passed in as 'transient-change', as shown here:

<xsl:with-param name="tag" select="'transient-change'"/>

The extra quotation marks are required to allow XSLT to distinguish between the string "transient-change" and the contents of a node named "transient-change". If the change is relative to a node other than the context node, the parameter dotcan be set to that node, as shown in the following example, where context is set to the [edit chassis] hierarchy level:

<xsl:for-each select="interfaces/interface/unit">
    ...
    <xsl:call-template name="jcs:emit-change">
        <xsl:with-param name="dot" select="chassis"/>
            ...

See also Example: Imposing a Minimum MTU Setting.

Published: 2013-03-05

Published: 2013-03-05