jcs:emit-change Template
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>...</xsl:text>
</xsl:with-param>
<xsl:with-param name="name" select="name($dot)"/>
<xsl:with-param name="tag" select="'change'"/>
<xsl:with-param name="tag" select="'transient-change'"/>
</xsl:call-template>
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:
- <xsl:param name="content">—Allows you to include the content of the change, relative to dot.
- <xsl:param name="dot" select=".">—Allows you to indicate a location other than the current location in the XML hierarchy. The select attribute contains the current context “.” as a default value. If you want to change the current context, you can include the dot parameter and include a different XPath expression in the select attribute.
- <xsl:param name="message">—Allows you to include a warning message to be displayed by 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, include the dot parameter.
- <xsl:param name="name" select="name($dot)"/>—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 name of the element in $dot (which in turn defaults to “ .”, which is the current element).
<xsl:param name="tag" select="'change'"/>—Allows you to specify the type of change to be generated. By default, the <jcs:emit-change> template generates a permanent change, as designated by the 'change' expression. To specify a transient change, you must include the tag parameter and include the 'transient-change' expression, as shown here:
<xsl:with-param name="tag" select="'transient-change'"/>
Usage Guidelines
The following example demonstrates how to call this 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 "dot" can 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"/>
...
Hide Navigation Pane
Show Navigation Pane
Download
SHA1