RE: What are the XQuery built-in types?

> More generally, probably all derived types will be provided 
> through type annotations in the data model -- so xs:NMTOKENS 
> is supported (and built-in to XML Schema) just like any other 
> derived type, but it seems that it is not really a "built-in" 
> type in XQuery, by the terminology in the drafts.
> 
> I am skeptical that I can query "of type xs:NMTOKENS" (or any 
> other list type), since it seems that I am not allowed to use 
> that type as a
> constructor: xs:NMTOKENS("A1 B2").  But then again maybe one 
> or both of these are allowed?

xs:NMTOKENS can be used in a construct of the form "attribute of type
xs:NMTOKENS", because it performs the same role as a user-defined type that
can be used as a type annotation for element and attribute nodes.

You can only use constructors for atomic values, so the constructor is
always the name of an atomic type. xs:NMTOKENS is a simple type, but it is
not an atomic type.
> 
> Also, what if I were to query
>   if (@att instance of attribute of type xs:NMTOKEN*) ...

attribute of type xs:NMTOKEN*
  means
(attribute of type xs:NMTOKEN)*

that is a sequence of attributes, each of which is of type NMTOKEN.

(Yes, it's **** confusing, and I sincerely hope we are going to change the
syntax to make it less so).

> or
>   if (data(@att) instance of xs:NMTOKEN*) ...
> Do these queries succeed or fail with att is annotated with 
> type xs:NMTOKENS?

This one is fine, and succeeds.

Michael Kay

Received on Tuesday, 11 February 2003 06:11:50 UTC