W3C home > Mailing lists > Public > www-forms@w3.org > April 2007

Re[2]: Nodeset bug and nested setvalue in a repeat. (1 of 2)

From: Ivan Latysh <IvanLatysh@yahoo.ca>
Date: Fri, 13 Apr 2007 14:53:39 -0400
Message-ID: <1727527971.20070413145339@yahoo.ca>
To: www-forms@w3.org

Hello All,

Continuing out conversation regarding <setvalue/> context issues.

[Aaron]
> Instead of a context function, why not use 1.1's context attribute?  Then the user specifies the context for the
> xpath expressions that are contained on the element.  It is used for xf:insert and xf:submission, I think.
>  
>  --Aaron
[Aaron]

[Peter]
>  I was also thinking about the setvalue issue and the 1.1 current() xpath function.  This does not do what is needed
> either as it allows access to the single node binding for the <xf:setvalue /> in your example.
>  
>  I would propose that a solution to the issue is to have a new function called context() which returns the bound
> context of an xforms node.  There are lots of issues, particularly with nested repeats, but with the re-write I did in MozzIE it would be quite easy to implement.
>  The function would return the nodeset of the node identified by the name:
>  
>      <xf:repeat nodeset="instance('myInstance')/fruit" model="myModel" id="fruits-repeat">
>       <xf:trigger>
>         <xf:label>Pick</xf:label>
>         <xf:action ev:event="DOMActivate">
>           <xf:setvalue ref="instance('myInstance')/bad-fruit" 
>               value="context('fruits-repeat')[index('fruits-repeat')]"/>
>         </xf:action>
>       </xf:trigger>
>     </xf:repeat>
>  
>  
>  At present if you have nested repeats you have to do this:
>  
>  <xf:repeat ref="instance('instSupermarkets')/products" id="supermarkets-repeat">
>   <xf:repeat ref="./fruit" id="fruits-repeat">
>       <xf:trigger>
>         <xf:label>Pick</xf:label>
>         <xf:action ev:event="DOMActivate">
>           <xf:setvalue ref="instance('myInstance')/bad-fruit" 
>              
> value="instance('instSupermarkets')/products[index('supermarkets-repeat')]/fruit[index('fruits-repeat')]"/>
>         </xf:action>
>       </xf:trigger>
>   </xf:repeat>
>  </xf:repeat>
>  
>  
>  But it would be written as:
>  
>  <xf:repeat bind="instance('instSupermarkets')/products" id="supermarkets-repeat">
>   <xf:repeat ref="./fruit" id="fruits-repeat">
>       <xf:trigger>
>         <xf:label>Pick</xf:label>
>         <xf:action ev:event="DOMActivate">
>           <xf:setvalue ref="instance('myInstance')/bad-fruit" 
>               value="context('fruits-repeat')[index('fruits-repeat')]"/>
>         </xf:action>
>       </xf:trigger>
>   </xf:repeat>
>  </xf:repeat>
>  It will also be considerably faster as the context does not need to be re-evaluated. 
>  I am thinking of adding this as an extension function in the MozzIE build as I doubt if it will make the spec anytime soon.
>  
>  I have the same issue with all of the forms I develop and it has been causing a lot of code bloat and bugs as you have to keep referring to complex xpaths everywhere.
>  If you have any other comments/suggestions let me know. 
>  
>  Regards
>  -- 
>  Peter Nunn
>  Director
[/Peter]

If I may suggest:

I do not believe that it is a good idea to introduce new functions or attributes in order to fix the issue.
XForms spec already has most of the rules in place, just happens that in some places it is not consistent, so let's fix
it.
In order to achieve consistency we should change <setvalue/>, and the other elements spec
to refer to 7.4 Evaluation Context:
[copy]
value
    Optional XPath expression to evaluate, with the result stored in the selected instance data node.
    The evaluation context for this XPath expression described in 7.4 Evaluation Context.
[/copy]

In the second eMail I will explain on examples how it will solve the issue.

-- 
Best regards,
 Ivan                            mailto:IvanLatysh@yahoo.ca
Received on Friday, 13 April 2007 18:59:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:09 GMT