current Function (Compact 2013)

3/26/2014

Returns a node set that has the current node as its only member.

Syntax

node-set current()

Parameters

None.

Return Value

Returns a node set that has the current node as its only member.

Remarks

The function returns a node set that has the current node as its only member. For an outermost expression, an expression not occurring within another expression, the current node is always the same as the context node; thus

<xsl:value-of select="current()"/>

is the same as the following code.

<xsl:value-of select="."/>

However, within square brackets, the current node is usually different from the context node, as shown in the following example.

<xsl:apply-templates select="//glossary/item[@name=current()/@ref]"/>

processes all <item> elements that have a <glossary> parent element and a name attribute with value equal to the value of the current node's ref attribute. This is different from

<xsl:apply-templates select="//glossary/item[@name=./@ref]"/>

which means the same as the following code.

<xsl:apply-templates select="//glossary/item[@name=@ref]"/>

This code would process all <item> elements that have a <glossary> parent element and that have a name attribute and a ref attribute with the same value.

See Also

Reference

XSLT Functions