W3C home > Mailing lists > Public > www-forms-editor@w3.org > August 2002

[long] nested repeats and index()

From: Jérôme Nègre <jerome.negre@e-xmlmedia.fr>
Date: Tue, 27 Aug 2002 14:37:29 +0200
Message-ID: <3D6B7289.6010400@e-xmlmedia.fr>
To: "www-forms-editor@w3.org" <www-forms-editor@w3.org>

Hi,

I think that the behaviour of index() and nested repeats isn't well 
defined in the latest draft.

Take the following <instance>:

<bookmarks>
	<section>
		<bookmark name="Main page"/>
		<bookmark name="ecma"/>
	</section>
	<section>
		<bookmark name="images"/>
	</section>
</bookmarks>

And the following UI:

<repeat nodeset="section" id="repeatSections">
	<repeat nodeset="bookmark" id="repeatBookmarks">
		<output ref="@name"/>
	</repeat>
</repeat>
<...>
<trigger id="insertbutton">
	<label>Insert bookmark</label>
	<insert nodeset="section[index('repeatSections')]/bookmark" 
at="index('repeatBookmarks')" position="after" event="xforms-activate"/>
</trigger>
<trigger id="insertsectionbutton">
	<label>Insert section</label>
	<insert nodeset="section" at="index('repeatSections')" position="after" 
event="xforms-activate"/>
</trigger>

Those are taken (and adapted) from the example in chapter G.2.


Step 1/
------
At startup, all index values are 1: index('repeatSections') returns 1, 
index('repeatBookmarks') returns 1.

Step 2/
------
The user triggers 'Insert bookmark', the instance now look like this:
<bookmarks>
	<section>
		<bookmark name="Main page"/>
		<bookmark name="images"/>
		<bookmark name="ecma"/>
	</section>
	<section>
		<bookmark name="images"/>
	</section>
</bookmarks>

index('repeatSections') still returns 1, index('repeatBookmarks') now 
returns 2 (chapter 9.3.5, point 3).

Step 3/
------
The user triggers 'Insert section', the instance now look like this:
<bookmarks>
	<section>
		<bookmark name="Main page"/>
		<bookmark name="images"/>
		<bookmark name="ecma"/>
	</section>
	<section>
		<bookmark name="images"/>
	</section>
	<section>
		<bookmark name="images"/>
	</section>
</bookmarks>

index('repeatSections') now returns 2, index('repeatBookmarks') still 
returns 2.

However, the Xpath expression 
section[index('repeatSections')]/bookmark[index('repeatBookmarks')] does 
not point to an existing element, so trying to use a <setvalue> on the 
new node would fail.

Is this interpretation the correct one? If so, a note should be added to 
the draft that says that using index() on nested repeats may lead to 
strange (and unexpected) results.

If this interpration is wrong, because index('repeatBookmarks') should 
return 1 in step 3 because the value of index('repeatSections') changed, 
it should also be specified.

Regards,
Jérôme
Received on Tuesday, 27 August 2002 08:39:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 10 June 2009 18:12:11 GMT