[xquery-talk] xquery function

G. Ken Holman gkholman at CraneSoftwrights.com
Sat Nov 20 06:42:31 PST 2010


Sorry, I missed that you wanted 1 or 0, so what Mike said is more correct:

   if( tokenize( $Y, "\s" ) = tokenize( $X, "\s" ) ) then 1 else 0

. . . . . . Ken

At 2010-11-20 06:37 -0500, G. Ken Holman wrote:
>I think all you need is:
>
>   tokenize( $Y, "\s" ) = tokenize( $X, "\s" )
>
>I hope this helps.
>
>. . . . . . . . Ken
>
>At 2010-11-20 11:24 +0000, Mohamed kharrat wrote:
>>dear all,
>>i want to create a function which return 1 or 0
>>i wrote this:
>>declare function local:Match($X as xs:string*,$Y as xs:string*)
>>{
>>
>>
>>  for $tok in tokenize($X, "\s")
>>(:for $tok2 in tokenize($Y, "\s"):)
>>
>>return if (some $l in tokenize($Y, "\s") satisfies $l= 
>>$tok(:contains ($l,$tok):)) then 1
>>else 0
>>};
>>local:Match('Cata avion nat voiture fff' , 'avion moto voiture')
>>this function return not only "1" or "0" but a sequence of  0 1 0 1 0
>>how to fix that?
>>i just want that this function verify if some word in "String1" 
>>contains in "String2" so in this case it  must return 1
>>thank you


--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



More information about the talk mailing list