|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.saxonica.schema.SchemaCompiler
public class SchemaCompiler
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 EnterpriseConfiguration
Constructor Summary | |
---|---|
SchemaCompiler(EnterpriseConfiguration config)
Create a SchemaCompiler |
Method Summary | |
---|---|
void |
addPendingTypeCheck(IdentityConstraintReference constraint,
SchemaType contextItemType)
Register an identity constraint that needs to be type-checked |
void |
addSchemaSource(Source schemaSource)
Load a schema, which will be available for use by all subsequent operations using this Configuration. |
void |
addSchemaSource(Source schemaSource,
ErrorListener errorListener)
Load a schema, which will be available for use by all subsequent operations using this EnterpriseConfiguration. |
void |
compile()
In deferred validation mode, validate and compile the accumulated schema components. |
void |
error(String message,
SourceLocator locator)
Report an error |
EnterpriseConfiguration |
getConfiguration()
Get the configuration |
int |
getErrorCount()
Test whether errors have been reported |
ErrorListener |
getErrorListener()
Get the ErrorListener used in this configuration. |
XSDSchema |
getExistingSchemaDocument(String systemId,
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(String systemId)
Determine whether a particular URI is currently being read |
boolean |
isDeferredValidationMode()
Ask if deferred validation mode is currently set |
void |
markAsRead(String systemId,
XSDSchema schema)
Mark a document as having been read |
String |
readInlineSchema(NodeInfo root,
String expected,
ErrorListener errorListener)
Read an inline schema from a stylesheet |
void |
readMultipleSchemas(PipelineConfiguration pipe,
String baseURI,
Collection schemaLocations,
String expected)
Read schemas from a list of schema locations |
String |
readSchema(PipelineConfiguration pipe,
String baseURI,
String schemaLocation,
String expected)
Read a schema document from a given schema location. |
void |
setBeingRead(String systemId)
Mark a URI as currently being read |
void |
setDeferredValidationMode(boolean defer)
Set deferred validation mode. |
void |
setErrorListener(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(String message,
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 |
---|
public SchemaCompiler(EnterpriseConfiguration config)
config
- the Saxon ConfigurationMethod Detail |
---|
public EnterpriseConfiguration getConfiguration()
public NamePool getNamePool()
public void setLanguageVersion(int version)
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
public int getLanguageVersion()
Configuration.XSD10
; to use facilities in XML Schema 1.1, the
value must be set to Configuration.XSD11
public void setDeferredValidationMode(boolean defer)
defer
- set to true to select deferred validation modepublic boolean isDeferredValidationMode()
public void setPreparedSchema(PreparedSchema schema)
schema
- the schema that has been loadedpublic PreparedSchema getPreparedSchema()
public ErrorListener getErrorListener()
public void setErrorListener(ErrorListener listener)
listener
- the ErrorListener to be usedpublic int getErrorCount()
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 void setBeingRead(String systemId)
systemId
- the URI of the schema document being readpublic boolean isBeingRead(String systemId)
systemId
- the URI of the document in question
public void markAsRead(String systemId, XSDSchema schema)
systemId
- the URI of the schema document that has been readschema
- the root element of the schema document contstructed from this URIpublic XSDSchema getExistingSchemaDocument(String systemId, String targetNamespace)
systemId
- the URI of the required schema documenttargetNamespace
- the expected namespace. If the schema document was previously read
but chameleoned into a different namespace, we read it again
public PipelineConfiguration getPipelineConfiguration()
public void setPipelineConfiguration(PipelineConfiguration pipelineConfiguration)
pipelineConfiguration
- the pipeline configurationpublic SchemaURIResolver getSchemaURIResolver()
public void addSchemaSource(Source schemaSource) throws SchemaException
schemaSource
- the JAXP Source object identifying the schema document to be loaded
SchemaException
- if the schema cannot be read or parsed or if it is invalid
UnsupportedOperationException
- if the configuration is not schema-awarepublic void addSchemaSource(Source schemaSource, ErrorListener errorListener) throws SchemaException
schemaSource
- the JAXP Source object identifying the schema document to be loadederrorListener
- the ErrorListener to be notified of any errors in the schema.
SchemaException
- if the schema cannot be read or parsed or if it is invalidpublic String readSchema(PipelineConfiguration pipe, String baseURI, String schemaLocation, String expected) throws SchemaException
pipe
- the pipeline configurationbaseURI
- 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, Collection schemaLocations, String expected) throws SchemaException
pipe
- the PipelineConfigurationbaseURI
- 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
expected namespace
SchemaException
public String readInlineSchema(NodeInfo root, String expected, ErrorListener errorListener) throws SchemaException
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 compile() throws SchemaException
SchemaException
- if any of the schema components is invalid, or if the collection of
schema components as a whole is invalid, or if there are components present that conflict with components
alread present in the cache held by the Configuration.public PreparedSchema validate(SchemaDocument doc) throws SchemaException
doc
- the schema document to be validated
SchemaException
- if the schema is invalidpublic void error(String message, SourceLocator locator) throws SchemaException
message
- the error messagelocator
- the location of the error
SchemaException
public void warning(String message, SourceLocator locator)
message
- the warning messagelocator
- the location of the errorpublic void addPendingTypeCheck(IdentityConstraintReference constraint, SchemaType contextItemType)
constraint
- the constraint to be checkedcontextItemType
- the type of the context node for the XPath expression to be checkedpublic void typeCheckIdentityConstraints() throws SchemaException
SchemaException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |