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

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]<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]
http://x-query.com/mailman/listinfo/talk

Reply via email to