Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XQuery 'if' statements not executing in OSB

mscongdonJun 6 2013 — edited Jun 6 2013
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
This post has been answered by abhay kumar on Jun 6 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2013
Added on Jun 6 2013
2 comments
1,984 views