From 397d810c59d1e7cfefb29944fa6e0eab15cc19ab Mon Sep 17 00:00:00 2001 From: Michael Kay Date: Sat, 4 May 2024 23:13:27 +0100 Subject: [PATCH] When coercing to a union type, atomize first before considering alternatives. --- specifications/xquery-40/src/expressions.xml | 28 +++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index 025ce0d7a..2d9b26704 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -7024,7 +7024,29 @@ name.

sequence, given a required R.

-

If R is a or +

If R is a + (for example, if it is an , + a , or + an ), and J + is not an atomic value, then: + +

J is atomized to produce a sequence of atomic values + JJ.

+

Each atomic value in JJ is coerced to the required + type R by recursive application of the item coercion rules (the + rules in this section) to produce a value V.

+

The result is the sequence-concatenation of the V values.

+
+

+

For example, if J is an element with type annotation + xs:integer, and R is the union type xs:numeric, + then the effect is to atomize the element to an xs:integer, and then + to coerce the resulting xs:integer to xs:numeric + (which leaves the integer unchanged). This is not the same as attempting to + coerce the element to each of the alternatives of the union type in turn, which + would deliver an instance of xs:double.

+ +

Otherwise, if R is a or a (which includes the case where it is an ), then:

@@ -7086,7 +7108,7 @@ name.

choice item types.

- +

If R is an