Validation using s9api
The s9api interface allows schemas to be loaded into a Processor, and then to be used for validating instances, or for schema-aware XSLT and XQuery processing.
The main steps are:
If required, set options on the
SchemaManagerto control the way in which schema documents will be loaded.
Load a schema document by calling the load() method, which takes a JAXP Source object as its argument. The resulting schema document is available to all applications run within the containing
Set options on the
SchemaValidatorto control the way in which a particular validation episode is performed, and then invoke its validate() method to validate an instance document.
Note that additional schemas referenced from the
attributes within the source documents will be loaded as necessary. By default a target
namespace is ignored if there is already a loaded schema for that namespace; Saxon makes
no attempt to load multiple schemas for the same namespace and check them for
consistency. This behaviour can be changed using the configuration option MULTIPLE_SCHEMA_IMPORTS.
Although the API is defined in such a way that a SchemaValidator is created for a
particular SchemaManager, in the Saxon implementation the schema components that are available
to the validator are not only the components within that schema, but all the components
that form part of any schema registered with the
Processor (or indeed, with
the underlying Configuration).
implements the Destination
interface, which means it can be used to receive input from any process that writes to a
Destination, for example an XSLT transformation or an XQuery query. The
result of validation can also be sent to any
Destination, for example an