Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.saxonica.schema
Class SchemaCompiler

    java.lang.Object
      com.saxonica.schema.SchemaCompiler

All Implemented Interfaces:
  ISchemaCompiler

    public class SchemaCompiler

extends java.lang.Object
implements ISchemaCompiler

A SchemaCompiler is capable of reading source schema documents and converting them into collections of schema components. The Compiler holds all the options relating to schema compilation, including maintaining information about the schema documents involved in a compilation.

A default SchemaCompiler is available as part of the SchemaAwareConfiguration

Since:
  8.9

Constructor Summary
`SchemaCompiler(SchemaAwareConfiguration config)` Create a SchemaCompiler

Method Summary
`void` | `addPendingTypeCheck(IdentityConstraint constraint, SchemaType contextItemType)` Register an identity constraint that needs to be type-checked
`void` | `addSchemaSource(javax.xml.transform.Source schemaSource)` Load a schema, which will be available for use by all subsequent operations using this Configuration.
`void` | `addSchemaSource(javax.xml.transform.Source schemaSource, javax.xml.transform.ErrorListener errorListener)` Load a schema, which will be available for use by all subsequent operations using this SchemaAwareConfiguration.
`void` | `compile()` In deferred validation mode, validate and compile the accumulated schema components
`void` | `error(java.lang.String message, javax.xml.transform.SourceLocator locator)` Report an error
`SchemaAwareConfiguration` | `getConfiguration()` Get the configuration
`int` | `getErrorCount()` Test whether errors have been reported
`javax.xml.transform.ErrorListener` | `getErrorListener()` Get the ErrorListener used in this configuration.
`XSDSchema` | `getExistingSchemaDocument(java.lang.String systemId, java.lang.String targetNamespace)` Get the root element of the tree representing a schema document that has already been read
`int` | `getLanguageVersion()` Get the XSD langauge version allowed
`NamePool` | `getNamePool()` Get the NamePool
`int[]` | `getOccurrenceLimits()` Get the occurrence limits previously set using setOccurrenceLimits (or the default)
`PipelineConfiguration` | `getPipelineConfiguration()` Get the pipeline configuration
`PreparedSchema` | `getPreparedSchema()` Get the PreparedSchema.
`SchemaURIResolver` | `getSchemaURIResolver()` Get the user-defined SchemaURIResolver for resolving URIs used in "import schema" declarations; if none has been explicitly set, returns the standard schema URI resolver.
`boolean` | `isBeingRead(java.lang.String systemId)` Determine whether a particular URI is currently being read
`boolean` | `isDeferredValidationMode()` Ask if deferred validation mode is currently set
`void` | `markAsRead(java.lang.String systemId, XSDSchema schema)` Mark a document as having been read
`java.lang.String` | `readInlineSchema(NodeInfo root, java.lang.String expected, javax.xml.transform.ErrorListener errorListener)` Read an inline schema from a stylesheet
`void` | `readMultipleSchemas(PipelineConfiguration pipe, java.lang.String baseURI, java.util.Collection schemaLocations, java.lang.String expected)` Read schemas from a list of schema locations
`java.lang.String` | `readSchema(PipelineConfiguration pipe, java.lang.String baseURI, java.lang.String schemaLocation, java.lang.String expected)` Read a schema document from a given schema location.
`void` | `setBeingRead(java.lang.String systemId)` Mark a URI as currently being read
`void` | `setDeferredValidationMode(boolean defer)` Set deferred validation mode.
`void` | `setErrorListener(javax.xml.transform.ErrorListener listener)` Set the ErrorListener to be used in this compiler.
`void` | `setLanguageVersion(int version)` Set the XSD language version allowed.
`void` | `setOccurrenceLimits(int minimum, int maximum)` Set the occurrence limits to be used when compiling a finite state automaton.
`void` | `setPipelineConfiguration(PipelineConfiguration pipelineConfiguration)` Set the pipeline configuration
`void` | `setPreparedSchema(PreparedSchema schema)` Set the PreparedSchema.
`void` | `typeCheckIdentityConstraints()` Do all the pending type-checking
`PreparedSchema` | `validate(SchemaDocument doc)` Validate the schema represented by a schema document.
`void` | `warning(java.lang.String message, javax.xml.transform.SourceLocator locator)` Report a warning

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SchemaCompiler

    public SchemaCompiler(SchemaAwareConfiguration config)

  Create a SchemaCompiler

  Parameters:
    `config` - the Saxon Configuration

Method Detail

### getConfiguration

    public SchemaAwareConfiguration getConfiguration()

  Get the configuration

  Returns:
    the configuration (which is always schema-aware)

