com.saxonica.validate
Class SchemaAwareConfiguration

java.lang.Object
  extended bynet.sf.saxon.Configuration
      extended bycom.saxonica.validate.SchemaAwareConfiguration
All Implemented Interfaces:
java.io.Serializable, SourceResolver

public final class SchemaAwareConfiguration
extends Configuration

A subclass of Configuration that defines a schema-aware processor. This contains helper methods invoked both at compile time and at run-time to perform operations that are allowed only in a schema-aware processor; the superclass Configuration contains the dummy versions of these methods used in a non-schema-aware processor. The interface is designed so that the calling classes contain no references to classes that are available only in the schema-aware product.

Applications should avoid using this class directly, and should instead access all the necessary functionality through its superclass, Configuration.

See Also:
Serialized Form

Nested Class Summary
static class SchemaAwareConfiguration.SurrogateSchema
          A SurrogateSchema is a dummy schema object that is stored in the schema cache while the schema for a given namespace is being processed.
 
Field Summary
 
Fields inherited from class net.sf.saxon.Configuration
DO_NOT_RECOVER, JAVA_APPLICATION, listener, optimizer, RECOVER_SILENTLY, RECOVER_WITH_WARNINGS, recoveryPolicy, vendorFunctionLibrary, XML_SCHEMA, XML10, XML11, XPATH, XQUERY, XSLT
 
