Class SchemaManager
- Direct Known Subclasses:
SchemaManagerImpl
SchemaManager is used to load schema documents, and to set options for the way in which they are loaded.
The SchemaManager is deprecated from Saxon 13, and an XsdCompiler should be used instead.
The class is retained to provide a measure of backwards compatibility, but some changes may be needed. In particular:
- The schema must now be loaded (using
load(File),load(Source...), orimportComponents(Source)) before callingnewSchemaValidator()to construct a validator. - The schema must be loaded in a single call of
load(File),load(Source...), orimportComponents(Source); it can no longer be built incrementally. - The schema is made available automatically to any
XsltCompiler,XQueryCompiler, orXPathCompilerthat is created after the schema is loaded, but it has no effect on any pre-existing compilers.
A note on terminology: a schema is a collection of schema components, such as type definitions, constructed by compiling a set of schema documents.
In earlier Saxon releases the schema built using the SchemaManager was held globally at the level
of the Processor or Configuration, and new schema components were also added to this schema
as a side effect of other actions that load schemas, for example xsl:import-schema in XSLT,
import schema declarations in XQuery, and xsi:schemaLocation attributes in source
documents undergoing validation. This is no longer the case. The schema built using this class is not modified when
queries and stylesheets import additional schema documents.
The SchemaManager is obtained using the call Processor.getSchemaManager(). Repeated calls
deliver the same SchemaManager each time. The SchemaManager is not thread-safe; in particular,
calls on load(Source...) should not be made in multiple threads concurrently.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclear()Deprecated.Reset the schema manager to its initial state, in particular, set the accumulated schema to be empty.abstract voidexportComponents(Destination destination) Deprecated.Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded into this Processor.abstract ErrorListenerDeprecated.since 10.0.abstract ErrorReporterDeprecated.abstract SchemaURIResolverDeprecated.Get the SchemaURIResolver to be used during schema loading.abstract XsdSchemaDeprecated.abstract StringDeprecated.Get the version of XSD in use for this schema.abstract voidimportComponents(Source source) Deprecated.Import a precompiled Schema Component Model from a given Source.Deprecated.Load a schema document from a given File.abstract XsdSchemaDeprecated.Load a schema document from a givenSource, or from a number of sources.abstract SchemaValidatorDeprecated.Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManager.abstract voidsetErrorListener(ErrorListener listener) Deprecated.since 10.0.abstract voidsetErrorReporter(ErrorReporter reporter) Deprecated.abstract voidsetSchemaURIResolver(SchemaURIResolver resolver) Deprecated.Set the SchemaURIResolver to be used during schema loading.abstract voidsetXsdVersion(String version) Deprecated.Set the version of XSD in use for this schema.
-
Field Details
-
hasLoadedSchema
protected boolean hasLoadedSchemaDeprecated.
-
-
Constructor Details
-
SchemaManager
public SchemaManager()Deprecated.
-
-
Method Details
-
setXsdVersion
Deprecated.Set the version of XSD in use for this schema. 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
Deprecated.Get the version of XSD in use for this schema. 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
Deprecated. -
getErrorReporter
Deprecated. -
setSchemaURIResolver
Deprecated.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 aSourcerepresenting the location where a schema document can be found.This SchemaURIResolver is used to dereference the URIs appearing in
xs:import,xs:include, andxs:redefinedeclarations.- Parameters:
resolver- the SchemaURIResolver to be used during schema loading.
-
getSchemaURIResolver
Deprecated.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
Deprecated.Load a schema document from a givenSource, or from a number of sources. The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as anXsdSchemaobject.This method can only be called once on a given
SchemaManagerobject.- Parameters:
source- the document(s) containing the schema(s). The getSystemId() method applied to this Source must return a base URI suitable for resolvingxs:includeandxs:importdirectives. Each 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). If no schema documents are supplied, an empty schema is loaded.- Returns:
- the resulting schema.
- Throws:
SaxonApiException- if the schema document is not valid.- Since:
- 9.1. From Saxon 12.3, the method can only be called once; to load from multiple schema documents,
either supply multiple sources in a single call to the
load(Source...)method, or use a separateSchemaManagerfor each one and combine the resulting schemas.
-
load
Deprecated.Load a schema document from a given File. The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as anXsdSchemaobject.This method can only be called once on a given
SchemaManagerobject.- Parameters:
file- the document containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolvingxs:includeandxs:importdirectives. 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)- Returns:
- the resulting schema.
- Throws:
SaxonApiException- if the schema document is not valid.- Since:
- 12.0
-
clear
public abstract void clear()Deprecated.Reset the schema manager to its initial state, in particular, set the accumulated schema to be empty. -
getXsdSchema
Deprecated. -
importComponents
Deprecated.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
Deprecated.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
Deprecated.Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManager.The result of calling
schemaManager.newSchemaValidator()is the same as the result of callingschemaManager.getXsdSchema().newSchemaValidator().- Returns:
- a new SchemaValidator
- Throws:
IllegalStateException- if no schema has been loaded (using eitherload(Source...)orimportComponents(Source)). To validate against an empty schema, first call {load(Source...)} supplying no arguments.
-
XsdCompiler