Implicit conversion of bpel:getVariableProperty(...)

Does the conversion of simple type values into XPath objects, as described for variables, apply for variable properties retrieved through bpel:getVariableProperty(...) in an XPath expression?

While I believe it is the intension to apply such a conversion, I cannot point out a requirement that enforces this -- did I miss it? However, the method signature returns “object”, suggesting that it may return an XPath object like Boolean for example. Also, an example in section 15.1.3 uses a boolean expression that expects an implicit conversion:

bpel:getVariableProperty('shipRequest', 'props:shipComplete')

Without conversion getVariableProperty will return a sequence of CIIs, that XPath converts into a string object. In XPath a string is true if and only if its length is non-zero. So even after the conversion required by section 8.3, a string "false" will result in the value true.

Note, that an expression like the following, from the first example in section 11.2, does not need implicit conversion, because the XPath language will make the conversion from string to number:

bpel:getVariableProperty('stockResult','inventory:level') > 100




A runtime is allowed to do implicit data conversion or casting based on the expected data type.
The first few paragraphs of Section 8.3 cover this in detail.

Yes, the specification says: "Implicit data conversion or casting MAY be applied..." but continues: "conversion ... MUST be applied when ... XPath 1.0 is used".

As I read it, the first part allows implicit data conversion in general, that is, when using any language. But then the second part specifies that for XPath 1.0, conversion MUST be done using the XPath function boolean(), on boolean expressions.

Applying the XPath function boolean() would turn the string "false" into the boolean value true.

Even if the first part could be read as a general allowance, it is used on the expression results, and it would not help on an expression like:

$myBoolVariable or bpel:getVariableProperty('shipRequest', 'props:shipComplete')

Here a conversion of the variable property within getVariableProperty, as done with variables, is needed. Otherwise, the "or" operator will use the boolean function to convert the variable property value into a boolean value, based on its string length.

Thank you - Your opinion is much appreciated.

The requirement applies to the final value of the expression, not other functions used within an expression. Given your example above:

 $myBoolVariable or bpel:getVariableProperty('shipRequest', 'props:shipComplete')

is executed as:

boolean( $myBoolVariable or bpel:getVariableProperty('shipRequest', 'props:shipComplete'))

However, it sounds like you prefer the following:

boolean( $myBoolVariable or boolean(bpel:getVariableProperty('shipRequest', 'props:shipComplete')))


I think the best practice is to implement any casting or conversion where necessary within the expression. Even better, use explicit types to model your data. BPEL supports multiple expression and query languages so it's important to have rules which are easily implemented across languages.

It sounds like we are approaching a common understanding: We agree that there is no requirement to convert the result of getVariableProperty into XPaht objects, as it is the case with variables.

However, I do not prefer any of the two deductions you list -- they are quite the same. The example:

$myBoolVariable or bpel:getVariableProperty('shipRequest', 'props:shipComplete')

is actually evaluated as:
boolean( boolean($myBoolVariable) or boolean (bpel:getVariableProperty('shipRequest', 'props:shipComplete')) )

The outer boolean function, is applied by requirement of section 8.3. The inner boolean functions are applied implicit by the XPath "or" operator, according to XPath 1.0 specification, section 3.4.

The problem is, that getVariableProperty selects, perhaps deep inside some complex type variable, a boolean value represented as a Text node containing the string "false". As XPath 1.0 does not supports XML Schema types, this Text node is converted to an XPath string object. The boolean function converts this string into the boolean value true, because the string length is non-zero.

This is following the standards, but hardly what one would expect from the original expression.

When you write you think it is practice to implement a conversion where necessary, do we then agree that it is necessary to apply same conversion to getVariableProperty, as done with variables?

I certainly agree that conversion should be the practice. I will, for my master thesis, conduct an experiment to expose the practice among some implementations. But, do we agree that the specification does not directly allow such conversion?

Thanks. Focus Areas: BPEL | DITA | ebXML | IDtrust | OpenDocument | SAML | UBL | UDDI
OASIS sites: OASIS | Cover Pages | | AMQP | CGM Open | eGov | Emergency | IDtrust | LegalXML | Open CSA | OSLC | WS-I