### getNamePool

    public NamePool getNamePool()

  Get the NamePool

  Returns:
    the name pool

### setLanguageVersion

    public void setLanguageVersion(int version)

  Set the XSD language version allowed.

  Parameters:
    `version` - the language version allowed. Default is `Configuration.XSD10`; to use facilities in XML Schema 1.1, the value must be set to `Configuration.XSD11`

### getLanguageVersion

    public int getLanguageVersion()

  Get the XSD langauge version allowed

  Returns:
    the XSD language version. Default is `Configuration.XSD10`; to use facilities in XML Schema 1.1, the value must be set to `Configuration.XSD11`

### setDeferredValidationMode

    public void setDeferredValidationMode(boolean defer)

  Set deferred validation mode. In this mode, schema documents loaded using the readSchema() interfaces are not fully compiled and validated until the compile() method is called.

  Parameters:
    `defer` - set to true to select deferred validation mode

### isDeferredValidationMode

    public boolean isDeferredValidationMode()

  Ask if deferred validation mode is currently set

  Returns:
    true if deferred validation mode has been set

### setPreparedSchema

    public void setPreparedSchema(PreparedSchema schema)

  Set the PreparedSchema. Used when validating a schema loaded using the SchemaModelLoader

  Parameters:
    `schema` - the schema that has been loaded

### getPreparedSchema

    public PreparedSchema getPreparedSchema()

  Get the PreparedSchema. This is a callback available only during a schema validation episode

  Returns:
    the PreparedSchema containing all the schema components

### getErrorListener

    public javax.xml.transform.ErrorListener getErrorListener()

  Get the ErrorListener used in this configuration. If no ErrorListener has been supplied explicitly, the default ErrorListener is used.

  Returns:
    the ErrorListener.
  Since:
    8.9

### setErrorListener

    public void setErrorListener(javax.xml.transform.ErrorListener listener)

  Set the ErrorListener to be used in this compiler. The ErrorListener is informed of all errors detected during schema processing.

  Parameters:
    `listener` - the ErrorListener to be used
  Since:
    8.9

### getErrorCount

    public int getErrorCount()

  Test whether errors have been reported

  Returns:
    the number of errors reported

### setOccurrenceLimits

    public void setOccurrenceLimits(int minimum,
                                    int maximum)

  Set the occurrence limits to be used when compiling a finite state automaton.

  Parameters:
    `minimum` - The highest value of minOccurs that will be strictly enforced. If the actual value of minOccurs in a schema is higher than this value, it will be treated as if this value had been specified. The default is 100.
    `maximum` - The highest value of maxOccurs that will be strictly enforced. If the actual value of maxOccurs in a schema is higher than this value, it will be treated as if "unbounded" had been specified. The default is 250.
  Since:
    8.9

### getOccurrenceLimits

    public int[] getOccurrenceLimits()

  Get the occurrence limits previously set using setOccurrenceLimits (or the default)

  Returns:
    an array of two integers, the minimum occurrence limit and the maximum occurrence limit
  Since:
    8.9

### setBeingRead

    public void setBeingRead(java.lang.String systemId)

  Mark a URI as currently being read

  Parameters:
    `systemId` - the URI of the schema document being read

### isBeingRead

    public boolean isBeingRead(java.lang.String systemId)

  Determine whether a particular URI is currently being read

  Parameters:
    `systemId` - the URI of the document in question
  Returns:
    true if the document is currently being read

### markAsRead

    public void markAsRead(java.lang.String systemId,
                           XSDSchema schema)

  Mark a document as having been read

  Parameters:
    `systemId` - the URI of the schema document that has been read
    `schema` - the root element of the schema document contstructed from this URI

### getExistingSchemaDocument

    public XSDSchema getExistingSchemaDocument(java.lang.String systemId,
                                               java.lang.String targetNamespace)

  Get the root element of the tree representing a schema document that has already been read

  Parameters:
    `systemId` - the URI of the required schema document
    `targetNamespace` - the expected namespace. If the schema document was previously read but chameleoned into a different namespace, we read it again
  Returns:
    the root element of the tree representing this schema document

### getPipelineConfiguration

    public PipelineConfiguration getPipelineConfiguration()

  Get the pipeline configuration

  Returns:
    the pipeline configuration

### setPipelineConfiguration

    public void setPipelineConfiguration(PipelineConfiguration pipelineConfiguration)

  Set the pipeline configuration

  Parameters:
    `pipelineConfiguration` - the pipeline configuration

