Re: Get the values of an element and combine them
John Boyer <[email protected]> Mon, 24 Feb 2014 10:10:10 -0800
| Newsgroups | gmane.comp.web.xforms |
|---|---|
| Message-ID | <OF56E0D1B7.E043EB82-ON88257C89.0062FFCA-88257C89.0063D028@ca.ibm.com> |
This is a multipart message in MIME format. --=_alternative 0063CFDE88257C89_= Content-Type: text/plain; charset="US-ASCII" A couple of minor points: 1) It's typically better to use xforms-model-construct-done so that the data values are available to the UI when it is first created, rather than having any kind of value change. 2) The reason I don't usually push this approach is that, you're right, it doesn't account for many use cases in the lifecycle of the data. For example: - If a new result is obtained from a REST or web service by an xforms submission, then the xforms submit done must also do the same copy operations - Similar issue if someone does a setvalue on the spatial datum, they must do parallel setvalue operations on the instance data - Schema validity results for the spatial datum do not transfer to the controls bound to temporary instance data into which copies have been made. - Model item properties like readonly, required, constraint placed on the spatial datum do not transfer, and so must be recoded as more binds - If this construct is within a repeat, then all of these special cases have increased complexity in light of row insertions Cheers, John M. Boyer, Ph.D. IBM Distinguished Engineer & IBM Master Inventor @johnboyerphd | [email protected] From: "Steven Pemberton" <[email protected]> To: [email protected], [email protected], "Jean-Baptiste Pressac" <[email protected]>, Date: 02/24/2014 08:55 AM Subject: Re: Get the values of an element and combine them Here is an example of how I would do it: http://www.cwi.nl/~steven/forms/dcterms.xml I'm not sure of all the requirements of your problem, but what I do is: 1. At initialisation, extract the values of east and north from your input spatial value: <action ev:event="xforms-ready"> <setvalue ref="east" value="substring-before(substring-after(instance('in')/spatial, 'east='), ';')"/> <setvalue ref="north" value="substring-before(substring-after(instance('in')/spatial, 'north='), ';')"/> </action> 2. Bind a calculation to the output spatial value: <bind ref="spatial" calculate="concat('east=', ../east, '; north=', ../north, ';')"/> I hope this helps. Steven Pemberton On Thu, 20 Feb 2014 16:13:50 +0100, Jean-Baptiste Pressac <[email protected]> wrote: > Hello, > I would like to use Xform to edit the following element : > <dcterms:spatial xsi:type="dcterms:Point">east=456; > north=123;</dcterms:spatial> > > I could use : > <xf:input ref="dcterms:spatial[@xsi:type='dcterms:Point']" > class="dcterms:spatial"> > <xf:label>Latitude / Longitude:</xf:label> > </xf:input> > > But is there a way to display two inputs to let the user enter the east > value and the north value separately ? > > Thanks, --=_alternative 0063CFDE88257C89_= Content-Type: text/html; charset="US-ASCII" <font size=2 face="sans-serif">A couple of minor points:</font> <br> <br><font size=2 face="sans-serif">1) It's typically better to use xforms-model-construct-done so that the data values are available to the UI when it is first created, rather than having any kind of value change.</font> <br> <br><font size=2 face="sans-serif">2) The reason I don't usually push this approach is that, you're right, it doesn't account for many use cases in the lifecycle of the data. For example:</font> <br><font size=2 face="sans-serif">- If a new result is obtained from a REST or web service by an xforms submission, then the xforms submit done must also do the same copy operations</font> <br><font size=2 face="sans-serif">- Similar issue if someone does a setvalue on the spatial datum, they must do parallel setvalue operations on the instance data</font> <br><font size=2 face="sans-serif">- Schema validity results for the spatial datum do not transfer to the controls bound to temporary instance data into which copies have been made.</font> <br><font size=2 face="sans-serif">- Model item properties like readonly, required, constraint placed on the spatial datum do not transfer, and so must be recoded as more binds</font> <br><font size=2 face="sans-serif">- If this construct is within a repeat, then all of these special cases have increased complexity in light of row insertions</font> <br> <br><font size=2 face="sans-serif">Cheers,</font> <br><font size=2 face="sans-serif">John M. Boyer, Ph.D.<br> IBM Distinguished Engineer & IBM Master Inventor<br> @johnboyerphd | [email protected]<br> </font> <br> <br> <br> <br><font size=1 color=#5f5f5f face="sans-serif">From: </font><font size=1 face="sans-serif">"Steven Pemberton" <[email protected]></font> <br><font size=1 color=#5f5f5f face="sans-serif">To: </font><font size=1 face="sans-serif">[email protected], [email protected], "Jean-Baptiste Pressac" <[email protected]>, </font> <br><font size=1 color=#5f5f5f face="sans-serif">Date: </font><font size=1 face="sans-serif">02/24/2014 08:55 AM</font> <br><font size=1 color=#5f5f5f face="sans-serif">Subject: </font><font size=1 face="sans-serif">Re: Get the values of an element and combine them</font> <br> <hr noshade> <br> <br> <br><tt><font size=2>Here is an example of how I would do it:<br> <br> </font></tt><a href=http://www.cwi.nl/~steven/forms/dcterms.xml><tt><font size=2>http://www.cwi.nl/~steven/forms/dcterms.xml</font></tt></a><tt><font size=2><br> <br> I'm not sure of all the requirements of your problem, but what I do is:<br> <br> 1. At initialisation, extract the values of east and north from your <br> input spatial value:<br> <br> <action ev:event="xforms-ready"><br> <setvalue ref="east" <br> value="substring-before(substring-after(instance('in')/spatial, 'east='), <br> ';')"/><br> <setvalue ref="north" <br> value="substring-before(substring-after(instance('in')/spatial, 'north='), <br> ';')"/><br> </action><br> <br> 2. Bind a calculation to the output spatial value:<br> <br> <bind ref="spatial" calculate="concat('east=', ../east, '; north=', <br> ../north, ';')"/><br> <br> I hope this helps.<br> <br> Steven Pemberton<br> <br> On Thu, 20 Feb 2014 16:13:50 +0100, Jean-Baptiste Pressac <br> <[email protected]> wrote:<br> <br> > Hello,<br> > I would like to use Xform to edit the following element :<br> > <dcterms:spatial xsi:type="dcterms:Point">east=456;<br> > north=123;</dcterms:spatial><br> ><br> > I could use :<br> > <xf:input ref="dcterms:spatial[@xsi:type='dcterms:Point']"<br> > class="dcterms:spatial"><br> > <xf:label>Latitude / Longitude:</xf:label><br> > </xf:input><br> ><br> > But is there a way to display two inputs to let the user enter the east<br> > value and the north value separately ?<br> ><br> > Thanks,<br> <br> </font></tt> <br> --=_alternative 0063CFDE88257C89_=--