Schema-aware XSLT and XQuery from Java and C#

If a query or stylesheet is schema-aware, it will typically expect the principal input document to be schema-validated. There are a number of ways this can be achieved:

Within an application, a schema should only be compiled once into an XdmSchema object. Compiling it once to validate a source document, and again to satisfy a schema import in XSLT or XQuery, is likely to lead to errors (quite apart from being inefficient).

The configuration property VALIDATION_WARNINGS has the same effect as the -outval:recover option on the command line: validation errors encountered when processing the final result tree are reported to the ErrorListener as warnings, not as fatal errors.

If you are validating the result tree, and you want your application to have access to the type annotations in the validated tree, then you supply an XdmDestination as the destination for the query or transformation results. From this you can extract the XdmNode representing the root of the tree, and thence navigate to other nodes in the tree. To get the actual type annotation you need to drop into lower-level Saxon interfaces, by obtaining the underlying NodeInfo object and calling its getSchemaType() method.