Re: The semantics of position() -- trying to be very explicit

Innovimax SARL wrote:
> Two questions :
> 1) what about empty sequences ?

In a <p:for-each> or <p:viewport>, then the body doesn't execute, so you 
never need to evaluate a position() call in this context.

In a <p:option>, <p:parameter>, <p:choose> or <p:when>, I think that it 
should be a dynamic error (which MAY be reported statically) if the 
context supplied is anything but a single document.

When an XPath is passed as an option to a step, then it's up to the step 
how it's evaluated. <p:matching-documents> will be like <p:for-each>, 
for example.

> 2) Are we clear that "position()" cannot be evaluated in a @match ?

Patterns can't contain position() except within a predicate. For 
example, match="div[1]" is a shorthand for match="div[position() = 1]", 
and will match any <div> that is the first <div> child of its parent.

> and cannot be evaluated in a @select of a for-each (since this one
> should evaluate a node set), nor in a @select of a p:input. 

Since these must return nodes, and there's no operator that uses 
position() to create a node, then the only way position() can appear in 
these contexts is within a predicate.

> So position() could only be used in
> * a p:when/@test
> * a p:option/@select as a constant (position() is evaluated and then
> concatenated for example : few useful use cases)
> * a p:option/@value for something waiting for a boolean or a number
> or a string after having evaluated it as XPath
>   + option(test) in matching document (p:subsequence)
>   + a bunch of options evaluated to number or string (few useful use cases)
> 
> As a consequence, are we clear that using position() instead of
> p:position(), gives us only two places where to use this construct in
> a potentially useful manner ?

You make it sound as though p:position() could be used in other 
contexts? I can't see how.

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com

Received on Thursday, 7 June 2007 07:29:26 UTC