Re: Evaluation context

On Wed, 21 Dec 2016 20:31:03 +0100, Erik Bruchez <ebruchez@orbeon.com>  
wrote:

>>>>> When there is a single-node binding, the context item always has a  
>>>>> size of 1 (or may be missing). This is a bit tricky. What does this  
>>>>> do:
>>>
>>> <xf:repeat ref="1 to 10">
>>>  <xf:output value="position"/>
>>> </xf:repeat>
>>>
>>> vs.
>>>
>>> <xf:repeat ref="1 to 10">
>>>  <xf:group ref=".">
>>>    <xf:output value="position"/>
>>>  </group>
>>> </xf:repeat>
>>
>> They both do the same thing, since a repeat object is a single item  
>> binding:
>>
>> "a repeat object consisting of an implicitly generated group element  
>> that binds to the item, and containing a copy of the template."
>>
>> I thought about this, and I can think of no place except for bind where  
>> a sequence binding is nested directly within a sequence binding.
>
> They do the same thing as far as the binding item proper, but what about  
> the XPath context position and size? For sequence bindings, we now say:
>
>    "a size of the size of the sequence, and a position of the position  
> of the generated item in the sequence"
>
> So should I expect `position()` to work (as in showing "1", "2", etc.)  
> here:
>
> <xf:repeat ref="1 to 10">
>  <xf:output value="position()"/>
> </xf:repeat>
>
> And in the second case, does the single-item binding (in addition to the  
> implicit group of the repeat) reset the position() and last()?
>
> <xf:repeat ref="1 to 10">
>  <xf:group ref=".">
>    <xf:output value="position()"/>
>  </group>
> </xf:repeat>
>
> In other words, are position() and last() inherited when there is no  
> sequence-binding?
>
> In our implementation, I think that single-item bindings reset to  
> position = 1 and size = 1.

I would say that only the size should be reset, not the position, in both  
cases, but I am happy to hear a counter-argument.

Steven

>
> -Erik

Received on Thursday, 22 December 2016 09:09:59 UTC