[xquery-talk] Compared to what?

Michael Kay mike at saxonica.com
Wed Apr 2 08:39:29 PST 2014


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
Saxonica




More information about the talk mailing list