XSLT current() Function
--
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
XSLT Tutorial
XSLT Tutorial
XSL Language
XSLT Introduction
XSLT Browsers
XSLT Transformation
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
<a href="#" title="XSLT Element">XSLT Element
XSLT on Client
XSLT on Server
XSLT - Edit XML
XML Editors
XSLT Summary
XSLT Examples
XSLT Elements
XSLT Functions
XSLT Transformation Tools
XSLT Element Reference Manual
XSLT Transformation Tools
In-depth Exploration
Programming
Web Service
Software
Scripting Languages
Computer Science
Development Tools
Network Design and Development
Search
Programming Languages
Scripts
XSLT current() Function
Complete XSLT Function Reference Object
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()"/>
equals
<xsl:value-of select="."/>
However, there is one difference. Let's look at the following XPath expression: "catalog/cd". The expression selects the child nodes of the current node, then selects the child nodes of the node. This means that "." has a different meaning at each step of the calculation.
This line:
<xsl:apply-templates select="//cd[@title=current()/@ref]"/>
will process all elements whose title attribute value equals the ref attribute value of the current node.
Different from this:
<xsl:apply-templates select="//cd[@title=./@ref]"/>
This will process all elements with title and ref attributes having the same value.
Syntax
node-set current()
Example 1
<?xml version="1.0" encoding="ISO-8859-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.
YouTip