RE: ACTION A-641-13

> > xs:NMTOKENS("a") castable as XS:NMTOKENS
> 
> is true. Perhaps replace "is false" by "is not generally true".
> 

I have a bit of trouble disentangling why this is true. Let me try:

xs:NMTOKENS("a") returns type xs:NMTOKEN* (per section 18.3), which in this case is the same as xs:NMTOKEN("a"), which is (according to 18.3) the same as casting the string "a" to xs:NMTOKEN. Section 19.1.9 (casting from strings) points to 19.3.1 (casting to derived types). This cast succeeds, the result being type xs:NMTOKEN.

Casting xs:NMTOKEN to xs:NMTOKENS fits 19.3 (casting to non-primitive types). TT  is not a derived or parent type, they are not in the same branch (don't share the same primitive type) etc etc, so we end up in 19.3.6 (casting to list types).

This section says "the supplied value must be of type xs:string or xs:untypedAtomic" (it doesn't say it can be a derived type of xs:string or xs:untypedAtomic). Neither is true (it is xs:NMTOKEN), so I think the cast should fail.

Conversely, if the expression was " 'a' castable as xs:NMTOKENS", the cast would succeed.

This seems to be expressed in 18.3 in the Note with "This approach does not work with list types, because it is not permitted to use a value of type xs:NMTOKEN* as input to the constructor function xs:NMTOKENS". This suggests that the expression from the previous message should indeed always fail.

Or did I miss something?

I think the same is true for the other list types, xs:ENTITIES(x) is never castable to xs:ENTITIES, and xs:IDREFS(x) is never castable to xs:IDREFS.

I do not know what happens if you have a user-defined list type. Is the constructor of such a type (say xs:MyListInt of type xs:integer*) similar that it returns not xs:MyListInt, but a sequence of xs:integer?. 

I think that "xs:NMTOKENS(()) castable as xs:NMTOKENS" should also fail, even though the constructor itself succeeds, but I'm unsure and cannot find this clearly in the text.

-- Abel

Received on Sunday, 8 May 2016 15:17:57 UTC