All of what you are asking for is possible, actually easy. I suggest the next step is to read through some xquery tutorials .... Now that you have the basic idea you are going to need to learn how a more complex app is implemented.
Sent from my iPad (excuse the terseness) David A Lee [email protected]<mailto:[email protected]> On Jun 6, 2013, at 1:08 PM, "sudheshna iyer" <[email protected]<mailto:[email protected]>> wrote: Thanks for the responses. But the below code returns multiple responses. I only need one. Given a string "AS01,GS03", I only need one response : Success/Error or Failure. Also is there any way we can parameterize the error codes. Currently AE*,GE*, SE* are considered as errors codes. But if business comes back with X* also as error code then I need to change the code to accomplish this. Instead can I just make the cofiguration change to accomodate the requiremnt instead of code change. for $s in tokenize("a,b,c",",") if( startsWith($s,"AE" ) ) then return "Failure" else if( startsWith($s,"GE") or startsWith("SE" ) )then return "Error" else return () ________________________________ From: David Lee <[email protected]<mailto:[email protected]>> To: David Lee <[email protected]<mailto:[email protected]>>; sudheshna iyer <[email protected]<mailto:[email protected]>>; Andrew Welch <[email protected]<mailto:[email protected]>> Cc: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Sent: Thursday, June 6, 2013 12:25 PM Subject: Re: [xquery-talk] contains or tokenize usage help required in Xquery if( startsWith($s,"GE") or startsWith("SE" ) ) return "Error" ---> if( startsWith($s,"GE") or startsWith("SE" ) ) then return "Error" ---------------------------------------- David A. Lee [email protected]<mailto:[email protected]> http://www.xmlsh.org<http://www.xmlsh.org/> From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of David Lee Sent: Thursday, June 06, 2013 12:22 PM To: sudheshna iyer; Andrew Welch Cc: [email protected]<mailto:[email protected]> Subject: Re: [xquery-talk] contains or tokenize usage help required in Xquery for $s in tokenize("a,b,c",",") if( startsWith($s,"AE" ) ) then return "Failure" else if( startsWith($s,"GE") or startsWith("SE" ) ) return "Error" else return () Note this *may* produce multiple results ... ---------------------------------------- David A. Lee [email protected]<mailto:[email protected]> http://www.xmlsh.org<http://www.xmlsh.org/> From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of sudheshna iyer Sent: Thursday, June 06, 2013 11:54 AM To: Andrew Welch Cc: [email protected]<mailto:[email protected]> Subject: Re: [xquery-talk] contains or tokenize usage help required in Xquery Thank you for the response. Do you have an example of iterating using tokenize function? Thank you again for your help. ________________________________ From: Andrew Welch <[email protected]<mailto:[email protected]>> To: sudheshna iyer <[email protected]<mailto:[email protected]>> Cc: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Sent: Thursday, June 6, 2013 11:47 AM Subject: Re: [xquery-talk] contains or tokenize usage help required in Xquery On 6 June 2013 16:36, sudheshna iyer <[email protected]<mailto:[email protected]>> wrote: > Hello All, > > I will get a string of error codes from my vendor in a comma seperated > format. > I need an xquery function, which will return "Success" or "Failure" or > "Error" based on the following: > > If string contains AE* or -> Return "Failure" > else if GE* or SE* -> Return "Error" > else "Success" if (contains($str, 'AE')) then 'Failure' else if (contains($str, 'GE') or contains($str, 'SE') then 'Error' else 'Success' you get the idea.... if that's not sufficient then tokenize on comma and iterate the sequence checking each using starts-with(). > Below are the samples of strings that I can receive. > AS01,GS03 > -> Should return Success > AS01,GS01 > -> Should return Success > AS01,GE02 > -> Should return Error > AE01,GE02 > -> Should return Failure > > Thank you very much for your help. > > > _______________________________________________ > [email protected]<mailto:[email protected]> > http://x-query.com/mailman/listinfo/talk -- Andrew Welch http://andrewjwelch.com<http://andrewjwelch.com/> _______________________________________________ [email protected]<mailto:[email protected]> http://x-query.com/mailman/listinfo/talk
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
