Re: controls and instance nodes

Hi Richard,

I know this is a bit of a hack but why don't you just split the text 
content into several text nodes, like:

<form>
<phonenumber>708<?splitter ?>-<?splitter ?>8000</phonenumber>
</form>

<xforms:bind id="areacode" nodeset="/form/phonenumber/text()[1]"/>
<xforms:bind id="dash-seperator" nodeset="/form/phonenumber/text()[2]"/>
<xforms:bind id="phonenumber" nodeset="/form/phonenumber/text()[3]"/>

As the text content for the phonenumber will be the concatenation of the 
text nodes it still means that if you have a schema datatype for 
phonenumber it will validate correctly. I'm not sure what happens to the 
validity state of the bound controls as they are now bound to text nodes 
of the element that gets validated.

Would this be a useful solution for your use case?

Best regards,
David

Richard Braman wrote:
> 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
>
>  
>
>  


-- 
--------------------------------------------
David Landwehr (david.landwehr@solidapp.com)
Chief Executive Officer, SolidApp
Web: http://www.solidapp.com
Office: +45 48268212
Mobile: +45 24275518
--------------------------------------------

Received on Monday, 20 February 2006 12:04:47 UTC