Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

XSLT Context (Dot) Overview

date_range 13-Jan-21

The current context node changes as an <xsl:apply-templates> instruction traverses the document hierarchy and as an <xsl:for-each> instruction examines each node that matches an XPath expression. All relative node references are relative to the current context node. This node is abbreviated “ .” (read: dot) and can be referred to in XPath expressions, allowing explicit references to the current node.

The following example contains four uses for “.” . The system node is saved in the system variable for use inside the <xsl:for-each> instruction, where the value of “.” will have changed. The for-each select expression uses “.” to mean the value of the name element. The “.” is then used to pull the value of the name element into the <tag> element. The <xsl:if> test then uses “.” to reference the value of the current context node.

content_copy zoom_out_map
<xsl:template match="system">
    <xsl:variable name="system" select="."/>
    <xsl:for-each select="name-server/name[starts-with(., '10.')]">
        <tag><xsl:value-of select="."/></tag>
        <xsl:if test=". = '10.1.1.1'">
            <match>
                <xsl:value-of select="$system/host-name"/>
            </match>
        </xsl:if>
    </xsl:for-each>
</xsl:template>
footer-navigation