The saxon:item-type element declares a simple name that can be used to represent an item type.

Category: declaration
Content: none
Permitted parent elements: xsl:stylesheet ; xsl:transform




The name to be used for the type.



The item type represented by the name.


"private" | "final"

The visibility of the item type. Saxon 11 only allows the value "private", which means the item type name is available only within the containing package.

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.8. Available for all platforms.


With maps and arrays, item types can become quite complex, and they are not always very meaningful. For example, in a SaxonJS stylesheet implementing an interactive chess game, the state of the board might be represented by the type array(array(xs:integer)), while a move or possible move might be represented as map(xs:string, xs:integer). 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(board) and 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 signature function ($board as type(board), $move as type(move)) as type(board).

The element 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 type(typename) syntax anywhere within the stylesheet, including in another saxon:item-type 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 in XSLT as and type attributes, and in XPath instance of and treat as expressions (but not in cast as or castable as, 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 xsl:include.

Type aliases are not recognized in static expressions (for example, in use-when).

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 ALLOW_SYNTAX_EXTENSIONS to be enabled.

For further information about the syntax extension, see Type aliases.


<saxon:item-type name="square" as="xs:integer"/> <saxon:item-type name="piece" as="xs:string"/> <saxon:item-type name="board" as="array(array(type(square)))"/> <saxon:item-type name="move" type="map(type(piece), type(square))"/>

See also