Re: position vs index

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Norman Walsh writes:

> We say that for the purposes of evaluating XPath expressions, the
> context position is the number of the document in the sequence. Steps
> that accept a sequence, like for-each and matching-documents, set the
> context position based on the number of document's they've processed
> and position() just "comes out right".
>
> If
>
>   <p:option name="pos" select="position()"/>
>
> occurs inside a for-each, $pos is the number of documents the for-each
> has processed.

Wrong, in my opinion -- the subpipeline inside a foreach does not have
a sequence flowing through it, so p:position() is always 1.  p:index()
counts iterations.

> If
>
>   <p:option name="test">position() mod 2 = 1</p:option>
>
> is evaluated inside a p:matching-documents, it's counting the number
> of documents that it has received.

That will indeed always be 1.

What I don't like about your proposal is that to make it work, we now
have to distinguish between the value of position() 'at the front door'
of an atomic component and its value just after you 'step inside',
which just makes no sense to me -- it's an atomic component, how can
it affect the situation wrt the sequence situation?

Also, consider a pipeline such as

 <p:pipeline>
  <p:for-each select="//div">
   <p:xslt2>
    [produces sequence]
   </p:xslt>
   <p:matching-documents>
    <p:option name="test" select="p:position() = 1"/>
    . . .

Seems clear to me that this should select the first document from each
sequence of document produced by the xslt2 step, which is what it
would do the sub-pipe were at the top level, but I don't see how it
can do that on your account, because on your account it's required to
reflect where we are in the for-each iteration. . .

ht
- -- 
 Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                     Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
            Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                   URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFGZtBvkjnJixAXWBoRAjC6AJ44w2ZqfjMRpShuOxhTqEr0pEqhxACfV4Zw
K+mhRjIhSxMWY/+CRX5BrGg=
=SWDU
-----END PGP SIGNATURE-----

Received on Wednesday, 6 June 2007 15:19:29 UTC