YouTip LogoYouTip

Func Current

XSLT current() Function

XSLT current() Function

--

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


Image 3: XSLT Function Reference Object 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.


Image 4: XSLT Function Reference Object Complete XSLT Function Reference Object

← Func DocumentXlink Reference β†’