Class SchemaManager

java.lang.Object
net.sf.saxon.s9api.SchemaManager
Direct Known Subclasses:
SchemaManagerImpl

@Deprecated public abstract class SchemaManager extends Object
Deprecated.
since Saxon 13.0 - use XsdCompiler
The 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:

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 Details

    • hasLoadedSchema

      protected boolean hasLoadedSchema
      Deprecated.
  • Constructor Details

    • SchemaManager

      public SchemaManager()
      Deprecated.
  • Method Details

    • setXsdVersion

      public abstract void setXsdVersion(String version)
      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

      public abstract String 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 public abstract void setErrorListener(ErrorListener listener)
      Deprecated.
      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 public abstract ErrorListener getErrorListener()
      Deprecated.
      since 10.0. Use getErrorReporter()
      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

      public abstract void setErrorReporter(ErrorReporter reporter)
      Deprecated.
    • getErrorReporter

      public abstract ErrorReporter getErrorReporter()
      Deprecated.
    • setSchemaURIResolver

      public abstract void setSchemaURIResolver(SchemaURIResolver resolver)
      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 a Source representing the location where a schema document can be found.

      This SchemaURIResolver is used to dereference the URIs appearing in xs:import, xs:include, and xs:redefine declarations.

      Parameters:
      resolver - the SchemaURIResolver to be used during schema loading.
    • getSchemaURIResolver

      public abstract SchemaURIResolver 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

      public abstract XsdSchema load(Source... source) throws SaxonApiException
      Deprecated.
      Load a schema document from a given Source, 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 an XsdSchema object.

      This method can only be called once on a given SchemaManager object.

      Parameters:
      source - the document(s) containing the schema(s). The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. 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 separate SchemaManager for each one and combine the resulting schemas.
    • load

      public XsdSchema load(File file) throws SaxonApiException
      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 an XsdSchema object.

      This method can only be called once on a given SchemaManager object.

      Parameters:
      file - the document containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs: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)
      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

      public abstract XsdSchema getXsdSchema()
      Deprecated.
    • importComponents

      public abstract void importComponents(Source source) throws SaxonApiException
      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 on exportComponents(net.sf.saxon.s9api.Destination)
      Throws:
      SaxonApiException - if a failure occurs loading the schema from the supplied source
    • exportComponents

      public abstract void exportComponents(Destination destination) throws SaxonApiException
      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

      public abstract SchemaValidator 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 calling schemaManager.getXsdSchema().newSchemaValidator().

      Returns:
      a new SchemaValidator
      Throws:
      IllegalStateException - if no schema has been loaded (using either load(Source...) or importComponents(Source)). To validate against an empty schema, first call {load(Source...)} supplying no arguments.