Constructor Summary
SchemaAwareConfiguration()
           
 
Method Summary
 void addSchema(java.lang.Object schema)
          Add a schema to the cache
 void addSchemaSource(javax.xml.transform.Source schemaSource)
          Load a schema, which will be available for use by all subsequent operations using this SchemaAwareConfiguration.
 void addSurrogateSchema(java.lang.String namespace)
          Put a temporary schema marker in the cache, to indicate that a schema for a given namespace is being processed.
 void displayLicenseMessage()
          Display a message about the license status
 Receiver getAnnotationStripper(Receiver destination)
          Add to a pipeline a receiver that strips all type annotations.
 SchemaDeclaration getAttributeDeclaration(int fingerprint)
          Get a global attribute declaration
 Receiver getDocumentValidator(Receiver receiver, java.lang.String systemId, NamePool namePool, int validationMode, int stripSpace, SchemaType schemaType)
          Get a document-level validator to add to a Receiver pipeline
 SchemaDeclaration getElementDeclaration(int fingerprint)
          Get a global element declaration
 Receiver getElementValidator(Receiver out, int nameCode, int locationId, SchemaType schemaType, int validation, NamePool pool)
          Get a Receiver that can be used to validate an element, and that passes the validated element on to a target receiver.
 javax.xml.transform.ErrorListener getErrorListener()
          Get the ErrorListener to which errors are reported
 java.util.Set getImportedNamespaces()
          Get the set of namespaces of imported schemas
 int[] getOccurrenceLimits()
          Get the occurrence limits previously set using setOccurrenceLimits (or the default)
 Optimizer getOptimizer()
          Factory method to get an Optimizer
 Receiver getOutputMethod(java.lang.String clarkName)
          Get a configuration-defined output method.
 java.lang.String getProductTitle()
          Get a message used to identify this product when a transformation is run using the -t option
 java.lang.Object getSchema(java.lang.String namespace)
          Get a schema from the cache.
 SchemaType getSchemaType(int fingerprint)
          Get the top-level schema type with a given fingerprint.
 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.
 PreparedSchema getSuperSchema()
          Get the SuperSchema, containing references to all names defined in all known schemas
 VendorFunctionLibrary getVendorFunctionLibrary()
          Get the FunctionLibrary used to bind calls on Saxon-defined extension functions
 boolean isSchemaAware(int language)
          Determine if the configuration is schema-aware
 boolean isSealedNamespace(java.lang.String namespace)
          Test whether a schema namespace is sealed.
 NodeTest makeSubstitutionGroupTest(SchemaDeclaration elementDecl)
          Make a test for elements corresponding to a given element declaration
 java.lang.String readInlineSchema(NodeInfo root, java.lang.String expected)
          Read an inline schema from a stylesheet
 void readMultipleSchemas(PipelineConfiguration pipe, java.lang.String baseURI, java.util.List 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 from a given schema location
 void removeSchema(java.lang.String namespace)
          Remove the schema for a given namespace.
 javax.xml.transform.Source resolveSource(javax.xml.transform.Source source, Configuration config)
          Implement the SourceResolver interface
 void sealNamespace(java.lang.String namespace)
          Mark a schema namespace as being sealed.
 void setOccurrenceLimits(int minimum, int maximum)
          Set the occurrence limits to be used when compiling a finite state automaton.
 void setPlatform(Platform platform)
          Set the Platform to be used for platform-dependent methods
 void supplyLicenseKey(java.io.BufferedReader reader)
          This method allows the contents of a license key to be supplied programmatically.
 int validateAttribute(int nameCode, java.lang.CharSequence value, int validation)
          Validate an attribute value (XSLT only)
 
Methods inherited from class net.sf.saxon.Configuration
areAllNodesUntyped, findExternalObjectModel, getClass, getClassLoader, getCollationURIResolver, getCollectionURIResolver, getConfiguration, getConfigurationProperty, getConversionContext, getDebugger, getDocumentNumberAllocator, getExtensionBinder, getExtensionFunctionFactory, getExternalObjectModels, getHostLanguage, getImplicitTimezone, getInstance, getLocale, getMessageEmitterClass, getModuleURIResolver, getNameChecker, getNamePool, getOutputURIResolver, getPlatform, getRecoveryPolicy, getSchemaValidationMode, getSourceParser, getSourceParserClass, getSourceResolver, getStandardModuleURIResolver, getStripsWhiteSpace, getStyleParser, getStyleParserClass, getSystemURIResolver, getTraceListener, getTreeModel, getURIResolver, getXMLVersion, init, isAllowExternalFunctions, isLazyConstructionMode, isLineNumbering, isMultiThreading, isRetainDTDAttributeTypes, isStripsAllWhiteSpace, isTiming, isTraceExternalFunctions, isValidation, isValidationWarnings, isVersionWarning, makeCollator, makeParser, makePipelineConfiguration, makeSchemaAwareConfiguration, makeSlotManager, makeTraceListener, makeURIResolver, registerExternalObjectModel, reportFatalError, reuseSourceParser, reuseStyleParser, setAllNodesUntyped, setAllowExternalFunctions, setClassLoader, setCollationURIResolver, setCollectionURIResolver, setConfigurationProperty, setDebugger, setErrorListener, setExtensionBinder, setExtensionFunctionFactory, setHostLanguage, setImplicitTimezone, setLazyConstructionMode, setLineNumbering, setMessageEmitterClass, setModuleURIResolver, setModuleURIResolver, setMultiThreading, setNamePool, setOutputURIResolver, setRecoveryPolicy, setRetainDTDAttributeTypes, setSchemaURIResolver, setSchemaValidationMode, setSourceParserClass, setSourceResolver, setStripsAllWhiteSpace, setStripsWhiteSpace, setStyleParserClass, setTiming, setTraceExternalFunctions, setTraceListener, setTreeModel, setURIResolver, setValidation, setValidationWarnings, setVersionWarning, setXMLVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaAwareConfiguration

public SchemaAwareConfiguration()
Method Detail

setPlatform

public void setPlatform(Platform platform)
Set the Platform to be used for platform-dependent methods

Overrides:
setPlatform in class Configuration
Parameters:
platform - the platform to be used

supplyLicenseKey

public void supplyLicenseKey(java.io.BufferedReader reader)
This method allows the contents of a license key to be supplied programmatically. This must be a license file as issued to authorized OEM distributors of Saxon-SA.

Parameters:
reader - A reader that will be used to read the contents of the license file (for example, a StringReader)
Throws:
java.lang.IllegalArgumentException - if the key supplied is not a valid OEM license key

getProductTitle

public java.lang.String getProductTitle()
Get a message used to identify this product when a transformation is run using the -t option

Overrides:
getProductTitle in class Configuration
Returns:
A string containing both the product name and the product version

isSchemaAware

public final boolean isSchemaAware(int language)
Determine if the configuration is schema-aware

Overrides:
isSchemaAware in class Configuration
Parameters:
language -

displayLicenseMessage

public void displayLicenseMessage()
Display a message about the license status

Overrides:
displayLicenseMessage in class Configuration

getErrorListener

public javax.xml.transform.ErrorListener getErrorListener()
Get the ErrorListener to which errors are reported

Overrides:
getErrorListener in class Configuration
Returns:
either the user-supplied error listener, or a system-provided error listener

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.

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

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.

Overrides:
getSchemaURIResolver in class Configuration

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 from a given schema location

Overrides:
readSchema in class Configuration
Parameters:
pipe -
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.List schemaLocations,
                                java.lang.String expected)
                         throws SchemaException
