[xquery-talk] Compared to what?
dlee at calldei.com
Wed Apr 2 09:02:23 PST 2014
Had to jump in here with a catcall ...
"Miss something in a W3C spec ? Why ... the horror !!! or as George Takei (tm) says
'ohh myy' "
Tssk tssk ...
The effort put into these specs is unequaled except for perhaps the effort to comprehend them in less time then they took to write :)
From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Ihe Onwuka
Sent: Wednesday, April 02, 2014 12:51 PM
To: Michael Kay
Cc: talk at x-query.com
Subject: Re: [xquery-talk] Compared to what?
indeed.... how did I miss that..I'll tell you.. once I saw that a comparison was involved I was expecting to be declaratively told what type of comparison. Thats what I looked for and didn't see it.
I didn't expect to see an algorithm and didn't recognise what it was.
On Wed, Apr 2, 2014 at 5:39 PM, Michael Kay <mike at saxonica.com> wrote:
> On 2 Apr 2014, at 17:13, Ihe Onwuka <ihe.onwuka at gmail.com> wrote:
>> Excerpt from the 3.13 of the XQuery 3.0 specification.
>> "In a switch expression, the switch keyword is followed by an
>> expression enclosed in parentheses, called the switch operand
>> expression. This is the expression whose value is being compared."
>> The issue is the last word - compared.
>> XPath has general and value based comparisons and the spec doesn't
>> say what type of comparison is operative for comparisons on the
>> switch operand expression.
> Not sure how you missed this, but it says this in great detail:
> The resulting value is matched against each SwitchCaseOperand in turn until a match is found or the list is exhausted. The matching is performed as follows:
> * The SwitchCaseOperand is evaluated.
> * The resulting value is atomized.
> * If the atomized sequence has length greater than one, a type error is raised [err:XPTY0004].
> * The atomized value of the switch operand expression is compared with the atomized value of the SwitchCaseOperand using the fn:deep-equal function, with the default collation from the static context.
> Using fn:deep-equal() on two atomic values is almost the same as using "eq", except that you get false rather than an error if the values are of incomparable types, and you get true if you compare NaN to NaN.
> Michael Kay
talk at x-query.com
More information about the talk