W3C home > Mailing lists > Public > www-forms@w3.org > May 2006

Actions changing the XPath context

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Thu, 25 May 2006 22:37:40 +0200
Message-ID: <44761594.9010607@orbeon.com>
To: 'www-forms' <www-forms@w3.org>

All,

Consider the following simple example:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
             xmlns:xforms="http://www.w3.org/2002/xforms"
             xmlns:ev="http://www.w3.org/2001/xml-events">
     <xhtml:head>
         <xforms:model>
             <xforms:instance>
                 <instance>
                     <sort-by>name</sort-by>
                     <sort-order>ascending</sort-order>
                 </instance>
             </xforms:instance>
         </xforms:model>
     </xhtml:head>
     <xhtml:body>
         <xforms:group ref=".[sort-by != 'capital']">
             <xforms:trigger>
                 <xforms:label>Change</xforms:label>
                 <xforms:action ev:event="DOMActivate">
                     <xforms:setvalue 
ref="sort-by">capital</xforms:setvalue>
                     <xforms:setvalue 
ref="sort-order">ascending</xforms:setvalue>
                 </xforms:action>
             </xforms:trigger>
         </xforms:group>
     </xhtml:body>
</xhtml:html>

When loading up this example, the button should appear. When you
activate it, the two xforms:setvalue actions will be run in order.

However, right after the first action has been executed, if you were
to evaluate the xforms:group single-node binding, it would now return
an empty node-set. This means that the context for the evaluation of
the second xfomrs:setvalue is now empty, and you will either get an
error or the action will do nothing. This may or may not achieve what
the form author initially intended (in this case, it didn't).

Note that the single-node binding expression ".[sort-by != 'capital']"
may be be considered unususal, but it is a very convenient way of of
hiding and showing controls and groups.

My questions are:

1. Is this meant to work? I not, I believe it should ;-)

2. Does XForms 1.0, explicitly or implicitly specify when the
    xforms:group's single-node binding is evaluated, i.e. is it allowed
    to re-evaluate it after the first xforms:setvalue?

3. What would happen if instead of using xforms:setvalue, I was to use
    xforms:delete in the action to delete the node to which an
    enclosing xforms:group is bound?

    <xforms:delete nodeset="sort-by" at="1"/>

-Erik

-- 
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/
Received on Thursday, 25 May 2006 20:38:05 GMT

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