I have a Multipart Message which comprises of TWO XML Messages. I wanna compare the equality of values of the first part with that of the second part.
And then I wanna route them to the respective step. I tried XQ_getXpath(xpath,partNo,"") but it is not returning a string. Pls help me in this regard.
-------FIRST PART XML-------------
<Name>XXYYZZ</Name>
<Variable1>FO1</Variable1>
<Variable2>EFGHI</Variable1>
------SECOND PART XML---------
<?xml version="1.0" encoding="UTF-8"?> <
RSOut xmlns:dbservice="http://www.sonicsw.com/esb/service/dbservice"> <
VAR1>FO</VAR1> <
VAR2>ABCDE</VAR2> </
RSOut>
In CBR I wanna check the equality of value of tag 'Variable1' in the first part with that of 'VAR1' in the second part.
The XQ_getXPath doesn't indeed return a string, as it is of type enumeration. In the javascript CBR code below I've given an example how to extract the first string from the enumeration, thus asuming the result of the xpath is one value.
// Retrieve string from xpath result
function getStringValue(xpathRes) {
if( xpathRes != null && xpathRes.getCount() >= 1) {
theVal = xpathRes.enumerate().nextElement().textContent;
return (theVal);
}
return ("");
}
xpathResultPart1Var1 = XQ_getXPath("/mainNode/Variable1/text()", 0);
xpathResultPart2Var1 = XQ_getXPath("/RSOut/VAR1/text()", 1);
XQ_logInformation("Variable1 = " + xpathResultPart1Var1 + " VAR1 = " + xpathResultPart2Var1);
resP1V1 = getStringValue(xpathResultPart1Var1);
resP2V1 = getStringValue(xpathResultPart2Var1);
XQ_logInformation("resP1V1 = " + resP1V1 + " resP2V1 = " + resP2V1);
Thanks a ton for that help.
After doing the above I tried to make conditions in CBR file for checking like : resP1V1==resP2V1.
But it did not work. Can you please suggest how to use conditions to check for equality and inequality?
Sorry for my very little knowledge. I am new entrant into this technology but interested.
No problem; there's quite a lot possible with javascript & xslt 2.0 in Sonic, so we all continue learning.
To do an equality comparison on two string objects use:
resP1V1.equals(resP2V1)
To search if a string exists (anywhere) within a string object use:
string1Object.match("stringToLookFor")
Thanks a lot Serge. It workeD!!!!!