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
<EDI>
<CONF_UNB>
<SYNTAX_ID>VALUE1</SYNTAX_ID>
<SYNTAX_VERS>1</SYNTAX_VERS>
<SENDER_ID>VALUE2</SENDER_ID>
<SEND_QUAL>10</SEND_QUAL>
</CONF_UNB>
</EDI>
test1 : /EDI/CONF_UNB/SYNTAX_ID
result : node SYNTAX_ID with value ‘VALUE1′
test2 : count(/EDI/CONF_UNB/SYNTAX_ID) = 1
result : xs:boolean = true
test3 : /EDI/CONF_UNB/SYNTAX_ID = ‘VALUE1′
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!
Original blog
Popularity: 2% [?]


