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.
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>
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>
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>
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>
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>
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.