RE: Another <bind> and <repeat> question. And indirect relationships between binds and controls..

Hi Ryan,

as far as my understanding goes, your assertion (10.00 on both counts)
is correct. I also agree that this is not always (!) useful. The point
is: with the bind, you can get out of repeat's context node easily,
which is sometimes desirable. However, it should be achieved by other
means.

Please note that your second example yields a different result: in the
first iteration, the context node will be the first line item, and its
price is 10.00. In the second iteration, the context node is the second
line item, with a price of 3.00.

Hence,

> The input in the second 
> example does not
> explicitly reference the bind, yet they both reference the 
> same node in the
> instance doc.

is not correct. In fact, you can get to your conclusion much easier: An
arbitrary number of bind elements may refer to the same node in the
instance, and so can an arbitrary number of form controls. Therefor,
there is an indirect many-to-many relationship between form controls and
bind elements. However, I don't see why this is important.

> This might be better stated as [single-node binding] form 
> controls have a
> one-to-one relationship with a node in the instance document. 
> Nodes in the
> instance document have a one-to-many relationship with bind 
> elements. Is
> this correct, or am I missing something?

This is my understanding of what we wanted to achieve :-) Additionally,
nodes in the instance document have a one-to-many relationship with form
controls (be it single-node binding or nodeset-binding ones).

Hope this helps. If you could shed some light on what this is useful
for?

Thanks!

Josef

> -----Original Message-----
> From: Tomayko, Ryan [mailto:Ryan_Tomayko@stercomm.com]
> Sent: Monday, October 22, 2001 7:15 AM
> To: 'www-forms@w3.org'
> Subject: Another <bind> and <repeat> question. And indirect
> relationships between binds and controls..
> 
> 
> Sorry for the size of this post.
> 
> Is it impossible to use a bind attribute on a form control to 
> reference data
> inside a repeating structure?
> 
> For instance (literally):
> 
> <xf:xform>
>   <xf:instance>
>     <po>
>       <lineitems>
>          <line qty="5" price="10.00"/>
>          <line qty="10" price="3.00"/>
>       </lineitems>
>     </po>
>   </xf:instance>
> 
>   <xf:bindings>
>      <xf:bind id='b1' ref='po/lineitems/line/@price' 
> isValid='number(.) >
> 0'/>
>   </xf:bindings>
> </xf:xform>
> 
> ...
> 
> <xf:repeat nodeset='po/lineitems/line'>
> 	<xf:input bind='b1'/>
> </xf:repeat>
> 
> 
> In this case, the input should have a value of 10.00 on both 
> iterations of
> the repeat because of the first node rule. It seems that the 
> repeat breaks
> the usability of bind in some cases. 
> 
> We should be able to get around this by specifying a ref 
> instead of a bind
> on the input:
> 
> <xf:repeat nodeset='po/lineitems/line'>
> 	<xf:input ref='@price'/>
> </xf:repeat>
> 
> This brings up another question: can form control elements 
> and bind elements
> have an indirect relationship? The input in the second 
> example does not
> explicitly reference the bind, yet they both reference the 
> same node in the
> instance doc. If the form controls and bind elements can have 
> an indirect
> relationship, then form controls and bind elements have a one to many
> relationship. 
> 
> This might be better stated as [single-node binding] form 
> controls have a
> one-to-one relationship with a node in the instance document. 
> Nodes in the
> instance document have a one-to-many relationship with bind 
> elements. Is
> this correct, or am I missing something?
> 
> - Ryan
> 
> Ryan Tomayko <rtomayko@stercomm.com>
> Sterling Commerce
> 
> 

Received on Monday, 22 October 2001 12:43:01 UTC