Bugzilla – Bug 15807
[XP30] 3.16.3 Cast - {variety}simple?
Last modified: 2012-02-15 09:15:16 UTC
The XQuery 3.0 specification states in 3.16.3 Cast "The SimpleTypeName must be the name of a type defined in the in-scope schema types, and the {variety} of the type must be simple." However, XML Schema states: "{variety} One of {atomic, list, union}. Required for all Simple Type Definitions except ·anySimpleType·, in which it is absent." i.e. {variety} doesn't include 'simple'. This also appears in 3.16.4 Castable and the appendix entry for err:XQST0052
Also in this section, the EBNF rule [169] is reproduced, although it is not referenced in [94] or [164]. Does this indicate an error? [94] CastExpr ::= UnaryExpr ( "cast" "as" SingleType )? [164] SingleType ::= SimpleTypeName "?"? [169] AtomicOrUnionType ::= EQName
It should say 'The SimpleTypeName must be the name of a *generalized atomic type* defined in the in-scope schema types, that is, either an atomic type or a *restricted union type*'. (Did we really end up deciding to call this class of union types "restricted union types"? I remember there was a lot of confusion about using this term for union types that do not incorporate a restriction.)
Actually, 5(d) makes it clear that we allow casting from string/untypedAtomic to any simple type whatsoever. So (a) my comment 2 is wrong, and (b) the presence of the production AtomicOrUnionType in this section is an anachronism. We also allow casting from an instance of one of the member types of a union to the union type, and from a value that is castable to one of the member types of a union to the union type. These cases should probably be included in the list of cases in rule 5.
Changing to XPath 3.0, since it affects both specs.
(In reply to comment #0) > The XQuery 3.0 specification states in 3.16.3 Cast > > "The SimpleTypeName must be the name of a type defined in the in-scope schema > types, and the {variety} of the type must be simple." We will change "and the {variety} of the type must be simple" to "and the type must be simple". Also, we need to add these two cases to the list of allowable casts: * We allow casting from one of the members of a union to a union type. * We allow casting from a value to a union type if you can cast to any member of the union. We will also remove production 169 from that section.