XSLT Elements and Attributes Shown in This Manual
The following sections explain each of the XSLT elements shown in this manual. The elements are organized alphabetically.
xsl:apply-templates
Syntax
<xsl:apply-templates select="node-set-expression"><xsl:with-param name="qualified-name" select="expression">...</xsl:with-param></xsl:apply-templates>Description
Apply one or more templates, according to the value of the
selectattribute. The nodes to which the processor applies templates are selected by the path specified by theselectattribute. The<xsl:template>instruction dictates which elements are transformed according to which template. The templates that are applied are passed the parameters specified by the<xsl:with-param>elements within the<xsl:apply-templates>instruction.Attributes
select—Selects the nodes to which the processor applies templates. By default, the processor applies templates to the child nodes of the current node.Usage Examples
See Adding a Final "then accept" Term to a Firewall and Preventing Import of the Full Routing Table.
See Also
xsl:call-template,xsl:for-each,xsl:template,xsl:with-paramxsl:call-template
Syntax
<xsl:call-template name="qualified-name"><xsl:with-param name="qualified-name" select="expression">...</xsl:with-param></xsl:call-template>Description
Call a named template. The
<xsl:with-param>elements within the<xsl:call-template>instruction are used to define parameters that are passed to the template.Attributes
name—Specifies the name of the called template.Usage Examples
See Requiring and Restricting Configuration Statements, Imposing a Minimum MTU Setting, Warning About a Deprecated Value, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:apply-templates,xsl:templatexsl:choose
Syntax
<xsl:choose><xsl:when test="boolean-expression">...</xsl:when><xsl:otherwise>...</xsl:otherwise></xsl:call-template>Description
Express multiple conditional tests. The
<xsl:choose>instruction contains one or more<xsl:when>elements, each of which tests an XPath expression. If the test evaluates as TRUE, the XSLT processor executes the instructions in the<xsl:when>element. The XSLT processor processes only the instructions contained in the first<xsl:when>element whosetestattribute evaluates as TRUE. If none of the<xsl:when>elements'testattributes evaluate as TRUE, the content of the<xsl:otherwise>element, if there is one, is processed.Usage Examples
See Controlling a Dual Routing Engine Configuration, Preventing Import of the Full Routing Table, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:if,xsl:otherwise,xsl:whenxsl:comment
Syntax
<xsl:comment>...</xsl:comment>Description
Generate a comment within the final document. The content within the
<xsl:comment>element determines the value of the comment. The content must not contain two hyphens next to each other (--); this sequence is not allowed in comments.XSLT files can contain ordinary <!
--... Insert your comment here ...--> comments, but these are ignored by the processor. To generate a comment within the final document, use an<xsl:comment>element.Usage Examples
See Adding a Final "then accept" Term to a Firewall.
xsl:copy-of
Syntax
<xsl:copy-of select="expression"/>Description
Create a copy of what is selected by the expression defined in the
selectattribute. Namespace nodes, child nodes, and attributes of the current node are automatically copied as well.Attributes
select—Specifies an expression to select nodes to be copied.Usage Examples
See Requiring and Restricting Configuration Statements.
See Also
xsl:element
Syntax
<xsl:element name="expression"/>Description
Create an element node in the output document.
Attributes
name—Specifies the name of the element to be created. The value of the name attribute can be set to an expression that is extracted from the input XML document. To do this, enclose an XML element in curly brackets ({ }), as in<xsl:element name="{$isis-level-1}".Usage Examples
See Creating a Complex Configuration Based on a Simple Interface Configuration.
xsl:for-each
Syntax
<xsl:for-each select="node-set-expression">...</xsl:for-each>Description
Include a looping mechanism that repeats XSL processing for each instance of identical XML elements. The element nodes are selected by the expression defined by the
selectattribute. Each of the nodes is then processed by the instructions contained in the<xsl:for-each>instruction.Attributes
select—Specifies an expression to select nodes to be processed.Usage Examples
See Requiring and Restricting Configuration Statements, Imposing a Minimum MTU Setting, Limiting the Number of E1 Interfaces, Adding T1 Interfaces to a RIP Group, Configuring Administrative Groups for LSPs, and Controlling a Dual Routing Engine Configuration.
See Also
xsl:if
Syntax
<xsl:if test="boolean-expression">...</xsl:if>Description
Include a conditional construct that causes instructions to be processed if the Boolean expression held in the
testattribute evaluates to TRUE.Attributes
test—Specifies a Boolean expression.Usage Examples
See Requiring and Restricting Configuration Statements, Limiting the Number of E1 Interfaces, Adding T1 Interfaces to a RIP Group, and Controlling a Dual Routing Engine Configuration.
See Also
xsl:import
Syntax
<xsl:import href="../import/junos.xsl"/>Description
Import rules from an external style sheet. Provides access to all the declarations and templates within the imported style sheet, and allows you to override them with your own if needed. Any
<xsl:import>elements must be the first elements within the style sheet, the first children of the<xsl:stylesheet>document element. The path can be any URI. The ../import/junos.xsl path shown in the syntax is standard for all commit scripts and op scripts.Imported rules are overwritten by any subsequent matching rules within the importing style sheet. If more than one style sheet is imported, the style sheets imported last override each previous import where the rules match.
Attributes
href—Specifies the location of the imported style sheet.Usage Examples
See all examples listed in Commit Script Examples.
See Also
xsl:otherwise
Syntax
<xsl:otherwise>...</xsl:otherwise>Description
Within an
<xsl:choose>instruction, include the instructions that are processed if none of the expressions defined in thetestattributes of the<xsl:when>elements evaluate as TRUE.Usage Examples
See Controlling a Dual Routing Engine Configuration and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:param
Syntax
<xsl:param name="qualified-name"select="expression">...</xsl:param>Description
Declare a parameter for a template (if it is within a template) or for the style sheet as a whole (if it is at the top level of the style sheet).
Attributes
name—Defines the name of the parameter.
select—Defines the default value for the parameter, which is used if the person or client application that executes the script does not explicitly provide a value. Theselectattribute or the content of the<xsl:param>element can define the default value. Do not specify both aselectattribute and some content; we recommend using theselectattribute so as not to create a result tree fragment.Usage Examples
See Requiring and Restricting Configuration Statements, Imposing a Minimum MTU Setting, Limiting the Number of E1 Interfaces, Limiting the Number of ATM Virtual Circuits, and Preventing Import of the Full Routing Table.
See Also
xsl:template,xsl:variable,xsl:with-paramxsl:stylesheet
Syntax
<xsl:stylesheet version="1.0"><xsl:import href="../import/junos.xsl"/>...</xsl:stylesheet>Description
Include the document element for the style sheet. Contains all the top-level elements such as global variable and parameter declarations, import elements, and templates. Any
<xsl:import>elements must be the first elements within the style sheet, the first children of the<xsl:stylesheet>document element. The path can be any URI. The ../import/junos.xsl path shown in the syntax is standard for all commit scripts and op scripts.Attributes
version—Specifies the version of XSLT that is being used. The JUNOS software supports XSLT version 1.0.Usage Examples
See all examples listed in Commit Script Examples.
See Also
xsl:template
Syntax
<xsl:template match="pattern"mode="qualified-name"name="qualified-name"><xsl:param name="qualified-name"select="expression">...</xsl:param> ...</xsl:stylesheet>Description
Declare a template that contains rules to apply when a specified node is matched. The
matchattribute associates the template with an XML element. Thematchattribute can also be used to define a template for a whole branch of the XML document For example,match="/"matches the whole document.When templates are applied to a node set using the
<xsl:apply-templates>instruction, they might be applied in a particular mode; themodeattribute in the<xsl:template>instruction indicates the mode in which a template needs to be applied for the template to be used. If templates are applied in the specified mode, thematchattribute is used to determine whether the template can be used with the particular node.You can pass templates parameters by using the
<xsl:with-param>element. To receive a parameter, the template must contain an<xsl:param>element that declares a parameter of that name. These parameters are listed before the body of the template, which is used to process the node and create a result.Attributes
match—Applies the template to nodes by specifying a pattern against which nodes are matched.
mode—Indicates the mode in which a template needs to be applied for the template to be used.
name—Calls the template by name.Usage Examples
See all examples listed in Commit Script Examples.
See Also
xsl:apply-templates,xsl:call-templatexsl:text
Syntax
<xsl:text>...</xsl:text>Description
Insert literal text in the output.
Usage Examples
See Requiring and Restricting Configuration Statements, Imposing a Minimum MTU Setting, Limiting the Number of E1 Interfaces, Controlling IS-IS and MPLS Interfaces, and Adding a Final "then accept" Term to a Firewall.
xsl:value-of
Syntax
<xsl:value-of select="string-expression"/>Description
Extract data from the XML structure. The
selectattribute specifies the expression that is evaluated. In the string expression, use@to access attributes of elements. Use "." to access the contents of the element itself. If the result is a node set, the<xsl:value-of>instruction adds the string value of the first node in that node set; none of the structure of the node is preserved. To preserve the structure of the node, you must use the<xsl:copy-of>instruction instead.Attributes
select—Specifies the expression that is evaluated.Usage Examples
See Imposing a Minimum MTU Setting, Limiting the Number of E1 Interfaces, Controlling IS-IS and MPLS Interfaces, Configuring Administrative Groups for LSPs, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:variable
Syntax
<xsl:variable name="qualified-name"select="expression">...</xsl:variable>Description
Declare a local or global variable. If the
<xsl:variable>instruction appears at the top level of the style sheet as a child of the<xsl:stylesheet>document element, it is a global variable with a scope covering the entire style sheet. Otherwise, it is a local variable with a scope of its following siblings and their descendants.Attributes
name—Specifies the name of the variable. After declaration, the variable can be referred to within XPath expressions using this name, prefixed with the$character.
select—Determines the value of the variable. The value of the variable is determined either by theselectattribute or by the contents of the<xsl:variable>element. Do not specify both aselectattribute and some content; we recommend using theselectattribute so as not to create a result tree fragment.Usage Examples
See Limiting the Number of E1 Interfaces, Limiting the Number of ATM Virtual Circuits, Configuring Administrative Groups for LSPs, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:when
Syntax
<xsl:whentest="boolean-expression">...</xsl:when>Description
Within an
<xsl:choose>instruction, specify a set of processing that occurs when the expression specified in thetestattribute evaluates as TRUE. The XSLT processor processes only the instructions contained in the first<xsl:when>element whosetestattribute evaluates as TRUE. If none of the<xsl:when>elements'testattributes evaluate as TRUE, the content of the<xsl:otherwise>element, if there is one, is processed.Attributes
test—Specifies a Boolean expression.Usage Examples
See Controlling a Dual Routing Engine Configuration, Preventing Import of the Full Routing Table, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also
xsl:choose,xsl:if,xsl:otherwisexsl:with-param
Syntax
<xsl:with-param name="qualified-name"select="expression">...</xsl:with-param>Description
Specify the value of a parameter to be passed into a template. It can be used when applying templates with the
<xsl:apply-templates>instruction or calling templates with the<xsl:call-template>instruction.Attributes
name—Specifies the name of the parameter for which the value is being passed.
select—Determines the value of the parameter. The value of the parameter is determined either by theselectattribute or by the contents of the<xsl:with-param>element. Do not specify both aselectattribute and some content. We recommend using theselectattribute to set the parameter so as to prevent the parameter from being passed a result tree fragment as its value.Usage Examples
See Controlling a Dual Routing Engine Configuration, Preventing Import of the Full Routing Table, and Automatically Configuring Logical Interfaces and IP Addresses.
See Also