[
Lists Home |
Date Index |
Thread Index
]
".
>
> Unions will make more sense when I go back and read through WXS,
> but for now I'm trying to work forward to read the XPath,
> XQuery, and XSLT specifications. I'm not working with WXS yet,
> so I'm not familiar with the "basic reasons", and can't work
> back from them. I'm sure it's blindingly obvious to someone
> who's written schemas.
>
It's not blindingly obvious, and the Query/XSLT (QT) specs do rather assume
a more thorough knowledge of Schema than many readers are likely to possess,
but Vladimir's explanation was very accurate.
First thing to grasp about types in QT is that there are two kinds of type:
schema types and sequence types. Schema types are defined in a schema, and
divide into complex types and simple types; simple types in turn divide into
union types, list types, and atomic types. Schema types are used as type
annotations on element and attribute nodes. Sequence types are the types of
XPath values (sequences): they consist of an item type and a cardinality
(1-1, 0-1, 0-many, or 1-many). The item type may be a node type (such as
text or attribute) or an atomic type. So atomic types are present in both
type hierarchies.
In the case of a list or union type, the node (an element or attribute) will
have a type annotation that is the name of the schema type (a union type, or
perhaps a list type whose member type is a union type), but the typed value
of the node will consist of one or more atomic values, each of which is an
instance of a specific atomic type (not an instance of the list or union
type).
So if an attribute has type xs:NMTOKENS, its value will be a sequence of
atomic values each of which is of type xs:NMTOKEN. If you want to assign
this sequence to a variable, you declare its type as xs:NMTOKEN*, not as
xs:NMTOKENS - because xs:NMTOKENS is a "schema type", whereas xs:NMTOKEN* is
a "sequence type".
Confused? Can't blame you.
Michael Kay
http://www.saxonica.com/
|