Summary of JUNOS Named XSLT Templates

Named XSLT templates are provided in the junos.xsl import file to make scripting tasks easier in commit, op, and event scripts. All named templates have the jcs: prefix on their names to indicate they belong to the jcs: namespace. This section lists the templates in alphabetical order.

When you use named templates in a script, you must include the xmlns:jcs attribute in the opening <xsl:stylesheet> tag element and the <xsl:import/> tag element to import the junos.xsl file, as in this example:

<?xml version=”1.0”?>
<xsl:stylesheet xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0" ...other attributes...>
    <xsl:import href="../import/junos.xsl"/>
    ...
</xsl:stylesheet>

You then include an <xsl:call-template name="name"> element in the script to reference each named template, passing in any required or optional parameters.

For more information about attributes and tag elements to include in your scripts, see Required Boilerplate for Commit Scripts, Required Boilerplate for Op Scripts, and Required Boilerplate for Event Scripts.

<jcs:edit-path>

Syntax

<xsl:call-template name="jcs:edit-path">
    <xsl:with-param name="dot" select="expression"/>
</xsl:call-template>

Description

Generate an <edit-path> element suitable for inclusion in an <xnm:error> or <xnm:warning> element. By default, the location of the configuration error is passed as dot into the <jcs:edit-path> template. This location defaults to “ .” , the current position in the XML hierarchy. You can alter the default by including the select attribute of the dot parameter.

<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.

Usage Guidelines

See <jcs:edit-path> Template.

See Example: Requiring and Restricting Configuration Statements.

Related Topics

<jcs:emit-change>

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.

<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 “ .” , 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

See <jcs:emit-change> Template.

See Example: Imposing a Minimum MTU Setting.

Related Topics

<jcs:emit-comment>

Syntax

<junos:comment>
    <xsl:text>...</xsl:text>
</junos:comment>

Description

Emit a simple comment. The template contains a <junos:comment> element. You never call the <jcs:emit-comment> template directly. Rather, you include its <junos:comment> element and the child element <xsl:text> inside a call to the <jcs:emit-change> template, a <change> element, or a <transient-change> element.

Usage Guidelines

See <jcs:emit-comment> Template.

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

Related Topics

<jcs:statement>

Syntax

<xsl:call-template name="jcs:statement">
    <xsl:with-param name="dot" select="expression"/>
</xsl:call-template>

Description

Generate a <statement> element suitable for inclusion in an <xnm:error> or <xnm:warning> element. The parameter dot can be passed into the <jcs:statement> template if the error is not at the current position in the XML hierarchy.

<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.

Usage Guidelines

See <jcs:statement> Template.

See Example: Configuring Dual Routing Engines.

Related Topics