problem with constraints for numeric values

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with constraints for numeric values

Benjamin
Hi,

i think i have a noob problem, but i cant find the solution. My Goal is
to have a constraint that says  value "a" should be <=  "b".  If i set
value a = 2 and b > 9 the constraint seems to be broken. I try
differenct types, but nothing helps. What i have to do to make this work
right.? i add my testpage for the Sandbox. Hope someone can help me.

all the best Benjamin




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

test.xhtml (906 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: problem with constraints for numeric values

Erik Bruchez
Administrator
Benjamin,

A couple of issues with your code:

1. xforms:bind doesn't support @ref. Instead, use @nodeset.

(We do have a loose plan to optionally better validate XForms input to
detect that kind of situations. Also, we do think that XForms should
support xforms:bind/@ref.)

2. See the following note from XPath 2.0: [1]

"In XPath 1.0, the < and > operators, when applied to two strings,
attempted to convert both the strings to numbers and then made a
numeric comparison between the results. In XPath 2.0, these operators
perform a string comparison using the default collating sequence. (If
either value is numeric, however, the results are compatible with
XPath 1.0)"

Instead, use the lt, le, gt, and ge operators, which operate on numeric types.

Your example becomes:

<xforms:bind nodeset="a" type="xforms:integer" constraint="/root/a lt /root/b"/>
<xforms:bind nodeset="b" type="xforms:integer" constraint="/root/b gt /root/a"/>

You could also write:

<xforms:bind nodeset="a" type="xforms:integer" constraint=". lt ../b"/>
<xforms:bind nodeset="b" type="xforms:integer" constraint=". gt ../a"/>

-Erik

[1] http://www.w3.org/TR/xpath20/

On Thu, Feb 18, 2010 at 5:37 PM, Benjamin Jehle
<[hidden email]> wrote:

> Hi,
>
> i think i have a noob problem, but i cant find the solution. My Goal is to
> have a constraint that says  value "a" should be <=  "b".  If i set value a
> = 2 and b > 9 the constraint seems to be broken. I try differenct types, but
> nothing helps. What i have to do to make this work right.? i add my testpage
> for the Sandbox. Hope someone can help me.
>
> all the best Benjamin
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: problem with constraints for numeric values

Benjamin
Erik,

> 1. xforms:bind doesn't support @ref. Instead, use @nodeset.
>  
I try to use @ref with bind and seems to work. So xforms doesnt support
it, but orbeon? Or is this a bug? Anyway i will use  @nodeset now :-)

> 2. See the following note from XPath 2.0: [1]..
>  
Wow that explains the strange behave. Thx a lot for your help.

All the best Benjamin

Erik Bruchez schrieb:

> Benjamin,
>
> A couple of issues with your code:
>
> 1. xforms:bind doesn't support @ref. Instead, use @nodeset.
>
> (We do have a loose plan to optionally better validate XForms input to
> detect that kind of situations. Also, we do think that XForms should
> support xforms:bind/@ref.)
>
> 2. See the following note from XPath 2.0: [1]
>
> "In XPath 1.0, the < and > operators, when applied to two strings,
> attempted to convert both the strings to numbers and then made a
> numeric comparison between the results. In XPath 2.0, these operators
> perform a string comparison using the default collating sequence. (If
> either value is numeric, however, the results are compatible with
> XPath 1.0)"
>
> Instead, use the lt, le, gt, and ge operators, which operate on numeric types.
>
> Your example becomes:
>
> <xforms:bind nodeset="a" type="xforms:integer" constraint="/root/a lt /root/b"/>
> <xforms:bind nodeset="b" type="xforms:integer" constraint="/root/b gt /root/a"/>
>
> You could also write:
>
> <xforms:bind nodeset="a" type="xforms:integer" constraint=". lt ../b"/>
> <xforms:bind nodeset="b" type="xforms:integer" constraint=". gt ../a"/>
>
> -Erik
>
> [1] http://www.w3.org/TR/xpath20/
>
> On Thu, Feb 18, 2010 at 5:37 PM, Benjamin Jehle
> <[hidden email]> wrote:
>  
>> Hi,
>>
>> i think i have a noob problem, but i cant find the solution. My Goal is to
>> have a constraint that says  value "a" should be <=  "b".  If i set value a
>> = 2 and b > 9 the constraint seems to be broken. I try differenct types, but
>> nothing helps. What i have to do to make this work right.? i add my testpage
>> for the Sandbox. Hope someone can help me.
>>
>> all the best Benjamin
>>
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>>    


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: problem with constraints for numeric values

Erik Bruchez-3
Benjamin,

On Thu, Mar 11, 2010 at 5:37 PM, Benjamin Jehle
<[hidden email]> wrote:
> Erik,
>
>> 1. xforms:bind doesn't support @ref. Instead, use @nodeset.
>>
>
> I try to use @ref with bind and seems to work. So xforms doesnt support it,
> but orbeon? Or is this a bug? Anyway i will use  @nodeset now :-)

I think that's because we use generic code to evaluate bindings, so
@ref just works! But it's currently not per the spec.

-Erik

>
>> 2. See the following note from XPath 2.0: [1]..
>>
>
> Wow that explains the strange behave. Thx a lot for your help.
>
> All the best Benjamin
>
> Erik Bruchez schrieb:
>>
>> Benjamin,
>>
>> A couple of issues with your code:
>>
>> 1. xforms:bind doesn't support @ref. Instead, use @nodeset.
>>
>> (We do have a loose plan to optionally better validate XForms input to
>> detect that kind of situations. Also, we do think that XForms should
>> support xforms:bind/@ref.)
>>
>> 2. See the following note from XPath 2.0: [1]
>>
>> "In XPath 1.0, the < and > operators, when applied to two strings,
>> attempted to convert both the strings to numbers and then made a
>> numeric comparison between the results. In XPath 2.0, these operators
>> perform a string comparison using the default collating sequence. (If
>> either value is numeric, however, the results are compatible with
>> XPath 1.0)"
>>
>> Instead, use the lt, le, gt, and ge operators, which operate on numeric
>> types.
>>
>> Your example becomes:
>>
>> <xforms:bind nodeset="a" type="xforms:integer" constraint="/root/a lt
>> /root/b"/>
>> <xforms:bind nodeset="b" type="xforms:integer" constraint="/root/b gt
>> /root/a"/>
>>
>> You could also write:
>>
>> <xforms:bind nodeset="a" type="xforms:integer" constraint=". lt ../b"/>
>> <xforms:bind nodeset="b" type="xforms:integer" constraint=". gt ../a"/>
>>
>> -Erik
>>
>> [1] http://www.w3.org/TR/xpath20/
>>
>> On Thu, Feb 18, 2010 at 5:37 PM, Benjamin Jehle
>> <[hidden email]> wrote:
>>
>>>
>>> Hi,
>>>
>>> i think i have a noob problem, but i cant find the solution. My Goal is
>>> to
>>> have a constraint that says  value "a" should be <=  "b".  If i set value
>>> a
>>> = 2 and b > 9 the constraint seems to be broken. I try differenct types,
>>> but
>>> nothing helps. What i have to do to make this work right.? i add my
>>> testpage
>>> for the Sandbox. Hope someone can help me.
>>>
>>> all the best Benjamin
>>>
>>>
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing
>>> list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=help
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>>>
>>>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws