public class ValidatorImpl
extends javax.xml.validation.Validator
Modifier and Type | Class and Description |
---|---|
class |
ValidatorImpl.InvalidityHandlerWrappingErrorHandler
Interface for reporting validation errors found during validation of an instance document
against a schema.
|
Constructor and Description |
---|
ValidatorImpl(PipelineConfiguration pipe,
PreparedSchema schema)
Create the Validator
|
Modifier and Type | Method and Description |
---|---|
Configuration |
getConfiguration()
Get the underlying Saxon Configuration object
|
org.xml.sax.ErrorHandler |
getErrorHandler()
Gets the current
ErrorHandler set to this Validator . |
java.lang.Object |
getProperty(java.lang.String name)
Look up the value of a property.
|
org.w3c.dom.ls.LSResourceResolver |
getResourceResolver()
Gets the current
LSResourceResolver |
void |
reset() |
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Sets the
ErrorHandler to receive errors encountered
during the validate method invocation. |
void |
setProperty(java.lang.String name,
java.lang.Object object)
Set the value of a property.
|
void |
setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)
Sets the
LSResourceResolver to customize
resource resolution while in a validation episode. |
void |
validate(javax.xml.transform.Source source,
javax.xml.transform.Result result) |
public ValidatorImpl(PipelineConfiguration pipe, PreparedSchema schema)
pipe
- the pipeline configurationschema
- the schema against which validation takes placepublic void reset()
reset
in class javax.xml.validation.Validator
public void validate(javax.xml.transform.Source source, javax.xml.transform.Result result) throws org.xml.sax.SAXException, java.io.IOException
validate
in class javax.xml.validation.Validator
org.xml.sax.SAXException
java.io.IOException
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
ErrorHandler
to receive errors encountered
during the validate
method invocation.
Error handler can be used to customize the error handling process
during a validation. When an ErrorHandler
is set,
errors found during the validation will be first sent
to the ErrorHandler
.
The error handler can abort further validation immediately
by throwing SAXException
from the handler. Or for example
it can print an error to the screen and try to continue the
validation by returning normally from the ErrorHandler
If any Throwable
is thrown from an ErrorHandler
,
the caller of the validate
method will be thrown
the same Throwable
object.
Validator
is not allowed to
throw SAXException
without first reporting it to
ErrorHandler
.
When the ErrorHandler
is null, the implementation will
behave as if the following ErrorHandler
is set:
class DraconianErrorHandler implementsErrorHandler
{ public void fatalError(SAXParseException
e ) throwsSAXException
{ throw e; } public void error(SAXParseException
e ) throwsSAXException
{ throw e; } public void warning(SAXParseException
e ) throwsSAXException
{ // noop } }
When a new Validator
object is created, initially
this field is set to null.
setErrorHandler
in class javax.xml.validation.Validator
errorHandler
- A new error handler to be set. This parameter can be null.public org.xml.sax.ErrorHandler getErrorHandler()
ErrorHandler
set to this Validator
.getErrorHandler
in class javax.xml.validation.Validator
setErrorHandler(ErrorHandler)
method, or null
if that method has never been called since this Validator
has created.setErrorHandler(ErrorHandler)
public void setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)
LSResourceResolver
to customize
resource resolution while in a validation episode.setResourceResolver
in class javax.xml.validation.Validator
resourceResolver
- A new resource resolver to be set. This parameter can be null.public org.w3c.dom.ls.LSResourceResolver getResourceResolver()
LSResourceResolver
getResourceResolver
in class javax.xml.validation.Validator
setResourceResolver(org.w3c.dom.ls.LSResourceResolver)
method, or null
if that method has never been calledpublic Configuration getConfiguration()
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 Validator
to recognize a property name but
temporarily be unable to return its value.
Some property values may be available only in specific
contexts, such as before, during, or after a validation.
Validator
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
. In addition, the following properties
are recognized:
XMLConstants.FEATURE_SECURE_PROCESSING
XMLConstants.ACCESS_EXTERNAL_DTD
XMLConstants.ACCESS_EXTERNAL_SCHEMA
getProperty
in class javax.xml.validation.Validator
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
- When 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 Validator
to recognize a property name but
to be unable to change the current value.
Some property values may be immutable or mutable only
in specific contexts, such as before, during, or after
a validation.
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
. In addition, the following properties
are recognized, and passed directly to the underlying XML parser:
XMLConstants.FEATURE_SECURE_PROCESSING
XMLConstants.ACCESS_EXTERNAL_DTD
XMLConstants.ACCESS_EXTERNAL_SCHEMA
setProperty
in class javax.xml.validation.Validator
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
Validator
recognizes the property name but
cannot set the requested value.java.lang.NullPointerException
- When the name parameter is null.Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.