W3C home > Mailing lists > Public > www-forms@w3.org > February 2014

Re: Get the values of an element and combine them

From: Steven Pemberton <Steven.Pemberton@cwi.nl>
Date: Tue, 25 Feb 2014 11:11:36 +0100
To: "Steven Pemberton" <Steven.Pemberton@cwi.nl>, "John Boyer" <boyerj@ca.ibm.com>
Cc: "Jean-Baptiste Pressac" <Jean-Baptiste.Pressac@univ-brest.fr>, public-xformsusers@w3.org, www-forms@w3.org
Message-ID: <op.xbt09mshsmjzpq@steven-ux21a>
On Mon, 24 Feb 2014 19:10:10 +0100, John Boyer <boyerj@ca.ibm.com> wrote:

> 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.
In fact this example revealed to me a place where I would like *really* to  
have an event: after instance construction, but before recalc etc are done.

> 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
I think you're being too negative. The root of the problem is unstructured  
data. Whoever designed the format

    <dcterms:spatial xsi:type="dcterms:Point">east=456;  
north=123;</dcterms:spatial>

should be forced to attend the beginners class on how to structure data in  
XML. It should be at least

    <dcterms:spatial  
xsi:type="dcterms:Point"><east>456</east><north>123</north></dcterms:spatial>
or
    <dcterms:spatial xsi:type="dcterms:Point" east="456" north="123"/>

but hiding the data in a string is ghastly.

But my approach is to construct a proper XML instance from the  
unstructured data right at the start, and then treat the data as it should  
be treated. You can keep the unstructured data alive with a bind, and that  
can be your return value.

Steven


>
>> Cheers,
> John M. Boyer, Ph.D.
> IBM Distinguished Engineer & IBM Master Inventor
> @johnboyerphd | boyerj@ca.ibm.com
>
>
>
>
> From:        "Steven Pemberton" <Steven.Pemberton@cwi.nl>To:         
> public-xformsusers@w3.org, www-forms@w3.org, "Jean-Baptiste Pressac"  
> <Jean-Baptiste.Pressac@univ-brest.fr>,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  
> <Jean-Baptiste.Pressac@univ-brest.fr> 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,
Received on Tuesday, 25 February 2014 10:12:11 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:26 UTC