Hi Anne,

Sorry for the late, it's hard to catch up these days. There are several
things making your test case to fail. First there was a bug in ODE on simple
types casting from an xs:string. I've just fixed it so that should not be a
problem.

Another problem is the way XPath 1.0 deals with types, it's supposed to make
some sort of best effort dynamic casting depending on what's on both sides
of the = but the result is rarely what you would expect. So as soon as your
variable containing 2 is be injected in the XPath engine it will become 2.0,
whatever the xsd type you defined is. However your statically defined 2 (in
$precision=2) won't because the XPath engine gets it as is and not through a
variable. So the following should work now:

$precision=2.0
$precision='2.0'
number($precision)=number('2')
number($precision)=number(2)

The explicit cast with number() will work now that I fixed the bug I just
mentioned. Generally speaking I would really recommend using explicit
casting, especially when playing around with the = operator.

I would recommend even more switching to XPath 2.0, it's not really better
than 1.0 because only the non-typed version of Saxon is open source but it
doesn't mess with your variable values. To switch just include the 2
following attributes in your process declaration:

   queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
   expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"

Cheers,
Matthieu


On 2/6/07, Anne Noseda <[EMAIL PROTECTED]> wrote:


Hello,

I would like to test the equality of a variable an a number into a <if>
activity but it does'nt work ...

I have a variable $precision :
<variable name="precision" type="xsd:string"/>

and I would like to test if this variable equals the number 2 :
<if name="coherencePrecisionChamp">
<condition>$precision=2</condition>
   <then>
    <assign name="assignError">
     <copy>
      <from>
       <literal>Erreur</literal>
      </from>
      <to>$errorMsg</to>
     </copy>
    </assign>
   </then>
   <else>
     <assign name="assignZut">
     <copy>
      <from>
        <literal>Zut</literal>
      </from>
      <to>$errorMsg</to>
     </copy>
    </assign>
   </else>
  </if>

I send a message with precision equals 2 but I have always "zut" as
result.

I have also tried the following conditions :
<condition>$precision='2'</condition>
<condition>number($precision)=2</condition>
<condition>number($precision)=number(2)</condition>
<condition>number($precision)=number('2')</condition>
but same result : "zut"

I have also tried to declare precision as a xsd:int but always the same.

The only way which works is :
<condition>contains($precision,'2')</condition>
but the condition is true for 12, 21, ... !!!

What is wrong in my syntax ?

Thanks,

Anne.
--
View this message in context:
http://www.nabble.com/BPEL---Boolean-equality-expression-tf3179916.html#a8823803
Sent from the Apache Ode User mailing list archive at Nabble.com.


Reply via email to