Wednesday, January 26, 2011

Failed to execute countNodes() function : oracle.xml.parser.v2.XMLNodeList cannot be cast to java.lang.String.

An error occurs while processing the XPath expression; the expression is ora:countNodes($inputVariable.payload/ns1:BookLot).
The XPath expression failed to execute; the reason was: Failed to execute countNodes() function : oracle.xml.parser.v2.XMLNodeList cannot be cast to java.lang.String.


the BPEL was:

copy
from ora:countNodes($inputVariable.payload/ns1:BookLot) /from
to $countLots /to
/copy


this http://forums.oracle.com/forums/thread.jspa?threadID=632140 tells me that the instructions should have been rather of this type:


ora:countNodes('Receive_Data_receive_InputVariable','EmpCollection','/ns2:EmpCollection/ns2:Emp')


ora:countNodes documentation:

This function returns size of elements as an integer.The signature of this function is ora:countNodes(variableName, partName?, locationPath?). The arguments are: 1) variableName - the source variable for the data, 2) partName - the part to select from the variable (optional), 3)locationPath - provides an absolute location path (with / meaning the root of the document fragment representing the entire part) to identify the root of a subtree within the document fragment representing the part (optional).

If I use

ora:countNodes('inputVariable', 'payload', '/ns1:BookLot')

I get always 0 in the result.

So I use count($inputVariable.payload/ns1:BookLot)

and I still get 0.

AFTER I put a Mediator between the File Adapter and the BPEL process, the result of count() is correct. Apparently there was some namespace mismatch if I go directly from FileAdapter to BPEL.

2 comments:

Unknown said...

Is '/ns1:PreactivationLot' the xpath to a repeating element?

vernetto said...

yes it is indeed (please note: I have changed PreactivationLot to BookLot in my example).

Anyway "count" does the job, so I don't bother any more about ora:countNodes()