How to Assign Boolean Values
The following example provides an example of assigning boolean values in BPEL 1.1. The XPath expression in the from
clause is a call to XPath's boolean function true
, and the specified approved field is set to true
. The function false
is also available.
<assign> <!-- copy from boolean expression function to the variable --> <copy> <from expression="true()"/> <to variable="output" part="payload" query="/result/approved"/> </copy> </assign>
The following example provides an example of assigning boolean values in BPEL 2.0.
<assign> <copy> <from>true()</from> <to>$output.payload/approved</to> </copy> </assign>
The XPath specification recommends that you use the "true()"
and "false()"
functions as a method for returning boolean constant values.
If you instead use "boolean(true)"
or "boolean(false)"
, the true
or false
inside the boolean function is interpreted as a relative element step, and not as any true
or false
constant. It attempts to select a child node named true
under the current XPath context node. In most cases, the true
node does not exist. Therefore, an empty result node set is returned and the boolean()
function in XPath 1.0 converts an empty node set into a false result. This result can be potentially confusing.