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. &nbsp;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 &amp; IBM Master Inventor<br>
@johnboyerphd | [email protected]<br>
</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">&quot;Steven Pemberton&quot;
&lt;[email protected]&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">[email protected],
[email protected], &quot;Jean-Baptiste Pressac&quot; &lt;[email protected]&gt;,
</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">02/24/2014 08:55 AM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</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>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</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>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
1. At initialisation, extract the values of east and north from your &nbsp;<br>
input spatial value:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &lt;action ev:event=&quot;xforms-ready&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;setvalue
ref=&quot;east&quot; &nbsp;<br>
value=&quot;substring-before(substring-after(instance('in')/spatial, 'east='),
&nbsp;<br>
';')&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;setvalue
ref=&quot;north&quot; &nbsp;<br>
value=&quot;substring-before(substring-after(instance('in')/spatial, 'north='),
&nbsp;<br>
';')&quot;/&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &lt;/action&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
2. Bind a calculation to the output spatial value:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &lt;bind ref=&quot;spatial&quot; calculate=&quot;concat('east=',
../east, '; north=', &nbsp;<br>
../north, ';')&quot;/&gt;<br>
<br>
I hope this helps.<br>
<br>
Steven Pemberton<br>
<br>
On Thu, 20 Feb 2014 16:13:50 +0100, Jean-Baptiste Pressac &nbsp;<br>
&lt;[email protected]&gt; wrote:<br>
<br>
&gt; Hello,<br>
&gt; I would like to use Xform to edit the following element :<br>
&gt; &lt;dcterms:spatial xsi:type=&quot;dcterms:Point&quot;&gt;east=456;<br>
&gt; north=123;&lt;/dcterms:spatial&gt;<br>
&gt;<br>
&gt; I could use :<br>
&gt; &lt;xf:input ref=&quot;dcterms:spatial[@xsi:type='dcterms:Point']&quot;<br>
&gt; class=&quot;dcterms:spatial&quot;&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;&lt;xf:label&gt;Latitude / Longitude:&lt;/xf:label&gt;<br>
&gt; &lt;/xf:input&gt;<br>
&gt;<br>
&gt; But is there a way to display two inputs to let the user enter the
east<br>
&gt; value and the north value separately ?<br>
&gt;<br>
&gt; Thanks,<br>
<br>
</font></tt>
<br>
--=_alternative 0063CFDE88257C89_=--