ItemType may appear (for example in a function signature or variable declaration, or
instance of or
cast as expressions), the syntax
~alias is permitted,
alias is a name for an item type declared elsewhere. Type aliases are QNames, and prefixes are
resolved in the usual way (using the default namespace for elements and types).
Type aliases are useful because they abstract away from the detail of how a type is
implemented: for example
is more meaningful than
tuple(r: xs:double, i: xs:double), and it creates more scope for changing the
way types are represented as the software evolves. However, type aliases do not provide any real encapsulation or information
hiding. Type aliases cannot be used within their own definition, and the definition of a type alias cannot be circular.
The mapping of type aliases to item types is an extension to the static context of an expression.
In XSLT, type aliases can be defined using the top-level declaration saxon:type-alias:
XSLT-defined type aliases are scoped to a package. The usual rules for import precedence apply.
Type aliases can be used in XSLT match patterns (see XSLT Patterns). For example:
~T at the start of a pattern can be regarded as an abbreviation for
.[. instance of ~T].
In XQuery, type aliases can be declared in the query prolog using the syntax
declare type QName = ItemType;,
declare type cx:complex = tuple(r: xs:double, i: xs:double);.