W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2011

[Bug 11713] [XPath 3.0] Rules for union types

From: <bugzilla@jessica.w3.org>
Date: Thu, 17 Mar 2011 17:51:12 +0000
To: public-qt-comments@w3.org
Message-Id: <E1Q0HLs-0006VX-FX@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=11713

--- Comment #3 from Michael Kay <mike@saxonica.com> 2011-03-17 17:51:09 UTC ---
Further discussion on the Schema WG mailing list established that this approach
has problems. For example, if assertions are used to restrict a union type, the
assertion on the union does not necessarily achieve the same thing as
assertions on each of the member types. For example, given a union of
(xs:integer, xs:string), and the assertion ($value instance of xs:string), and
the instance value 1234, an assertion a the union level will cause the value to
be rejected as invalid, while moving the assertion down to the member types
will cause it to e rejected as an xs:integer but accepted as an xs:string. 

Another approach has been suggested: when a node has been validated against a
union type, the typed value should be an atomic value that is annotated with
both the atomic member type and the union type against which it was validated
(and any intermediate unions as well). The value is a known to be a valid
instance of each of these types, and it is therefore accepted by a function
that requires any of these types. For example, if DT-with-Z restricts DT by
requiring a timezone, and DT is union(date, time, dateTime), and an attribute A
is validated against an attribute declaration with required type DT-with-Z,
then the node will be annotated as being of type DT-with-Z, and its typed value
will be labelled both with an atomic type (e.g. xs:date) and with the union
types DT and DT-with-Z. (The label DT is redundant, but does no harm.) And
therefore the atomic value can be used where the required type is xs:date,
where the required type is DT, and where the required type is DT-with-Z.

This still isn't perfect. Will current-date() be acceptable where the expected
type is DT? (I think it needs to be, for substitutability reasons). Will it be
acceptable where the expected type is DT with Z? Probably not. So there's still
a difference in treatment between "pure" unions and unions derived by
restriction.

I'm inclined to revert to my original proposal: we follow XSD 1.1 by saying
that atomic values are substitutable for a "pure" union type but not for a
"restricted" union type.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Thursday, 17 March 2011 17:51:14 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:45 UTC