Thanks, John. I should know better than to post to the list on a Monday morning 
before the coffee has kicked in... I was in fact reading "fn:" and typing "xs:".

On Mon, 20 Jun 2011, John Snelson wrote:

> On 20/06/11 14:45, David Sewell wrote:
>> On Fri, 17 Jun 2011, G. Ken Holman wrote:
>>
>>> At 2011-06-17 17:58 +0000, Will Thompson wrote:
>>> xs:boolean does a cast of the argument.  The first bullet of the
>>> documentation cites what is returned when the argument is an empty set:
>>>
>>>    http://www.w3.org/TR/2007/REC-xpath-functions-20070123/#func-boolean
>>
>> So per specs, xs:boolean(()) should return "false" as a boolean.
>
> You're confusing the cast function xs:boolean() with the built in
> function fn:boolean(). The link above gives the behaviour for
> fn:boolean(). The cast function xs:boolean() is the same as writing:
>
> () cast as xs:boolean?
>
> Which results in the empty sequence.
>
>> However, that's not the behavior in MarkLogic. Version "0.9-ml" throws
>> an error, "Invalid cast". Versions 1.0 and 1.0-ml return empty sequence.
>> (For what it's worth, Saxon 9.3 returns empty sequence as well.)
>>
>> In most cases, having a return value of empty sequence versus boolean
>> false probably won't affect expected results, but there are differences.
>> For example, Marklogic evaluates
>>
>>      empty(false())         ==>   false
>>      empty(xs:boolean(()))  ==>   true
>>
>> whereas the XPath specs suggest both should return "false"?
>
> No. The fn:empty() function simply returns true if it's argument is the
> empty sequence(). Since fn:false() returns a single boolean value,
> fn:empty() returns false (it's not the empty sequence). However,
> xs:boolean(()) returns the empty sequence, so fn:empty() returns true.
>
> John
>
>

-- 
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400314, Charlottesville, VA 22904-4314 USA
Email: [email protected]   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to