Read schemas from a list of schema locations

Overrides:
readMultipleSchemas in class Configuration
Parameters:
pipe -
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; null if there is no expectation
Throws:
SchemaException

readInlineSchema

public java.lang.String readInlineSchema(NodeInfo root,
                                         java.lang.String expected)
                                  throws SchemaException
Read an inline schema from a stylesheet

Overrides:
readInlineSchema in class Configuration
Parameters:
root - the xs:schema element in the stylesheet
expected - the target namespace expected; null if there is no expectation
Returns:
the actual target namespace of the schema
Throws:
SchemaException

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 SchemaAwareConfiguration.

Overrides:
addSchemaSource in class 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

addSchema

public void addSchema(java.lang.Object schema)
               throws SchemaException
Add a schema to the cache

Overrides:
addSchema in class Configuration
Parameters:
schema - This must be a SchemaReference (it is defined as an Object because a dummy version of the method exists in Saxon-B).
Throws:
SchemaException

addSurrogateSchema

public void addSurrogateSchema(java.lang.String namespace)
Put a temporary schema marker in the cache, to indicate that a schema for a given namespace is being processed. Used to detect circularities


getSchema

public java.lang.Object getSchema(java.lang.String namespace)
Get a schema from the cache. Return null if not found. The result will always be a PreparedSchema object, but must be cast by the caller.

Overrides:
getSchema in class Configuration
Returns:
an object of class javax.xml.validation.schema, which is not declared as such to avoid creating a dependency on this JDK 1.5 class

removeSchema

public void removeSchema(java.lang.String namespace)
Remove the schema for a given namespace. This is done if it is found to be invalid


getImportedNamespaces

public java.util.Set getImportedNamespaces()
Get the set of namespaces of imported schemas

Overrides:
getImportedNamespaces in class Configuration

getSuperSchema

public PreparedSchema getSuperSchema()
Get the SuperSchema, containing references to all names defined in all known schemas


sealNamespace

public void sealNamespace(java.lang.String namespace)
Mark a schema namespace as being sealed. This is done when components from this namespace are first used for validating a source document or compiling a source document or query. Once a namespace has been sealed, it is not permitted to change the schema components in that namespace by redefining them, deriving new types by extension, or adding to their substitution groups.

Overrides:
sealNamespace in class Configuration
Parameters:
namespace - the namespace URI of the components to be sealed

isSealedNamespace

public boolean isSealedNamespace(java.lang.String namespace)
Test whether a schema namespace is sealed. Once a namespace has been sealed, it is not permitted to change the schema components in that namespace by redefining them, deriving new types by extension, or adding to their substitution groups.

Overrides:
isSealedNamespace in class Configuration
Parameters:
namespace - the namespace URI of the components to be tested
Returns:
true if this namespace has been sealed, otherwise false

getElementDeclaration

public SchemaDeclaration getElementDeclaration(int fingerprint)
Get a global element declaration

Overrides:
getElementDeclaration in class Configuration
Returns:
the element declaration whose name matches the given fingerprint, or null if no element declaration with this name has been registered.

getAttributeDeclaration

public SchemaDeclaration getAttributeDeclaration(int fingerprint)
Get a global attribute declaration

