You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ode.apache.org by Waruna Ranasinghe <wa...@gmail.com> on 2012/01/04 10:15:20 UTC

Set value of a boolean variable

Hi all,

What do you think, the most efficient way to set a value of a boolean
variable.
There are two options,

   1. use literal value "true" or "false"
   2. use XPath function "true()" or "false()"

Thanks,
Waruna
-- 
-----------------------------------------------------
Regards,
Waruna Ranasinghe

www.wso2.com - "Lean . Enterprise . Middleware"

blog: http://warunapw.blogspot.com
twitter: http://twitter.com/warunapww
http://lk.linkedin.com/in/waruna
www.facebook.com/waruna.ranasinghe

Re: Set value of a boolean variable

Posted by Tammo van Lessen <tv...@gmail.com>.
Hi Waruna,

most efficient in the sense of "the right way" or "the fastest way"?

Tammo

On 04.01.2012 10:15, Waruna Ranasinghe wrote:
> Hi all,
> 
> What do you think, the most efficient way to set a value of a boolean
> variable.
> There are two options,
> 
>    1. use literal value "true" or "false"
>    2. use XPath function "true()" or "false()"
> 
> Thanks,
> Waruna

-- 
Tammo van Lessen - http://www.taval.de

Re: Set value of a boolean variable

Posted by Tammo van Lessen <tv...@gmail.com>.
After rechecking the code, I see these two options:

"the right way" is IMO to use XPath:

<copy>
  <from>true()</from>
  <to>$myvar</to>
</copy>

I think this leads to cleaner, more self descriptive BPEL code. The
downside of this is: The standard Saxon (I'm talking about the XPath 2.0
processor now) is not schema aware. When using a a plain xs:boolean
variable, ODE can determine the type of the variable based on its
definition and everything is fine. If the Boolean is, however, just a
field in a more complex message, it is impossible for ODE to determine
the type of this field and will return just a string ('true' or
'false'). This needs to be kept in mind for condition checks (not for
assignments).

"the fastest way" is probably to use literal strings as this would
bypass some XPath evaluations, which turn out to be rather expensive. A
possible pitfall with condition checks in this case: If we have assigned
a literal string ('true') to a xs:boolean variable and use it in an
XPath expression, it is automatically translated to XPath's true(), so
it should either be casted to string or compared to true()/false() as
well instead of 'true'/'false'.

HTH,
  Tammo

On 04.01.2012 10:15, Waruna Ranasinghe wrote:
> Hi all,
> 
> What do you think, the most efficient way to set a value of a boolean
> variable.
> There are two options,
> 
>    1. use literal value "true" or "false"
>    2. use XPath function "true()" or "false()"
> 
> Thanks,
> Waruna

-- 
Tammo van Lessen - http://www.taval.de