Class SchemaManager
- Direct Known Subclasses:
SchemaManagerImpl
To obtain a SchemaManager
, use the method Processor.getSchemaManager()
.
In a schema-aware Processor there is exactly one
SchemaManager
(in a non-schema-aware Processor there is none).
The cache of compiled schema definitions can include only one schema component (for example a type, or an element declaration) with any given name. An attempt to compile two different schemas in the same namespace will usually therefore fail.
As soon as a type definition or element declaration is used for the first time in a validation episode, it is marked as being "sealed": this prevents subsequent modifications to the component. Examples of modifications that are thereby disallowed include adding to the substitution group of an existing element declaration, adding subtypes to an existing type, or redefining components using <xs:redefine>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
exportComponents
(Destination destination) Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded into this Processor.abstract ErrorListener
Deprecated.since 10.0.abstract ErrorReporter
abstract SchemaURIResolver
Get the SchemaURIResolver to be used during schema loading.abstract String
Get the version of XSD in use.abstract void
importComponents
(Source source) Import a precompiled Schema Component Model from a given Source.void
Load a schema document from a given File.abstract void
Load a schema document from a given Source.abstract SchemaValidator
Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManagerabstract void
setErrorListener
(ErrorListener listener) Deprecated.since 10.0.abstract void
setErrorReporter
(ErrorReporter reporter) abstract void
setSchemaURIResolver
(SchemaURIResolver resolver) Set the SchemaURIResolver to be used during schema loading.abstract void
setXsdVersion
(String version) Set the version of XSD in use.
-
Constructor Details
-
SchemaManager
public SchemaManager()
-
-
Method Details
-
setXsdVersion
Set the version of XSD in use. The value must be "1.0" or "1.1". The default is currently "1.0", but this may change in a future release.- Parameters:
version
- the version of the XSD specification/language: either "1.0" or "1.1".
-
getXsdVersion
Get the version of XSD in use. The value will be "1.0" or "1.1"- Returns:
- the version of XSD in use.
-
setErrorListener
Deprecated.since 10.0. UsesetErrorReporter(ErrorReporter)
.Set the ErrorListener to be used while loading and validating schema documents- Parameters:
listener
- The error listener to be used. This is notified of all errors detected during the compilation. May be set to null to revert to the default ErrorListener.
-
getErrorListener
Deprecated.since 10.0. UsegetErrorReporter()
Get the ErrorListener being used while loading and validating schema documents- Returns:
- listener The error listener in use. This is notified of all errors detected during the compilation. Returns null if no user-supplied ErrorListener has been set.
-
setErrorReporter
-
getErrorReporter
-
setSchemaURIResolver
Set the SchemaURIResolver to be used during schema loading. This SchemaURIResolver, despite its name, is not used for resolving relative URIs against a base URI; it is used for dereferencing an absolute URI (after resolution) to return aSource
representing the location where a schema document can be found.This SchemaURIResolver is used to dereference the URIs appearing in
xs:import
,xs:include
, andxs:redefine
declarations.- Parameters:
resolver
- the SchemaURIResolver to be used during schema loading.
-
getSchemaURIResolver
Get the SchemaURIResolver to be used during schema loading.- Returns:
- the URIResolver used during stylesheet compilation. Returns null if no user-supplied URIResolver has been set.
-
load
Load a schema document from a given Source. The schema components derived from this schema document are added to the cache of schema components maintained by this SchemaManager- Parameters:
source
- the document containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolvingxs:include
andxs:import
directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)- Throws:
SaxonApiException
- if the schema document is not valid, or if its contents are inconsistent with the schema components already held by this SchemaManager.
-
load
Load a schema document from a given File. The schema components derived from this schema document are added to the cache of schema components maintained by this SchemaManager- Parameters:
file
- the document containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolvingxs:include
andxs:import
directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)- Throws:
SaxonApiException
- if the schema document is not valid, or if its contents are inconsistent with the schema components already held by this SchemaManager.- Since:
- 12.0
-
importComponents
Import a precompiled Schema Component Model from a given Source. The schema components derived from this schema document are added to the cache of schema components maintained by this SchemaManager- Parameters:
source
- the XML file containing the schema component model, as generated by a previous call onexportComponents(net.sf.saxon.s9api.Destination)
- Throws:
SaxonApiException
- if a failure occurs loading the schema from the supplied source
-
exportComponents
Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded into this Processor.- Parameters:
destination
- the destination to recieve the precompiled Schema Component Model in the form of an XML document- Throws:
SaxonApiException
- if a failure occurs writing the schema components to the supplied destination
-
newSchemaValidator
Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManager- Returns:
- a new SchemaValidator
-