[xquery-talk] XQuery quirk of the day

G. Ken Holman gkholman at CraneSoftwrights.com
Fri Apr 13 12:41:43 PDT 2012

At 2012-04-13 19:37 +0000, David Lee wrote:
> > >
> > >      empty($s) or $s eq ''
> >
> > But empty($s) doesn't return true for an empty string, it returns
> > true for an empty sequence.  If $s is defined as an empty string
> > you'll get false():
> >
>Correct thats why I used
>    empty($s) or $s eq ''

Ah, forgive me David, I thought I was reading the English language 
"or" separating two expressions as your choices and not the Boolean 
"or" of a single expression.  My mistake, as it is obvious now that 
you point it out.

>Or in context
>    if(empty($s) or $s eq '') then 'its a blank string'  else 'its not'
>But thanks for the tip on fn:not() !!! I gotta try that.

Yes, you'll find that it will return true for both cases of empty set 
and empty string because the argument to not() is first converted to 
its effective Boolean value.

Good luck!

. . . . . . . . . Ken

Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/q/
G. Ken Holman                   mailto:gkholman at CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

More information about the talk mailing list