Overrides:
getAttributeDeclaration in class Configuration
Returns:
the attribute declaration whose name matches the given fingerprint, or null if no element declaration with this name has been registered.

getSchemaType

public SchemaType getSchemaType(int fingerprint)
Get the top-level schema type with a given fingerprint.

Overrides:
getSchemaType in class Configuration
Parameters:
fingerprint - the fingerprint of the schema type
Returns:
the schema type , or null if there is none with this name.

getDocumentValidator

public Receiver getDocumentValidator(Receiver receiver,
                                     java.lang.String systemId,
                                     NamePool namePool,
                                     int validationMode,
                                     int stripSpace,
                                     SchemaType schemaType)
Get a document-level validator to add to a Receiver pipeline

Overrides:
getDocumentValidator in class Configuration
Parameters:
receiver - The receiver to which events should be sent after validation
systemId - the base URI of the document being validated
namePool - the namePool to be used by the validator
validationMode - for example Validation.STRICT or Validation.STRIP. The integer may also have the bit Validation.VALIDATE_OUTPUT set, indicating that the strean being validated is to be treated as a final output stream (which means multiple errors can be reported)
stripSpace -
schemaType - The type against which the outermost element of the document must be validated (null if there is no constraint)
Returns:
A Receiver to which events can be sent for validation

getElementValidator

public Receiver getElementValidator(Receiver out,
                                    int nameCode,
                                    int locationId,
                                    SchemaType schemaType,
                                    int validation,
                                    NamePool pool)
                             throws XPathException
Get a Receiver that can be used to validate an element, and that passes the validated element on to a target receiver. If validation is not supported, the returned receiver will be the target receiver.

Overrides:
getElementValidator in class Configuration
Parameters:
out - the target receiver to receive the validated element
nameCode - the nameCode of the element to be validated. This must correspond to the name of an element declaration in a loaded schema
schemaType - the schema type (typically a complex type) against which the element is to be validated
validation - The validation mode, for example Validation.STRICT or Validation.LAX
pool - The name pool
Returns:
The newly created receiver, which performs the validation and passes the validated elements on to the target receiver.
Throws:
XPathException

validateAttribute

public int validateAttribute(int nameCode,
                             java.lang.CharSequence value,
                             int validation)
                      throws ValidationException
Validate an attribute value (XSLT only)

Overrides:
validateAttribute in class Configuration
Parameters:
nameCode - the name of the attribute
value - the value of the attribute as a string
validation - STRICT or LAX
Returns:
an int, containing the type annotation to apply to the attribute node
Throws:
ValidationException - if the value is invalid

getAnnotationStripper

public Receiver getAnnotationStripper(Receiver destination)
Add to a pipeline a receiver that strips all type annotations. This has a null implementation in the Saxon-B product, because type annotations can never arise.

Overrides:
getAnnotationStripper in class Configuration

makeSubstitutionGroupTest

public NodeTest makeSubstitutionGroupTest(SchemaDeclaration elementDecl)
Make a test for elements corresponding to a given element declaration

Overrides:
makeSubstitutionGroupTest in class Configuration

getVendorFunctionLibrary

public VendorFunctionLibrary getVendorFunctionLibrary()
Get the FunctionLibrary used to bind calls on Saxon-defined extension functions

Overrides:
getVendorFunctionLibrary in class Configuration

getOptimizer

public Optimizer getOptimizer()
Factory method to get an Optimizer

Overrides:
getOptimizer in class Configuration

resolveSource

public javax.xml.transform.Source resolveSource(javax.xml.transform.Source source,
                                                Configuration config)
                                         throws XPathException
Implement the SourceResolver interface

Specified by:
resolveSource in interface SourceResolver
Overrides:
resolveSource in class Configuration
Throws:
XPathException

getOutputMethod

public Receiver getOutputMethod(java.lang.String clarkName)
Get a configuration-defined output method.

Overrides:
getOutputMethod in class Configuration
Returns:
a Receiver that implements the method, or null if the method URI is not recognized