[xquery-talk] Can I have multiple if's in a for loop (Not if-else
if, but if, if, if..)
Raja
m.rajamani at nic.in
Mon Apr 18 15:53:00 PDT 2011
Hi Sudheshna Iyer !!!!
Your options is possible with Xquery 1.0 and XQuery 3.0 (with typeswitch) option.. Enjoy..
By
Rajamani marimuthu
XRX Team
On 04/18/11, sudheshna iyer <sudheshnaiyer at yahoo.com> wrote:
>
> Can I have multiple if's in a for loop? I noticed that it works, if I use -->
> if (ONE) then ...else if (TWO) then ... else if (THREE) then .. else()
> But I want all the three if "ReturnParameterCode" is repeated with all the three
> values
>
>
>
> I have input xml with multiple ReturnParameterCode. I need to do XQuery
> transformation to form output xml based on occurance of elements in input xml
>
>
> Input xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <tns:InputMSG1 xmlns:tns="http://xmlns.aaa.org">
> <tns:CustNum>111</tns:CustNum>
> <tns:ReturnParameter>
> <tns:ReturnParameterCode>ONE</tns:ReturnParameterCode>
> <tns:ReturnParameterCode>TWO</tns:ReturnParameterCode>
> </tns:ReturnParameter>
> </tns:InputMSG1>
>
> If ReturnParameterCode is "ONE", then block <ONE> should appear in the output
> if ReturnParameterCode = TWO is present then block <TWO> should appear.
>
> My output should be:
> <?xml version="1.0" encoding="UTF-8"?>
> <tns:OutputMSG1 xmlns:tns="http://xmlns.aaa.com">
> <tns:ONE>
> <tns:Id>String</tns:Id>
> <tns:Number>String</tns:Number>
> </tns:ONE>
> <tns:TWO>
> <tns:Name>String</tns:Name>
> </tns:TWO>
> </tns:OutputMSG1>
>
> IF input xml doesn't have
> <tns:ReturnParameterCode>TWO</tns:ReturnParameterCode>, block <TWO> shouldn't
> appear in the output.
>
> <tns:InputMSG1 xmlns:tns="http://xmlns.aaa.org">
> <tns:CustNum>111</tns:CustNum>
> <tns:ReturnParameter>
> <tns:ReturnParameterCode>ONE</tns:ReturnParameterCode>
> </tns:ReturnParameter>
> </tns:InputMSG1>
> My output should be:
> <tns:OutputMSG1 xmlns:tns="http://xmlns.aaa.com">
> <tns:ONE>
> <tns:Id>String</tns:Id>
> <tns:Number>String</tns:Number>
> </tns:ONE>
> </tns:OutputMSG1>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>
--
Rajamani Marimuthu
Junior Research Fellow-JRF
NIC -Open Technology Centre
Rajaji Bhavan
Besant Nagar,
Chennai - 90
Cell : 9677192096
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20110418/9cd73ef5/attachment.htm
More information about the talk
mailing list