saxon:item-type element declares a simple name that can be used
to represent an item type.
The name to be used for the type
The item type represented by the name
With maps and arrays, item types can become quite complex, and they are not always
very meaningful. For example, in a Saxon-JS stylesheet implementing an interactive
chess game, the state of the board might be represented by the type
while a move or possible move might be represented as
Such types do little to make the code more readable, and they create a potential problem in exposing
design decisions as to how particular concepts are implemented internally. Type aliases allow
such types to be written as, for example
type(move). So a function
that takes a board and a move as input, and produces a new board as its result, would have the
function ($board as type(board), $move as type(move)) as type(board).
saxon:item-type can appear as a top-level declaration in the stylesheet.
A type that is declared anywhere in the stylesheet can be referenced using the
syntax anywhere within the stylesheet, including in another
declaration. Forwards references are allowed, but circular references are not.
Item types such as
type(board) can be used anywhere an item type is permitted, for example
type attributes, and in XPath
treat as expressions (but not in
cast as or
nor the name of a constructor function, unless a user-defined
function is explicitly written with the same name). Where a Sequence Type is allowed, the name can be followed
by an occurrence indicator, for example
type(move)* represents a sequence of moves.
Import precedence works in the usual way. Type aliases are currently local to a stylesheet package;
if you are writing a library package and want client applications to use aliases for the type names used in your API, issue
a stylesheet module containing the aliases, that users can include using
Type aliases are not recognized in static expressions (for example, in
Use of the
saxon:item-type syntax requires Saxon-PE or higher. Use of the "type(NNN)" syntax
in XPath expressions requires the configuration option
Feature.ALLOW_SYNTAX_EXTENSIONS to be enabled.
For further information about the syntax extension, see Type aliases.