[XSL-LIST Mailing List Archive Home]
Re: [xsl] Locating an attribute and its value indirectly
Subject: Re: [xsl] Locating an attribute and its value indirectly|
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 07 Nov 2011 12:15:52 -0500
On 11/4/2011 9:27 PM, G. Ken Holman wrote:
The current() function returns that node that was current at the
beginning of the evaluation of the XPath expression.
I'm sure Ken won't mind if I add a little color commentary. It may help
to keep in mind that the "context node" is an XPath concept, while the
"current node" is an XSLT concept.
In XPath, the evaluation context for an expression provides inputs that
may affect the results of evaluation; it includes a "context node" which
is, for example, used as the starting point for a relative path.
In a path with several steps, the context changes with each step.
Similarly, predicates are evaluated relative to context(s) defined in
the step they qualify. So two paths like "*/*" and "*/*" can
return two different things: the positional predicate here is applied to
different sets of nodes (evaluated in different contexts).
(Indeed, to make sense of positional predicates it may help also to know
that the XPath processor also keeps track of "context size" and "context
position", i.e. whether a node selected is first of three, or whatever.)
In XSLT, the *current node* is a node matched by a template rule or
selected for processing by a for-each instruction. Among other things,
the current node serves as the initial context node for any XPath in the
So when you say "path/to/node", the context node is different in every
step (actually any step may have many context nodes or none, depending
on what came back from the previous step), while the current node is
still the same as it is at the front (and is retrievable using the
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
Mulberry Technologies: A Consultancy Specializing in SGML and XML