A few issues with <setvalue/>

Hello All,

  I hope I am not breaking any rules by posting this message, if I do please correct me.

  I came across a few quite obvious flaws with XForms spec's after we begin work on the new project that use XForms
  technology for the presentation layer.

  Most of the problems that we experiences are contest related, some of the controls do not honor the context that cause
  quite a bit of problems. Let me start from an <setvalue/> element.

  According to specs (http://www.w3.org/TR/xforms/slice10.html#action-setvalue):
  [quote]
  value
   Optional XPath expression to evaluate, with the result stored in the selected instance data node.
   The evaluation context for this XPath expression is the result from the Single Node Binding.
  [/quote]
  Since <setvalue/> action has been design to "... explicitly sets the value of the specified instance data node."
  it has 2 key peaces; 1 - source; 2 - destination.
  As we know from the spec "destination" will be set by "Single Node Binding", but the sentence
  "The evaluation context for this XPath expression is the result from the Single Node Binding." makes synthetic
  restriction forcing source and destination to be in the same context ! Rendering this action useless in most cases.
  
  Here is a few real-world examples that won't work because <setvalue/> does not honor the context:
    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <root>
          <fruit>apple</fruit>
          <fruit>orange</fruit>
          <fruit>mandarine</fruit>
          <fruit>tomato</fruit>
          <bad-fruit>Unknown</bad-fruit>
        </root>
      </xf:instance>
    </xf:model>
    <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="."/>
        </xf:action>
      </xf:trigger>
    </xf:repeat>

   As the result <xf:setvalue ref="instance('myInstance')/bad-fruit" value="."/> won't work because XPath "." will be
   evaluated in the "instance('myInstance')/bad-fruit" context, when it should be evaluated in <xf:repeat/> context.

   ~~~~~~~~~~~~~~~~~~~~~
   I propose to change:
     Optional XPath expression to evaluate, with the result stored in the selected instance data node.
     The evaluation context for this XPath expression is the result from the Single Node Binding.

   Into something like:
     Optional XPath expression to evaluate, with the result stored in the selected by Single Node Binding data node.
     The evaluation context for this XPath expression is the current scope / context.

   and add the following example for the scope:
     <repeat nodeset="instance('myInstance')/node" model="myModel" id="my-repeat">
      <xf:trigger>
        <xf:label>Pick Me</xf:label>
        <xf:action ev:event="DOMActivate">
          <xf:setvalue ref="instance('myInstance')/picked-value" value="."/>
        </xf:action>
      </xf:trigger>
     </repeat>
  
-- 
Best regards,
 Ivan                          mailto:IvanLatysh@yahoo.ca

Received on Thursday, 12 April 2007 07:53:29 UTC