W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > June 2007

Re: position vs index

From: Henry S. Thompson <ht@inf.ed.ac.uk>
Date: Wed, 06 Jun 2007 16:19:11 +0100
To: Norman Walsh <ndw@nwalsh.com>
Cc: public-xml-processing-model-wg@w3.org
Message-ID: <f5by7ixaz68.fsf@hildegard.inf.ed.ac.uk>

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:for-each select="//div">
    [produces sequence]
    <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. . .

- -- 
 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]
Version: GnuPG v1.2.6 (GNU/Linux)

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:32:43 UTC