Re: Repeat item context

On Tue, 23 Jan 2018 18:07:18 +0100, Erik Bruchez <ebruchez@orbeon.com>  
wrote:

>> <instance>
>>    <data xmlns="">
>>       <item>one</item><item>two</item><item>three</item>
>>    </data>
>> </instance>
>>
>> <repeat ref="item">
>>    <output ref="."/>,
>>    <output value="last()"/>,
>>    <output value="position()"/>
>> </repeat>
>>
>> Question one:
>>
>> Should it output
>>
>> one, 1, 1
>> two, 1, 2
>> three, 1, 3
>>
>> or
>>
>> one, 3, 1
>> two, 3, 2
>> three, 3, 3
>
> The latter. `last()` and `position()` go together, and `position()` must  
> be smaller than or equal to `last>()`. A common use case is to test for  
> `position() = last()` to find the last item in a sequence.

Good, we agree (this for a Test Suite test).

>
>> Question two: What is the difference between the 'repeat position', and  
>> the position of the repeat item >>context?
>
> None as far as I an tell!

Also agree, so it looks like the text at  
https://www.w3.org/community/xformsusers/wiki/XForms_2.0#The_repeat_Element  
can be simplified:

"For each item in the repeat collection, a repeat item is defined,  
consisting of
  * the item,
  * its position in the repeat collection called the *repeat position*, and
  * a repeat object consisting of an implicitly generated group element  
that binds to the item, and containing a copy of the template. Unlike an  
explicit group, the binding to the item does not reset the size and  
position of its context.

These repeat objects together form the run-time content of the repeat."

"Repeat position" is used twice elsewhere:

In 10.4.1.3 Index Processing:

"If items are added to the repeat collection, then the repeat index is set  
to the repeat position of the last item added."
https://www.w3.org/community/xformsusers/wiki/XForms_2.0#Index_Processing

and in 10.4.1.4 Interaction and rendering:

"If the focus is given to a control within a repeat by any means, such as  
by an XForms action or by user interaction, the repeat index is set to the  
repeat position of the repeat item that contains the control, and the  
repeat index of all containing repeats are adjusted appropriately. A  
repeat index is changed as if by a setindex action."

https://www.w3.org/community/xformsusers/wiki/XForms_2.0#Interaction_and_rendering

I think in both these cases 'repeat position' can be replaced with  
'position' without loss of clarity.

Steven

>
> -Erik

Received on Wednesday, 24 January 2018 10:18:56 UTC