BPEL - Manipulating XML Data


Advertisements

XPath is mainly used to manipulate XMLs in the BPEL process. There are some valuable Xpath functions that can be used for manipulating XML. Let us see the functions below.

bpel:getVaribleData(varName, partName, xpathStr)

This can be used to extract a set of elements from a variable, using a XPath expression.

<bpel:copy>
   <bpel:from>
   <![CDATA[count(bpel:getVariableData(‘$Variable','$partName')/ns:return)]]>
   </bpel:from>
      <bpel:to variable = "itemNumber">
   </bpel:to>
</bpel:copy>

bpel:getLinkStatus()

This can be used to evaluate and return a Boolean whether a particular link is active or inactive.

:getVariableProperty(string, string)

This is helpful in extracting properties in Variables.

:doXSLTTransform()

This performs the XSLT transformations.

string ()

This can be used to extract text content out of elements rather using /text ().

string-length()

This function is used to calculate the length of the string. But the != operator seems not to work with the output from this function. So you can use > or < rather using ! = .

Boolean Values

You can assign boolean values with the XPath boolean function.

<assign>
   <!-- copy from boolean expression function to the variable -->
   <copy>
      <from expression = "true()"/>
      <to variable = "output" part = "payload" query="/result/approved"/>
   </copy>
</assign>

Assigning a Date or Time

You can assign the current value of a date or time field by using the Oracle BPEL XPath function getCurrentDate, getCurrentTime, or getCurrentDateTime, respectively.

<!-- execute the XPath extension function getCurrentDate() -->
<assign>
   <copy>
      <from expression = "xpath20:getCurrentDate()"/>
      <to variable = "output" part = "payload"
      query = "/invoice/invoiceDate"/>
   </copy>
</assign>

Concatenating Strings

Rather than copying the value of one string variable (or variable part or field) to another, you can first perform string manipulation, such as concatenating several strings.

<assign>
   <!-- copy from XPath expression to the variable -->
   <copy>
      <from expression = "concat('Hello ',
      bpws:getVariableData('input', 'payload', '/p:name'))"/>
      <to variable = "output" part = "payload" query = "/p:result/p:message"/>
   </copy>
</assign>

Assigning String Literals

You can assign string literals to a variable in BPEL.

<assign>
   <!-- copy from string expression to the variable -->
   <copy>
      <from expression = "'GE'"/>
      <to variable = "output" part = "payload" query = "/p:result/p:symbol"/>
   </copy>
</assign>

Assigning Numeric Values

You can assign numeric values in XPath expressions.

<assign>
   <!-- copy from integer expression to the variable -->
   <copy>
      <from expression = "100"/>
      <to variable = "output" part = "payload" query = "/p:result/p:quantity"/>
   </copy>
</assign>

Note − A few XSLT functions were used to transform an XML document.

Advertisements