XSLT - In predicate filters, why must one sometime use the XSLT current() function rather than the XPath context node dot operator?

xmlnode, xpath, xslt

Solution

In XPath, a Location Path expression is relative to the context node, e.g.:

head/title

or

@class

Predicates are used to filter sequences (node-sets in v1). A Predicate Expression is evaluated against each item (or node) in the sequence, using the item as context. e.g.

div[@class] (: @class is relative to div :)

The `current()` function is available in XSLT (not XPath) to refer to the node currently being processed by the containing `xsl:template` or `xsl:for-each` instruction.

http://www.w3.org/TR/xslt#function-current

Problem

In a predicate filter, I am trying to figure out how best to explain why and when one must use the XSLT `current()` function rather than the XPath context node `.` expression. The example given at the w3schools XSLT `current()` Function page helps only a bit as it mostly seems to illustrate the difference without really explaining it. Both Michael Kay's discussion of the `current()` function in Chapter 13 of "XSLT 2.0 and XPath 2.0, 4th Edition" and Paul Jungwirth's reply to the question Current node vs. Context node in XSLT/XPath? help me understand the difference personally; but each leaves me struggling with how to explain the difference to others rather than merely illustrating the difference using diagrams and code. If someone will share how they have gone further in explaining this, I would be most grateful.

Original source

Related problems