WSO2 BPS - Sample Guide - IF

Sample Guide - IF

Table of Content


Objective

Shows how to use <if/> construct to implement where user need to verify a logical condition.


Prerequisites


Overall Idea

<if><condition>number($tmpVar)=number(2)</condition>
    <assign name="assignError">
        <copy>
            <from>
                <literal>Worked</literal>
            </from>
            <to variable="myVar" part="TestPart"/>
        </copy>
    </assign>
    <else>
        <assign name="assignZut">
            <copy>
                <from>
                    <literal>Failed</literal>
                </from>
                <to variable="myVar" part="TestPart"/>
            </copy>
        </assign>
    </else>
</if>

<condition/> inside <if/> is used to implement the logical condition. Normally a XPath expression is used. <else/> is used to implement false case.

In the above example, value of tmpVar variable, is converted to a number and it's checked against 2. <condition>number($tmpVar)=number(2)</condition>

Based on the tmpVar value, "TestPart" element value in myVar variable will be "Worked" or "Failed".


Note - Apache ODE runtime has default support for http://www.w3.org/TR/xpath/, where the number($var) is defined.