Re: position() after match in component

/ Richard Tobin <richard@inf.ed.ac.uk> was heard to say:
| This is *NOT* about position() in document sequences.

:-)

| In a component like string-replace, a match pattern is applied to all
| the nodes in a document to identify a set of nodes, and another xpath
| expression is applied to each matching node (to determine the
| replacement text, in the string-replace case).  The context node is
| the matching node, but what is the rest of the context, i.e. the
| context position and context size?  Is the context position the
| position of the node amongst the matching nodes?  Is the context
| position the number of matching nodes?
|
| It seems obvious that the answer would be "yes" if the nodes were
| obtained from a select expression, but not so obvious given that it is
| a match pattern.

In XSLT, there's always a current node and a current node list.

  <xsl:apply-templates/>

is the same as

  <xsl:apply-templates select="*"/>

In this case, the context position/context size of the matched node is
its position amongst its element siblings (because that's what was
selected as the current node list).

However, we want to be able to stream many of our microsteps. On that
basis, I'd be in favor of saying that the context position and context
size are both 1 when the replace expression is evaluated in
p:string-replace (and in analagous situations on other steps).

The other logical possibilities I see are:

1. The position among all the matching nodes.
2. The position of the matching node among its siblings.

Both require an unbounded amount of look ahead.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | In a universe of electrons and selfish
http://nwalsh.com/            | genes, blind physical forces and
                              | genetic replication, some people are
                              | going to get hurt, other people are
                              | going to get lucky, and you won't find
                              | any rhyme or reason in it, nor any
                              | justice.--Richard Dawkins

Received on Thursday, 7 June 2007 13:14:01 UTC