XSLT current()Function
Complete XSLT Function Reference
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()"/>
Equal to
<xsl:value-of select="."/>
However, there is a difference. Let's look at the following XPath expression: "catalog/cd". The expression selects the <catalog> child node of the current node, and then selects 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 whose title attribute value equals the ref attribute value 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.
Syntax
Example 1
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd/artist">
Current node: <xsl:value-of select="current()"/>
<br />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
View XML file、 View XSL file、 View result。
Complete XSLT Function Reference Other Extensions