public class SchemaFactoryImpl
extends javax.xml.validation.SchemaFactory
Modifier and Type | Class and Description |
---|---|
static class |
SchemaFactoryImpl.ErrorListenerWrappingErrorHandler
A JAXP ErrorListener that wraps a SAX ErrorHandler
|
Modifier and Type | Field and Description |
---|---|
static boolean |
ENABLED
A mutable static variable (horrible but useful) allowing the use of this SchemaFactory to
be disabled.
|
static java.lang.String |
XSD_LANGUAGE_IDENTIFIER |
static java.lang.String |
XSD10_LANGUAGE_IDENTIFIER |
static java.lang.String |
XSD11_LANGUAGE_IDENTIFIER |
Constructor and Description |
---|
SchemaFactoryImpl()
Default constructor.
|
SchemaFactoryImpl(EnterpriseConfiguration config)
Constructor supplying an EnterpriseConfiguration
|
Modifier and Type | Method and Description |
---|---|
EnterpriseConfiguration |
getConfiguration()
Get the underlying Saxon Configuration object
|
org.xml.sax.ErrorHandler |
getErrorHandler()
Get the error handler in use
|
boolean |
getFeature(java.lang.String name)
Look up the value of a feature flag.
|
java.lang.Object |
getProperty(java.lang.String name)
Look up the value of a property.
|
org.w3c.dom.ls.LSResourceResolver |
getResourceResolver()
Get the resolver used for dereferencing URIs encountered during schema processing and validation.
|
boolean |
isSchemaLanguageSupported(java.lang.String language)
Tests whether a particular schema language is supported.
|
javax.xml.validation.Schema |
newSchema()
Returns the
Schema object containing all the schema components
that have been loaded using the newSchema(javax.xml.transform.Source[]) method. |
javax.xml.validation.Schema |
newSchema(javax.xml.transform.Source[] sources)
Parses the specified source(s) as a schema and returns it as a schema.
|
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Set an error handler to which all schema processing
errors will be notified.
|
void |
setFeature(java.lang.String name,
boolean value)
Set a feature for this
SchemaFactory . |
void |
setProperty(java.lang.String name,
java.lang.Object object)
Set the value of a property.
|
void |
setResourceResolver(org.w3c.dom.ls.LSResourceResolver lsResourceResolver)
Set a resolver to be used for dereferencing URIs encountered during schema processing and validation.
|
public static final java.lang.String XSD_LANGUAGE_IDENTIFIER
public static final java.lang.String XSD10_LANGUAGE_IDENTIFIER
public static final java.lang.String XSD11_LANGUAGE_IDENTIFIER
public static boolean ENABLED
isSchemaLanguageSupported(String)
, the response will be false,
meaning that Saxon does not get used as the Schema validation provider even though it
is present on the classpath.public SchemaFactoryImpl()
This constructor creates an EnterpriseConfiguration. It does not attempt to load a license file at this stage.
public SchemaFactoryImpl(EnterpriseConfiguration config)
config
- The EnterpriseConfiguration. The method verifies that this is usable by checking that
a license key is available.public boolean isSchemaLanguageSupported(java.lang.String language)
isSchemaLanguageSupported
in class javax.xml.validation.SchemaFactory
language
- URI identifying the language (see JAXP specifications for details).XSD10_LANGUAGE_IDENTIFIER
or
XSD11_LANGUAGE_IDENTIFIER
; otherwise false.
Always returns false if the static variable {#ENABLED} is set to false.
Always returns false if no Saxon Enterprise license can be found.
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
setErrorHandler
in class javax.xml.validation.SchemaFactory
errorHandler
- The requested error handler. Note: unlike releases prior to Saxon 9.6,
this does not change the error listener used by the Configuration.public org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler
in class javax.xml.validation.SchemaFactory
setErrorHandler(org.xml.sax.ErrorHandler)
if available; otherwise
null.public void setResourceResolver(org.w3c.dom.ls.LSResourceResolver lsResourceResolver)
setResourceResolver
in class javax.xml.validation.SchemaFactory
lsResourceResolver
- The resolver to be used. This is wrapped in a URIResolver and registered
with the Configuration, overwriting any URIResolver or SchemaURIResolver that was previously
registered with the Configuration. Equally, any subsequent call on setURIResolver() or
setSchemaURIResolver() on the Configuration object will replace the resolver registered using
this method.public org.w3c.dom.ls.LSResourceResolver getResourceResolver()
getResourceResolver
in class javax.xml.validation.SchemaFactory
public javax.xml.validation.Schema newSchema(javax.xml.transform.Source[] sources) throws org.xml.sax.SAXException
The callee will read all the Source
s and combine them into a
single schema. The exact semantics of the combination depends on the schema
language that this SchemaFactory
object is created for.
When an ErrorHandler
is set, the callee will report all the errors
found in sources to the handler. If the handler throws an exception, it will
abort the schema compilation and the same exception will be thrown from
this method. Also, after an error is reported to a handler, the callee is allowed
to abort the further processing by throwing it. If an error handler is not set,
the callee will throw the first error it finds in the sources.
The resulting schema contains components from the specified sources. The same result would be achieved if all these sources were imported, using appropriate values for schemaLocation and namespace, into a single schema document with a different targetNamespace and no components of its own, if the import elements were given in the same order as the sources. Section 4.2.3 of the XML Schema recommendation describes the options processors have in this regard. While a processor should be consistent in its treatment of JAXP schema sources and XML Schema imports, the behaviour between JAXP-compliant parsers may vary; in particular, parsers may choose to ignore all but the first <import> for a given namespace, regardless of information provided in schemaLocation.
If the parsed set of schemas includes error(s) as
specified in the section 5.1 of the XML Schema spec, then
the error must be reported to the ErrorHandler
.
The Saxon implementation does not support RELAX NG.
newSchema
in class javax.xml.validation.SchemaFactory
sources
- inputs to be parsed as schema documents. The Saxon implementation recognizes not only
the standard SAXSource
,
StreamSource
, and DOMSource
,
but also any implementation of NodeInfo
Schema
object.
Note that when an error has been reported, there is no
guarantee that the returned Schema
object is
meaningful.org.xml.sax.SAXException
- If an error is found during processing the specified inputs.
When an ErrorHandler
is set, errors are reported to
there first. See setErrorHandler(ErrorHandler)
. In the Saxon
implementation, if a SAXException is thrown, it will always wrap
an instance of SchemaException
java.lang.NullPointerException
- If the schemas
parameter itself is null or
any item in the array is null.java.lang.IllegalArgumentException
- If any item in the array is not recognized by this method.public javax.xml.validation.Schema newSchema()
Schema
object containing all the schema components
that have been loaded using the newSchema(javax.xml.transform.Source[])
method. If no schema
components have been loaded, the schema can still be used to validate
source documents provided that they specify the location of the required
schema components using the xsi:schemaLocation attribute.
The returned Schema
object assumes that if documents
refer to the same URL in the schema location hints,
they will always resolve to the same schema document. This
asusmption allows implementations to reuse parsed results of
schema documents so that multiple validations against the same
schema will run faster.
Note that the use of schema location hints introduces a
vulnerability to denial-of-service attacks.newSchema
in class javax.xml.validation.SchemaFactory
Schema
object.public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
The property name is any fully-qualified URI. It is
possible for a SchemaFactory
to recognize a property name but
temporarily be unable to return its value.
SchemaFactory
s are not required to recognize any specific
property names.
In the Saxon implementation, the property names that are recognized are the same as the
attribute names recognised by a TransformerFactory
.
These are listed as constant fields
in the class FeatureKeys
getProperty
in class javax.xml.validation.SchemaFactory
name
- The property name, which is a non-null fully-qualified URI.org.xml.sax.SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException
- When the
XMLReader recognizes the property name but
cannot determine its value at this time.java.lang.NullPointerException
- if the name parameter is null.setProperty(String, Object)
public void setProperty(java.lang.String name, java.lang.Object object) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
The property name is any fully-qualified URI. It is
possible for a SchemaFactory
to recognize a property name but
to be unable to change the current value.
In the Saxon implementation, the property names that are recognized are the same as the
attribute names recognised by a TransformerFactory
.
These are listed as constant fields
in the class FeatureKeys
setProperty
in class javax.xml.validation.SchemaFactory
name
- The property name, which is a non-null fully-qualified URI.object
- The requested value for the property.org.xml.sax.SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException
- When the
SchemaFactory
recognizes the property name but
cannot set the requested value.java.lang.NullPointerException
- if the name parameter is null.public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
Saxon recognizes the feature name XMLConstants.FEATURE_SECURE_PROCESSING, and if this is requested, it returns the value of the Configuration property named as the concatenation of FeatureKeys.XML_PARSER_FEATURE + XMLConstants.FEATURE_SECURE_PROCESSING.
In all other cases Saxon delegates to the superclass, which will generally result in a
SAXNotRecognizedException
.
getFeature
in class javax.xml.validation.SchemaFactory
name
- The feature name, which is a non-null fully-qualified URI.org.xml.sax.SAXNotRecognizedException
- If the feature
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException
- When the
SchemaFactory
recognizes the feature name but
cannot determine its value at this time.java.lang.NullPointerException
- If name
is null
.setFeature(String, boolean)
public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
Set a feature for this SchemaFactory
.
The call is delegated to the superclass except when the feature is XMLConstants.FEATURE_SECURE_PROCESSING
feature.
With this feature, the effect is to set the corresponding parser feature in the Configuration. (It thus affects all
operations under the control of that Configuration, not only schema processing). Setting a parser feature in the Configuration
affects all parsers created by that Configuration, but it does not affect the settings of a user-supplied parser, for example
an XMLReader supplied within a SAXSource object.
Note: in general, the way to set configuration options for Saxon is via the Configuration object, which can be obtained
using the getConfiguration()
method.
setFeature
in class javax.xml.validation.SchemaFactory
name
- The feature name, which is a non-null fully-qualified URI.value
- The requested value of the feature (true or false).org.xml.sax.SAXNotRecognizedException
- If the feature
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException
- When the
SchemaFactory
recognizes the feature name but
cannot set the requested value.java.lang.NullPointerException
- If name
is null
.getFeature(String)
public EnterpriseConfiguration getConfiguration()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.