Search code examples
type-conversionwso2wso2-esbwso2-enterprise-integratorwso2-integration-studio

Converting Double to Integer in WSO2 Integration Studio


I am performing an Arithmetic operation in my XPath Expression. In the below code, qty1 and qty2 are double, hence the result I get is double. I want to convert the result to an Integer and save it in a property. How can I achieve it in WSO2 Integration Studio?

<property name="RESULT_QTY" expression="($body/*[local-name()='Shipment']/*[local-name()='qty1'])-($body/*[local-name()='Shipment']/*[local-name()='qty2'])"/>


Solution

  • You can do something like below.

    <property name="double" scope="default" type="DOUBLE" value="10.0"/>
    <property name="doubleString" scope="default" expression="$ctx:double" type="STRING"/>
    <property expression="fn:substring-before($ctx:doubleString, '.')" name="integer" scope="default" />