XQuery 'if' statements not executing in OSB
Hello,
I am trying to build an XML message within an XQuery that's executed in a proxy message flow in Oracle Service Bus 11.1.1.5.
When I try to execute something like this:
------------------------
xquery version "1.0" encoding "UTF-8";
declare function XMLtoBAMJSONXML($dataStr)
as element(JSON) {
<JSON>
<address>
<streetOne>{data($dataStr/Address/LineOne)}</streetOne>
if(exists($dataStr/Address/LineTwo))
*then <streetTwo>{data($dataStr/Address/LineTwo)}</streetTwo>*
<city>{data($dataStr/Address/City)}</city>
<state>{data($dataStr/Address/State)}</state>
<zipCode>{data($dataStr/Address/Zipcode)}</zipCode>
<country>{data($dataStr/Address/Country)}</country>
</address>
</JSON>
};
declare variable $dataStr external;
XMLtoBAMJSONXML($dataStr)
----------------------
I get this outcome:
----------------
<JSON>
<address>
<streetOne>100 Main St.</streetOne>
if(exists($dataStr/Address/LineTwo))
then
*<streetTwo>Apt. 202</streetTwo>*
<city>Lexington</city>
<state>MA</state>
<zipCode>02425</zipCode>
<country>USA</country>
</address>
</JSON>
-----------------
My 'for' loops work (not shown here). But my 'if' statements are not.
Any idea what's wrong with my 'if' syntax?
Thank you,
Michael
Edited by: mscongdon on Jun 6, 2013 6:09 AM