Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

attribute-set

Syntax

attribute-set attribute-set-name {;
    attribute attribute-name1 { attribute-value1; }
    attribute attribute-name2 { attribute-value2; }
    use-attribute-sets attribute-set-name2;
...
}

Release Information

Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.

Description

Define a collection of attributes that can be used repeatedly. The attribute-set statement must be defined as a top-level statement in the script. The attribute set name is a string argument. The attribute set contents define the attributes to include in the collection. The contents can include individual attribute statements, which define attributes as a name and value pair, and they can include use-attribute-sets statements, which add the attributes from a previously defined attribute set to the current set.

To apply the attributes in an attribute set to a specific element, include the use-attribute-sets statement under that element and reference the attribute set name.

Attributes

attribute-set-name

Name of the attribute set, which must be a string. To add the attribute set to an element, reference this name in the use-attribute-sets statement.

attribute-name

Name of the individual attribute to add to the set.

attribute-value

A block of statements enclosed in curly braces that defines the attribute value.

SLAX Example

The following example creates two attribute sets: table-attributes and table-attributes-ext. The table-attributes-ext set includes all of the attributes that are already defined in the table-attributes set through use of the use-attributes-sets statement. In the main script body, the table-attributes-ext attribute set is applied to the <table> element. The <table> element includes the four attributes: order, cellpadding, cellspacing, and border.

version 1.1;

var $cellpadding = "0";
var $cellspacing = "10";

attribute-set table-attributes {
    attribute "order" { expr "0"; }
    attribute "cellpadding" { expr $cellpadding; }
    attribute "cellspacing" { expr $cellspacing; }
}
attribute-set table-attributes-ext {
    use-attribute-sets table-attributes;
    attribute "border" { expr "0"; }
}

match / {
    ...
    <table> {
        use-attribute-sets table-attributes-ext;
    }
}

XSLT Equivalent

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:variable name="cellpadding" select="0"/>
    <xsl:variable name="cellspacing" select="10"/>
    <xsl:attribute-set name="table-attributes">
        <xsl:attribute name="order">
            <xsl:text>0</xsl:text>
        </xsl:attribute>
        <xsl:attribute name="cellpadding">
            <xsl:value-of select="$cellpadding"/>
        </xsl:attribute>
        <xsl:attribute name="cellspacing">
            <xsl:value-of select="$cellspacing"/>
        </xsl:attribute>
    </xsl:attribute-set>
    <xsl:attribute-set name="table-attributes-ext" use-attribute-sets="table-attributes">
        <xsl:attribute name="border">
            <xsl:text>0</xsl:text>
        </xsl:attribute>
    </xsl:attribute-set>
    <xsl:template match="/">
        <table use-attribute-sets="table-attributes-ext"/>
    </xsl:template>
</xsl:stylesheet>

Published: 2013-03-05