Context (Dot)
The current context node changes as an
<xsl:apply-template>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 "
.". Thesystemnode is saved in thesystemvariable for use inside the<xsl:for-each>instruction, where the value of "." will have changed. Thefor-eachselectexpression uses "." to mean the value of thenameelement. The "." is then used to pull the value of thenameelement into the<tag>element. The<xsl:if>test then uses "." to reference the value of the current context node.<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>