Used to make assertions in the form of XPath expressions, causing a dynamic error if the assertion turns out to be false.
Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element
XPath expression to be asserted.
Can be used to specify (part of) the content of the error message produced when the assertion is false.
Specifies the error code associated with the error message produced when the assertion is false.
Available in XSLT 3.0. From Saxon 9.8, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.5. Available for all platforms.
Notes on the Saxon implementation
Following a change in the W3C specification, from Saxon 9.7 assertions are now
disabled by default. To enable assertions, use
-ea command line option, or the
configuration property XSLT_ENABLE_ASSERTIONS,
XsltCompiler.enableAssertions(true) in the s9api interface.
It may be useful to add an attribute such as
xsl:assert instructions; the global static variable
DEBUG can then be used to switch assertion processing on and
off. The variable might be declared as
The following code tests whether the value of
non-negative, and if not, fails with an error message: