- From: Norman Walsh <ndw@nwalsh.com>
- Date: Thu, 07 Jun 2007 12:28:39 -0400
- To: public-xml-processing-model-wg@w3.org
- Message-ID: <874pljwwy0.fsf@nwalsh.com>
/ ht@inf.ed.ac.uk (Henry S. Thompson) was heard to say:
[...Henry's cogent arguments elided...]
Looking at the example in Henry's mail, it suddenly became clear to me
why we can't use position() inside a for-each or viewport as we've
been considering. The observation is so simple, I can't believe no one
else made it before, so let me know if I'm once again overlooking the
obvious.
Consider his example:
<p:for-each name="myloop">
<p:group>
<p:option name="index" select="position()"/>
. . .
What is the context for that p:option? Depending on what we say about
the default context for p:option, it's equivalent to one of the
following two rewrites:
<p:option name="index" select="position()">
<p:empty/>
</p:option>
or
<p:option name="index" select="position()">
<p:pipe step="myloop" port="current"/>
</p:option>
In the former case, the expression is a dynamic error. In the latter
case, position() = 1 because current doesn't produce a sequence.
I don't think there's any existing XProc construct which will evaluate
the XPath expression that contains position() in the right context.
So I think we're stuck with p:index('stepname') for counting
iterations in p:for-each and p:viewport.
Henry's analysis does make it clear, I think, that position() is the
right answer for atomic steps that accept an XPath expression.
Be seeing you,
norm
--
Norman Walsh <ndw@nwalsh.com> | Everything should be made as simple as
http://nwalsh.com/ | possible, but no simpler.
Received on Thursday, 7 June 2007 16:28:55 UTC