Re: Options as strings. Blech.

On 2 September 2011 12:20, Andrew Welch wrote:
> On 2 September 2011 11:10, Florent Georges wrote:

  Hi,

>>  If we look at the definition of EBV[1], actually any string
>> returns true except the empty string.  So even 'false' returns
>> true:

>>    (: returns true() :)
>>    if ( 'false' ) then true() else false()

>>    (: returns false() :)
>>    xs:boolean('false')

> Don't forget the gotcha that the only non-empty string to
> return false is '0'... xs:boolean('0') returns false.

  No.  We talk about two different things here: first the EBV,
defined using boolean() (that is, fn:boolean()), and second the
boolean item constructor, that is xs:boolean() (note fn:* versus
xs:*).

  For the EBV and fn:boolean(), only the empty string returns
false, all other strings return true (including 'false' and '0').
For xs:boolean(), 'true' and '1' return true, 'false' and '0'
return false, and any other string is a cast error.

  Unless I missed something, of course.

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

Received on Friday, 2 September 2011 10:28:47 UTC