Validation from C#
The Saxon.Api 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 one of the Compile() methods, which allow the input to be supplied in a variety of forms (for example, a
TextReader, or a
Uri). The resulting schema 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 one of its Validate() methods to validate an instance document.
Note that additional schemas referenced from the
attributes within the source documents will be loaded as necessary, unless the
property is set to false. 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 behavior 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).