Evaluating xpath expressions

This week we were messing around with a routing problem in one of the Oracle Service Bus projects.
We had an if-then-else construction which selects on the payload to see what transformation is needed and which business service it needs to call.

Example payload


result : node SYNTAX_ID with value ‘VALUE1’

test2 : count(/EDI/CONF_UNB/SYNTAX_ID) = 1
result : xs:boolean = true

result : xs:boolean = true

test4 : count(/EDI/CONF_UNB/SYNTAX_ID = ‘VALUE1’)
result : xs:integer = 1
This is the approach we used, but looking at the result of test5, you will see it will always evaluate to true or 1 in this case.

test5 : count(/EDI/CONF_UNB/SYNTAX_ID = ‘VALUE2’)
result : xs:integer = 1

test6 : count(/EDI/CONF_UNB/SYNTAX_ID[text() = ‘VALUE2’])
result : xs:integer = 0

test7 : count(/EDI/CONF_UNB/SYNTAX_ID[text() = ‘VALUE1’])
result : xs:integer = 1

So for evaluation the xpath expression without being it embedded in an xquery function you can just select the node and compair it with a textvalue (/EDI/CONF_UNB/SYNTAX_ID = ‘VALUE1’).
When you want to compair the xpath expression with a textvalue from within a call to a xquery function you need to select the text-value of the node to which you compair (count(/EDI/CONF_UNB/SYNTAX_ID[text() = ‘VALUE2’])).

Routing works again!


About Eric Elzinga
Eric Elzinga I'm an integration consultant located in The Netherlands. Mainly doing projects based on Oracle integration stacks (Oracle SOA Suite/Oracle Service Bus (OSB)), Java development, and opensource integration products.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: