In the XML rendering of the custom syntax within an apply-macro statement, parameters and their values are contained in <name> and <value> elements, respectively. The <name> and <value> elements are sibling children of the <data> element. For example, the apply-macro blue-type-lsp statement contains six parameters, as follows:
[edit protocols mpls]
user@host# show
apply-macro blue-type-lsp {
10.1.1.1;
10.2.2.2;
10.3.3.3;
10.4.4.4;
color blue;
group-value 0;
}
The parameters and values are rendered in JUNOS XML tag elements as follows:
[edit protocols mpls]
user@host# show | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/7.4R1/junos">
<configuration>
<protocols>
<mpls>
<apply-macro>
<name>blue-type-lsp</name>
<data>
<name>10.1.1.1</name>
</data>
<data>
<name>10.2.2.2</name>
</data>
<data>
<name>10.3.3.3</name>
</data>
<data>
<name>10.4.4.4</name>
</data>
<data>
<name>color</name>
<value>blue</value>
</data>
<data>
<name>group-value</name>
<value>0</value>
</data>
</apply-macro>
</mpls>
</protocols>
</configuration>
</rpc-reply>
When you write commit script macros, referring to the <data>, <name>, and <value> elements allows you to extract and manipulate the parameters contained in apply-macro statements. For example, in the following select attribute, the XPath expression extracts the text contained in the <value> element that is a child of a <data> element that also contains a <name> child element with the text color. The variable declaration assigns the text of the <value> element to a variable named $color.
- <xsl:variable name="color" select="data[name = 'color']/value"/>