public class SchemaCompiler extends java.lang.Object implements ISchemaCompiler
A default SchemaCompiler is available as part of the EnterpriseConfiguration
Constructor and Description |
---|
SchemaCompiler(EnterpriseConfiguration config)
Create a SchemaCompiler
|
Modifier and Type | Method and Description |
---|---|
void |
addPendingTypeCheck(IdentityConstraintReference constraint,
SchemaType contextItemType)
Register an identity constraint that needs to be type-checked
|
void |
compile()
y
In deferred validation mode, validate and compile the accumulated schema components.
|
SchemaDocument |
doChameleonTransformation(javax.xml.transform.Source input,
SchemaElement referrer)
Do the chameleon transformation on a source schema document
|
SchemaDocument |
doOverrideTransformation(javax.xml.transform.Source input,
SchemaElement referrer)
Do the override transformation on a source schema document
|
void |
error(java.lang.String message,
Location locator)
Report an error
|
EnterpriseConfiguration |
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
|
NamespaceResolver |
makeNamespaceResolver(NodeInfo node)
Make a namespace resolver for a particular element in the schema.
|
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<java.lang.String> 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.
|
boolean |
reportMissingComponent(java.lang.String componentType,
StructuredQName componentName)
Register that there is an unresolved component reference
|
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,
Location locator)
Report a warning
|
public SchemaCompiler(EnterpriseConfiguration config)
config
- the Saxon Configurationpublic 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 javax.xml.transform.ErrorListener getErrorListener()
public void setErrorListener(javax.xml.transform.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(java.lang.String systemId)
systemId
- the URI of the schema document being readpublic boolean isBeingRead(java.lang.String systemId)
systemId
- the URI of the document in questionpublic void markAsRead(java.lang.String systemId, XSDSchema schema)
systemId
- the URI of the schema document that has been readschema
- the root element of the schema document constructed from this URIpublic XSDSchema getExistingSchemaDocument(java.lang.String systemId, java.lang.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 againpublic PipelineConfiguration getPipelineConfiguration()
public void setPipelineConfiguration(PipelineConfiguration pipelineConfiguration)
pipelineConfiguration
- the pipeline configurationpublic SchemaURIResolver getSchemaURIResolver()
public java.lang.String readSchema(PipelineConfiguration pipe, java.lang.String baseURI, java.lang.String schemaLocation, java.lang.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
expectationSchemaException
public void readMultipleSchemas(PipelineConfiguration pipe, java.lang.String baseURI, java.util.Collection<java.lang.String> schemaLocations, java.lang.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 namespaceSchemaException
- if reading a schema document failspublic java.lang.String readInlineSchema(NodeInfo root, java.lang.String expected, javax.xml.transform.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
- if the inline schema is in errorpublic 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
already present in the cache held by the Configuration.public PreparedSchema validate(SchemaDocument doc) throws SchemaException
doc
- the schema document to be validatedSchemaException
- if the schema is invalidpublic boolean reportMissingComponent(java.lang.String componentType, StructuredQName componentName)
componentType
- the type of component, for example attributeGroupcomponentName
- the name of the componentpublic void error(java.lang.String message, Location locator) throws SchemaException
message
- the error messagelocator
- the location of the errorSchemaException
- if the supplied ErrorListener throws an exceptionpublic void warning(java.lang.String message, Location 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
- if any of the checks failpublic SchemaDocument doChameleonTransformation(javax.xml.transform.Source input, SchemaElement referrer) throws SchemaException
input
- the included schema document to be transformeedreferrer
- the xs:include element referencing this schema documentSchemaException
- if the transformation failspublic SchemaDocument doOverrideTransformation(javax.xml.transform.Source input, SchemaElement referrer) throws SchemaException
input
- the schema document being overriddenreferrer
- the xs:override element referencing this schema documentSchemaException
- if the transformation failspublic NamespaceResolver makeNamespaceResolver(NodeInfo node)
node
- the node in the schema document whose namespace context is requiredCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.