Can I get any idea on the below?

________________________________
 From: sudheshna iyer <[email protected]>
To: David Lee <[email protected]>; Andrew Welch <[email protected]> 
Cc: "[email protected]" <[email protected]> 
Sent: Thursday, June 6, 2013 1:08 PM
Subject: Re: [xquery-talk] contains or tokenize usage help required in Xquery
 


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]>
To: David Lee <[email protected]>; sudheshna iyer <[email protected]>; 
Andrew Welch <[email protected]> 
Cc: "[email protected]" <[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" ) ) thenreturn "Error"
 
----------------------------------------
David A. Lee
[email protected]
http://www.xmlsh.org
 
From:[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]
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]
http://www.xmlsh.org
 
From:[email protected] [mailto:[email protected]] On Behalf Of 
sudheshna iyer
Sent: Thursday, June 06, 2013 11:54 AM
To: Andrew Welch
Cc: [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]>
To: sudheshna iyer <[email protected]> 
Cc: "[email protected]" <[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]> 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]
> http://x-query.com/mailman/listinfo/talk



-- 
Andrew Welch
http://andrewjwelch.com
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk


_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to