<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:xforms="http://www.w3.org/2002/xforms" 
      xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>Question about dispatching value changed and node bindings</title>
    <xforms:model>
      <xforms:instance>
        <data xmlns="">
          <value>Value</value>
          <calculated>DummyValue</calculated>
          <events-on-node>0</events-on-node>
          <events-on-text>0</events-on-text>
        </data>
      </xforms:instance>
      <xforms:bind nodeset="calculated/text()" calculate="/data/value"/>
    </xforms:model>
  </head>
  <body>
    <h1>Question about dispatching xforms-value-changed and node bindings</h1>
    <p>This question is about what a single node binding is actually bound to.
       One control is bound to the element 'calculated' another control is bound to the text node
       under 'calculated'. The text node has a computed calculate expression attached which will
       make its value identical to 'value'. The questions are then: 
       <ol>
         <li>is it true that only the control that is bound to the text node will dispatch xforms-value-changed?</li>
         <li>if 1. is true is it then logical that even though the computed calculate expression (in this case) 
             will change the same node as if the nodeset expression had been 'calculated'?</li>
       </ol>
    </p>
    
    <div>
         <xforms:input ref="calculated" id="cal1">
           <xforms:label>Bound to the Element:</xforms:label>
           <!-- I'm setting a ev:target on the setvalue action because I'm unsure if an implementation
                will dispatch events on the single node binding of an action. If that was the case
                the action would invoke it-self and recurse until stopped -->
           <xforms:setvalue ref="../events-on-node" value=".+1" ev:event="xforms-value-changed" ev:target="cal1"/>
         </xforms:input>
         
         <xforms:input ref="calculated/text()" id="cal2">
           <xforms:label>Bound to the Text:</xforms:label>
           <xforms:setvalue ref="../events-on-text" value=".+1" ev:event="xforms-value-changed" ev:target="cal2"/>
         </xforms:input>
    </div>
    
    <div>Change value to change the 'calculated' node:
         <xforms:select1 ref="value">
           <xforms:label>Value:</xforms:label>
           <xforms:item>
             <xforms:label>Value</xforms:label>
             <xforms:value>Value</xforms:value>
           </xforms:item>
           <xforms:item>
             <xforms:label>Another Value</xforms:label>
             <xforms:value>AValue</xforms:value>
           </xforms:item>
         </xforms:select1>
    </div>
    <div><xforms:output ref="events-on-node"><xforms:label>Number of xforms-value-changed on the Element:</xforms:label></xforms:output></div>
    <div><xforms:output ref="events-on-text"><xforms:label>Number of xforms-value-changed on the Text:</xforms:label></xforms:output></div>
  </body>
</html>

