Re: [xsl] Difference between current(), node() and self ??

Subject: Re: [xsl] Difference between current(), node() and self ??
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Sep 2006 13:42:00 +0100
> Until now, I thought that
> <xsl:value-of select="self"/>, <xsl:value-of select="node()"/> and
> <xsl:value-of select="current()"/> would print out the same values,
> but found out that this is not true.


the Xpath self selects the set of child elements with name self.
So in XSLT 1
<xsl:value-of select="self"/>
produces the string value of the first such element, and discards the
rest
in xslt2 it will produce the string value of each child element with
name self, separated by  space characters.


the xpath node() selects all child nodes of the current node (including,
text comments etc)

so in So in XSLT 1
<xsl:value-of select="node()"/>
produces the string value of the first such node, and discards the
rest
in xslt2 it will produce the string value of each child node, separated
by  space characters.


the Xpath current() selects the current node, so in XSL1 and XSLT2
<xsl:value-of select="current()"/> selects the string value of the
current node.

perhaps you meant self::* rather than self, self::* selects the current
node if it is an element and nothing otherwise, so it is the same as
current() if the current node is an element.

David

Current Thread