controls and instance nodes

I had a conversation with Erik @ Orbeon on the OPS users lists about
binding a control to a piece of a node, insead of the entire node.
 
For example , if you have a node in your instance like this (and you
cant change your instance because it is based on a government spec).
<xforms:model>
<xforms:instance id="main">
<form>
<phonenumber/> <!--10 digits including area code and number-->
</form>
</xforms:instance>
 
<!--and you want to bind two controls to it for editing, one that holds
the area code and the other the phone number-->
<!--This DOES NOT WORK, because the control must be bound to a node-->
<xforms:bind id="areacode" nodeset="/form/phonenumber"
calculate="substring(/form/phonenumber,1,3)"/>
<xforms:bind id="phonenumber" nodeset="/form/phonenumber"
calculate="substring(/form/phonenumber,4,7)"/>
</xforms:model>
 
<xforms:input bind="areacode">
<xforms:input bind="number">
 
We came up with a workaround which consists of creating a second
instance
<xforms:instance id="sub">
<form>
<area/>
</number>
</form>
</xforms:instance>
 
then binding the contols on the 'sub' instance:
<xforms:bind id="areacode" nodeset="instance('sub')/form/area" />
<xforms:bind id="phonenumber" nodeset="instance('sub')/form/number"/> 
 
Then on the  xforms-ready event , you would copy over (using
xforms:setvalue with an XPath expression using substring()) the the two
parts of the phone number to the "sub" instance as shown above:
When the form is ready to submit you would use xforms:setvalue again to
update the original instance with the sub-instance (with XPath
expressions using concat()).
 
********************MY QUESTION*******************
 
Did the XForms Group consider the possibility that a control might be
used in this fashion, or did the group decide that their should always
be a 1to1 relationship between instance nodes and control?  What can be
done to extend Xforms in the future to make this easier?

Richard Braman
mailto:rbraman@taxcodesoftware.org
561.748.4002 (voice) 

http://www.taxcodesoftware.org <http://www.taxcodesoftware.org/> 
Free Open Source Tax Software

 

 

Received on Monday, 20 February 2006 11:35:27 UTC