logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: if() function behavior: msg#00034

Subject: Re: if() function behavior
hello a.,

i think the current implementation conforms to the spec. the signature of the function is "string: if(boolean, string, string)", and its behaviour is defined as "Function if evaluates the first parameter as boolean, returning the second parameter when true, otherwise the third parameter.", see http://www.w3.org/TR/xforms/slice7.html#fn-if

so the string parameters are not evaluated by if(). the xpath engine automatically converts the parameters to strings, thus evaluating any expression *before* the boolean condition is evaluated.

maybe this behaviour should be changed, but i have no idea how to prevent JXPath from evaluating the parameters before calling the function.

regards,
uli.

sano-aPJ5+7zCQ8bR7s880joybQ@xxxxxxxxxxxxxxxx wrote:
I have a statement in my form like this:

<xforms:setvalue xforms:ref="instance('instance00')/brands/brand3" value="if(string-length('203') &gt; 4,substring('203',5,1),'')"/>

When executed, I get "java.lang.StringIndexOutOfBoundsException: String index out of range: -1".

It looks like the "substring('203',5,1)" part is evaluated even if the "string-length('203') &gt; 4" part returns "false". Is this normal behavior?

I am trying to split a value submitted from a SELECT control - like '204060708' - into values "2", "4", "6"... that I can insert into individual nodes of the instance tree.

A.



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Chiba-developer mailing list
Chiba-developer-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/chiba-developer




--
Ulrich Nicolas Lissé



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>