Conditional Type Assignment
Saxon supports Conditional Type Assignment.
The full syntax of XPath 2.0 can be used, but the expression is constrained to access the element node and its attributes: it has no access to the descendants, siblings, or ancestors of the element.