XSLT current()
Function
Definition and Usage
The current()
function returns a node-set containing only the current node. Usually, the current node is the same as the context node.
<xsl:value-of select="current()"/>
is equivalent to
<xsl:value-of select="."/>
However, there is a difference. Consider the following XPath expression: "catalog/cd". The expression selects the <catalog>
child node of the current node, and then the <cd>
child node of the <catalog>
node. This means that at each step of the evaluation, "." has a different meaning.
The following line:
<xsl:apply-templates select="//cd[@title=current()/@ref]"/>
will process all cd
elements where the value of the title
attribute equals the value of the ref
attribute of the current node.
Unlike this:
<xsl:apply-templates select="//cd[@title=./@ref]"/>
This will process all cd
elements where the title
attribute and the ref
attribute have the same value.