|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.Configuration com.saxonica.validate.SchemaAwareConfiguration
public final class SchemaAwareConfiguration
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
.
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, RECOVER_SILENTLY, RECOVER_WITH_WARNINGS, XML_SCHEMA, XML10, XML11, XPATH, XQUERY, XSLT |
Constructor Summary | |
---|---|
SchemaAwareConfiguration()
Create a SchemaAwareConfiguration |
Method Summary | |
---|---|
void |
addSchema(PreparedSchema pschema)
Add a schema to the cache |
void |
addSchemaSource(Source schemaSource,
ErrorListener errorListener)
Load a schema, which will be available for use by all subsequent operations using this SchemaAwareConfiguration. |
void |
addSurrogateSchema(String namespace)
Put a temporary schema marker in the cache, to indicate that a schema for a given namespace is being processed. |
DocumentInfo |
buildDocument(Source source)
Build a document tree, using options set on this Configuration and on the supplied source object. |
void |
checkTypeDerivationIsOK(SchemaType derived,
SchemaType base,
int block)
Check that a type is validly derived from another type, following the rules for the Schema Component Constraint "Is Type Derivation OK (Simple)" (3.14.6) or "Is Type Derivation OK (Complex)" (3.4.6) as appropriate. |
Configuration |
copy()
Copy an existing Configuration to create a new Configuration. |
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,
String systemId,
int validationMode,
int stripSpace,
SchemaType schemaType,
int topLevelElementName)
Get a document-level validator to add to a Receiver pipeline |
SchemaDeclaration |
getElementDeclaration(int fingerprint)
Get a global element declaration |
SequenceReceiver |
getElementValidator(SequenceReceiver receiver,
int nameCode,
int locationId,
SchemaType schemaType,
int validation)
Get a Receiver that can be used to validate an element, and that passes the validated element on to a target receiver. |
ErrorListener |
getErrorListener()
Get the ErrorListener to which errors are reported |
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 |
String |
getProductTitle()
Get a message used to identify this product when a transformation is run using the -t option |
PreparedSchema |
getSchema(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 |
isSchemaAvailable(String targetNamespace)
Determine whether the Configuration contains a cached schema for a given target namespace |
boolean |
isSchemaAware(int language)
Determine if the configuration is schema-aware |
boolean |
isSealedNamespace(String namespace)
Test whether a schema namespace is sealed. |
ProxyReceiver |
makeDocumentProjector(PathMap.PathMapRoot map)
Create a document projector for a given path map. |
Receiver |
makeEmitter(String clarkName,
Controller controller)
Get a configuration-defined output method. |
SchemaCompiler |
newSchemaCompiler()
Make a SchemaCompiler which can be used to compile schema documents. |
String |
readInlineSchema(NodeInfo root,
String expected,
ErrorListener errorListener)
Read an inline schema from a stylesheet |
void |
readMultipleSchemas(PipelineConfiguration pipe,
String baseURI,
List schemaLocations,
String expected)
Read schemas from a list of schema locations |
String |
readSchema(PipelineConfiguration pipe,
String baseURI,
String schemaLocation,
String expected)
Read a schema from a given schema location |
void |
removeSchema(String namespace)
Remove the schema for a given namespace. |
Source |
resolveSource(Source source,
Configuration config)
Implement the SourceResolver interface |
void |
sealNamespace(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 |
setParameterizedURIResolver()
Set the URIResolver to a URI resolver that allows query parameters after the URI, and in the case of Saxon-SA, that inteprets the file extension .ptree |
void |
supplyLicenseKey(BufferedReader reader)
This method allows the contents of a license key to be supplied programmatically. |
int |
validateAttribute(int nameCode,
CharSequence value,
int validation)
Validate an attribute value (XSLT only) |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SchemaAwareConfiguration()
Method Detail |
---|
public Configuration copy()
Note that creating a new SchemaAwareConfiguration using this method can be significantly cheaper than creating one from scratch, because it avoids the need to verify the Saxon-SA license key if this has already been done.
copy
in class Configuration
public void supplyLicenseKey(BufferedReader reader)
reader
- A reader that will be used to read the contents of the license file
(for example, a StringReader)
IllegalArgumentException
- if the key supplied is not a valid OEM license keypublic String getProductTitle()
getProductTitle
in class Configuration
public final boolean isSchemaAware(int language)
isSchemaAware
in class Configuration
language
- the processing language for which schema-aware processing is required
public void displayLicenseMessage()
displayLicenseMessage
in class Configuration
public void setParameterizedURIResolver()
setParameterizedURIResolver
in class Configuration
public ErrorListener getErrorListener()
getErrorListener
in class Configuration
public SchemaCompiler newSchemaCompiler()
public void setOccurrenceLimits(int minimum, int maximum)
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.public int[] getOccurrenceLimits()
public SchemaURIResolver getSchemaURIResolver()
getSchemaURIResolver
in class Configuration
public String readSchema(PipelineConfiguration pipe, String baseURI, String schemaLocation, String expected) throws SchemaException
readSchema
in class Configuration
pipe
- the PipelineConfigurationbaseURI
- the base URI for resolving relative URIsschemaLocation
- the location "hint" where to find the schema document. Must not be null.expected
- the target namespace expected; null if there is no
expectation
SchemaException
public void readMultipleSchemas(PipelineConfiguration pipe, String baseURI, List schemaLocations, String expected) throws SchemaException
readMultipleSchemas
in class Configuration
pipe
- the pipeline configurationbaseURI
- the base URI for resolving relative URIsschemaLocations
- 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
expectation
SchemaException
public String readInlineSchema(NodeInfo root, String expected, ErrorListener errorListener) throws SchemaException
readInlineSchema
in class Configuration
root
- the xs:schema element in the stylesheetexpected
- the target namespace expected; "" if there is no
expectationerrorListener
- The destination for error messages. May be null, in which case
the errorListener registered with this Configuration is used.
SchemaException
public void addSchemaSource(Source schemaSource, ErrorListener errorListener) throws SchemaException
addSchemaSource
in class Configuration
schemaSource
- the JAXP Source object identifying the schema document to be loadederrorListener
- the ErrorListener to be notified of any errors in the schema. If null,
the configuration's errorListener is used
SchemaException
- if the schema cannot be read or parsed or if it is invalidpublic void addSchema(PreparedSchema pschema) throws SchemaException
pschema
- The schema
SchemaException
public void addSurrogateSchema(String namespace)
namespace
- the target namespace of the schemapublic PreparedSchema getSchema(String namespace)
namespace
- the target namespace of the required schema
public boolean isSchemaAvailable(String targetNamespace)
isSchemaAvailable
in class Configuration
targetNamespace
- the target namespace of the schema being sought (supply "" for the
unnamed namespace)
public void removeSchema(String namespace)
namespace
- the namespace of the schema to be removedpublic Set getImportedNamespaces()
getImportedNamespaces
in class Configuration
public PreparedSchema getSuperSchema()
public void sealNamespace(String namespace)
sealNamespace
in class Configuration
namespace
- the namespace URI of the components to be sealedpublic boolean isSealedNamespace(String namespace)
namespace
- the namespace URI of the components to be tested
public SchemaDeclaration getElementDeclaration(int fingerprint)
getElementDeclaration
in class Configuration
fingerprint
- the NamePool fingerprint of the name of the required
element declaration
public SchemaDeclaration getAttributeDeclaration(int fingerprint)
getAttributeDeclaration
in class Configuration
fingerprint
- the namepool fingerprint of the required attribute
declaration
public SchemaType getSchemaType(int fingerprint)
getSchemaType
in class Configuration
fingerprint
- the fingerprint of the schema type
public void checkTypeDerivationIsOK(SchemaType derived, SchemaType base, int block) throws SchemaException
checkTypeDerivationIsOK
in class Configuration
derived
- the derived typebase
- the base type; the algorithm tests whether derivation from this type is permittedblock
- the derivations that are blocked by the relevant element declaration
SchemaException
- if the derivation is not allowedpublic Receiver getDocumentValidator(Receiver receiver, String systemId, int validationMode, int stripSpace, SchemaType schemaType, int topLevelElementName)
getDocumentValidator
in class Configuration
receiver
- The receiver to which events should be sent after validationsystemId
- the base URI of the document being validatedvalidationMode
- for example Validation.STRICT or Validation.STRIP. The integer may
also have the bit Validation.VALIDATE_OUTPUT set, indicating that the stream being validated
is to be treated as a final output stream (which means multiple errors can be reported)stripSpace
- if set to Whitespace.IGNORABLE, causes whitespace in element-only
content to be stripped after validation. Default is taken from the Configuration settings.schemaType
- The type against which the outermost element of the document must be validated
(null if there is no constraint)topLevelElementName
- the fingerprint of the required name for the top-level element
being validated
public SequenceReceiver getElementValidator(SequenceReceiver receiver, int nameCode, int locationId, SchemaType schemaType, int validation) throws XPathException
getElementValidator
in class Configuration
receiver
- the target receiver to receive the validated elementnameCode
- the nameCode of the element to be validated. This should be set to -1 if
validation against a specific type is required (in which case schemaType must not be null).
Otherwise, the namecode must correspond to the name of an element declaration in a loaded schemalocationId
- identifies the location of the element within its source document (or, if
preferred, the location of the instruction requesting validation)schemaType
- the schema type (typically a complex type) against which the element is to
be validated. Supply null if there are no constraints, that is, if validation is to start from
the element declaration.validation
- The validation mode, for example Validation.STRICT or Validation.LAX
XPathException
public int validateAttribute(int nameCode, CharSequence value, int validation) throws ValidationException
validateAttribute
in class Configuration
nameCode
- the name of the attributevalue
- the value of the attribute as a stringvalidation
- STRICT or LAX
ValidationException
- if the value is invalidpublic Receiver getAnnotationStripper(Receiver destination)
getAnnotationStripper
in class Configuration
destination
- the Receiver that events will be written to after whitespace stripping
public VendorFunctionLibrary getVendorFunctionLibrary()
getVendorFunctionLibrary
in class Configuration
public DocumentInfo buildDocument(Source source) throws XPathException
buildDocument
in class Configuration
source
- the Source to be used. This may be an AugmentedSource
, allowing options
to be specified for the way in which this document will be built.
A new tree will be built, using either the Tiny Tree or the Linked Tree implementation, except under the following circumstances:
DocumentWrapper
, except in the case where the DOM Document node
is a DocumentOverNodeInfo
, in which case the DocumentInfo that it wraps is
returned.The choice between a tiny tree and a linked tree is determined first be the properties of the AugmentedSource if that's what is supplied; otherwise by the properties of this Configuration.
XPathException
- if any errors occur during document parsing or validation. Detailed
errors occurring during schema validation will be written to the ErrorListener associated
with the AugmentedSource, if supplied, or with the Configuration otherwise.public ProxyReceiver makeDocumentProjector(PathMap.PathMapRoot map)
makeDocumentProjector
in class Configuration
map
- the path map used to control document projection
public Optimizer getOptimizer()
getOptimizer
in class Configuration
public Source resolveSource(Source source, Configuration config) throws XPathException
resolveSource
in interface SourceResolver
resolveSource
in class Configuration
source
- A source object, typically the source supplied as the first
argument to Transformer.transform(javax.xml.transform.Source, javax.xml.transform.Result)
or similar methods.config
- The Configuration. This provides the SourceResolver with access to
configuration information; it also allows the SourceResolver to invoke the
resolveSource() method on the Configuration object as a fallback implementation.
AugmentedSource
,
NodeInfo
,
or PullSource
. Return null if the Source object is not
recognized
XPathException
- if the Source object is recognized but cannot be processedpublic Receiver makeEmitter(String clarkName, Controller controller) throws XPathException
makeEmitter
in class Configuration
clarkName
- the QName of the user-supplied ContentHandler (requested as a prefixed
value of the method attribute in xsl:output, or anywhere that serialization parameters
are allowed), encoded in Clark format as {uri}localcontroller
- the Controller. Allows a local class loader to be used.
XPathException
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |