SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
| Introduction
| Constants
| Variable References
| Function Calls
| Axis steps
| Parentheses and operator precedence
| Filter expressions
| Path expressions
» | Cast as, Treat as
| Set difference and intersection
| Union
| Arithmetic expressions
| Range expressions
| Comparisons
| Instance of and Castable as
| Conditional Expressions
| Quantified Expressions
| For Expressions
| Boolean expressions: AND and OR
| Sequence expressions
Function Library
Standards Conformance

# Cast as, Treat as

The expression `E cast as T` converts the value of expression `E` to type `T`. Whether T is a built-in type or a user-defined type, the effect is exactly the same as using the constructor function `T (E)`.

The expression `E treat as T` is designed for environments that perform static type checking. Saxon doesn't do static type checking, so this expression has very little use, except to document an assertion that the expression `E` is of a particular type. A run-time failure will be reported if the value of `E` is not of type `T`; no attempt is made to convert the value to this type.

Next