### getSchemaURIResolver

    public SchemaURIResolver getSchemaURIResolver()

  Get the user-defined SchemaURIResolver for resolving URIs used in "import schema" declarations; if none has been explicitly set, returns the standard schema URI resolver.

  Returns:
    the SchemaURIResolver

### addSchemaSource

    public void addSchemaSource(javax.xml.transform.Source schemaSource)
                         throws SchemaException

  Load a schema, which will be available for use by all subsequent operations using this Configuration. Any errors will be notified to the ErrorListener associated with this Configuration.

  Parameters:
    `schemaSource` - the JAXP Source object identifying the schema document to be loaded
  Throws:
    `SchemaException` - if the schema cannot be read or parsed or if it is invalid
    `java.lang.UnsupportedOperationException` - if the configuration is not schema-aware
  Since:
    9.1

### addSchemaSource

    public void addSchemaSource(javax.xml.transform.Source schemaSource,
                                javax.xml.transform.ErrorListener errorListener)
                         throws SchemaException

  Load a schema, which will be available for use by all subsequent operations using this SchemaAwareConfiguration.

  Parameters:
    `schemaSource` - the JAXP Source object identifying the schema document to be loaded
    `errorListener` - the ErrorListener to be notified of any errors in the schema.
  Throws:
    `SchemaException` - if the schema cannot be read or parsed or if it is invalid

### readSchema

    public java.lang.String readSchema(PipelineConfiguration pipe,
                                       java.lang.String baseURI,
                                       java.lang.String schemaLocation,
                                       java.lang.String expected)
                                throws SchemaException

  Read a schema document from a given schema location. If deferredValidationMode is not set, the schema document will be fully validated and integrated with other schema documents previously loaded

  Parameters:
    `pipe` - the pipeline configuration
    `baseURI` - the base URI for resolving relative URIs
    `schemaLocation` - the location "hint" where to find the schema document. Must not be null.
    `expected` - the target namespace expected; null if there is no expectation
  Returns:
    the actual target namespace of the schema
  Throws:
    `SchemaException`

### readMultipleSchemas

    public void readMultipleSchemas(PipelineConfiguration pipe,
                                    java.lang.String baseURI,
                                    java.util.Collection schemaLocations,
                                    java.lang.String expected)
                             throws SchemaException

  Read schemas from a list of schema locations

  Parameters:
    `pipe` - the PipelineConfiguration
    `baseURI` - the base URI for resolving relative URIs
    `schemaLocations` - the list of location "hints" where to find the schema document. Must not be null.
    `expected` - the target namespace expected in each of the schema documents; null if there is no
  Throws:
    `SchemaException`

### readInlineSchema

    public java.lang.String readInlineSchema(NodeInfo root,
                                             java.lang.String expected,
                                             javax.xml.transform.ErrorListener errorListener)
                                      throws SchemaException

  Read an inline schema from a stylesheet

  Parameters:
    `root` - the xs:schema element in the stylesheet
    `expected` - the target namespace expected; "" if there is no expectation
    `errorListener` - The destination for error messages. May be null, in which case the errorListener registered with this Configuration is used.
  Returns:
    the actual target namespace of the schema
  Throws:
    `SchemaException`

### compile

    public void compile()
                 throws SchemaException

  In deferred validation mode, validate and compile the accumulated schema components

  Throws:
    `SchemaException`

### validate

    public PreparedSchema validate(SchemaDocument doc)
                            throws SchemaException

  Validate the schema represented by a schema document. This method validates the schema components associated with this schema document: that is, the components defined in this document, together with any components referenced by these components if they have not already been validated.

  Parameters:
    `doc` - the schema document to be validated
  Returns:
    schema the schema, if it is valid
  Throws:
    `SchemaException` - if the schema is invalid

### error

    public void error(java.lang.String message,
                      javax.xml.transform.SourceLocator locator)
               throws SchemaException

  Report an error

  Parameters:
    `message` - the error message
    `locator` - the location of the error
  Throws:
    `SchemaException`

### warning

    public void warning(java.lang.String message,
                        javax.xml.transform.SourceLocator locator)

  Report a warning

  Parameters:
    `message` - the warning message
    `locator` - the location of the error

### addPendingTypeCheck

    public void addPendingTypeCheck(IdentityConstraint constraint,
                                    SchemaType contextItemType)

  Register an identity constraint that needs to be type-checked

  Parameters:
    `constraint` - the constraint to be checked
    `contextItemType` - the type of the context node for the XPath expression to be checked

### typeCheckIdentityConstraints

    public void typeCheckIdentityConstraints()

  Do all the pending type-checking

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) Saxonica Limited. All rights reserved.