REPOST: Evaluation Context of <bind> Computed Expression

Since there was quite a bit of traffic on this list regarding the recent
terrorist attacks which took a considerable amount of attention from the
subject at hand, I wanted to repost this message as it seems to be a very
important problem with no proposed resolution. 

Thanks,
- Ryan

-----Original Message-----
From: Tomayko, Ryan 
Sent: Friday, September 14, 2001 9:15 AM
To: www-forms@w3.org
Subject: RE: Evaluation Context of <bind> Computed Expression


Thanks Mike,

> since relevant will be applied to every node in node-set 'ref' 
> *with that node as the context node.*

Okay, I completely missed this statement in the spec. I had the
understanding that the model-item properties were evaluated with the same
node context as the ref. If what you say is true, model item properties are
evaluated with the context node set to either the single node specified in
the ref or each node specified in the node-set.

I found the following in section 5.3.1:

> The bind element represents a node-set selected from the instance data. A 
> series of attributes on the element correspond to individual model item 
> properties, which are applied to each node in the node-set. 

Is there another piece of the spec I'm missing or can someone be more
specific with this paragraph? Does "applied to each node" mean that the
Computed Expressions are evaluated in the context of the selected ref or
node-set?

If this is the case, it would make applying binding expressions possible
within a repeat. However, there is a problem with the solution you provided.
In the following, the *lineItem* element repeats, not the qty. The XPath
expression used in the ref attribute would return a node-set containing a
single node: the qty element of the *first* lineItem. It would not return
each qty child element of each lineItem. In other words, the XPath
expression you specified is equivalent 
to: po/lineItems/lineItem[1]/qty

<xform:bind id="qty"
     ref="po/lineItems/lineItem/qty"
     relevant="../total > 1000"/>

Sample instance data (I should have included this in my original message): 
<po>
  <lineItems>
    <lineItem>
       <productId>123</productId>
       <qty>5</qty>
       <total>5.99</total>
    </lineItem>
    <lineItem>
       <productId>321</productId>
       <qty>10</qty>
       <total>10.99</total>
    </lineItem>
    <lineItem>
       <productId>ABC</productId>
       <qty>55</qty>
       <total>1.99</total>
    </lineItem>
  </lineItems>
</po>

So, it seems for the ref attribute, we're back at the beginning.. However,
if the ref attribute is specified on the ui control element instead of the
bind, this could be fully functional.

<xform:bind id="qty"
     relevant="../total > 1000"/>

...

<xform:repeat node-set="po/lineItems/lineItem">
	<xform:input ref="qty" bind="qty"/>
</xform:repeat>


Thanks,
- Ryan

-----Original Message-----
From: Mikko Honkala [mailto:honkkis@tml.hut.fi]
Sent: Friday, September 14, 2001 5:39 AM
To: Tomayko, Ryan; www-forms@w3.org
Subject: RE: Evaluation Context of <bind> Computed Expression


Hi Tomayko,

I am not sure, whether this answers your questions at all, but I think the
first
bind should be written as:

<xform:bind id="qty"
     ref="po/lineItems/lineItem/qty"
     relevant="../total > 1000"/>

, since relevant will be applied to every node in nodeset 'ref' with that
node as the context node.

Therefore, I do not see why form controls that refer to instance items with
computed expressions, could not be used within 'repeat'.

- Mikko Honkala - http://www.x-smiles.org/

Received on Tuesday, 18 September 2001 09:12:42 UTC