Class ValidatorImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Interface for reporting validation errors found during validation of an instance document against a schema. -
Constructor Summary
ConstructorsConstructorDescriptionValidatorImpl
(PipelineConfiguration pipe, PreparedSchema schema) Create the Validator -
Method Summary
Modifier and TypeMethodDescriptionGet the underlying Saxon Configuration objectGets the currentErrorHandler
set to thisValidator
.getProperty
(String name) Look up the value of a property.Gets the currentLSResourceResolver
void
reset()
void
setErrorHandler
(ErrorHandler errorHandler) Sets theErrorHandler
to receive errors encountered during thevalidate
method invocation.void
setProperty
(String name, Object object) Set the value of a property.void
setResourceResolver
(LSResourceResolver resourceResolver) Sets theLSResourceResolver
to customize resource resolution while in a validation episode.void
Validate a source document, sending the validated output to a specified destination.Methods inherited from class javax.xml.validation.Validator
getFeature, setFeature, validate
-
Constructor Details
-
ValidatorImpl
Create the Validator- Parameters:
pipe
- the pipeline configurationschema
- the schema against which validation takes place
-
-
Method Details
-
reset
public void reset() -
validate
Validate a source document, sending the validated output to a specified destination. Note that unlike the abstract parent method, this implementation imposes no restrictions on the type of the source and result: any kind of source can be used with any kind of result.- Specified by:
validate
in classValidator
- Parameters:
source
- XML to be validated. Must be an XML document or XML element and must not be null.result
- TheResult
object that receives (possibly augmented) XML. This parameter can be null if the caller is not interested in it.- Throws:
SAXException
IOException
-
setErrorHandler
Sets theErrorHandler
to receive errors encountered during thevalidate
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 theErrorHandler
.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 theErrorHandler
If any
Throwable
is thrown from anErrorHandler
, the caller of thevalidate
method will be thrown the sameThrowable
object.Validator
is not allowed to throwSAXException
without first reporting it toErrorHandler
.When the
ErrorHandler
is null, the implementation will behave as if the followingErrorHandler
is set:class DraconianErrorHandler implements
ErrorHandler
{ 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.- Specified by:
setErrorHandler
in classValidator
- Parameters:
errorHandler
- A new error handler to be set. This parameter can be null.
-
getErrorHandler
Gets the currentErrorHandler
set to thisValidator
.- Specified by:
getErrorHandler
in classValidator
- Returns:
- This method returns the object that was last set through
the
setErrorHandler(ErrorHandler)
method, or null if that method has never been called since thisValidator
has created. - See Also:
-
setResourceResolver
Sets theLSResourceResolver
to customize resource resolution while in a validation episode.- Specified by:
setResourceResolver
in classValidator
- Parameters:
resourceResolver
- A new resource resolver to be set. This parameter can be null.
-
getResourceResolver
Gets the currentLSResourceResolver
- Specified by:
getResourceResolver
in classValidator
- Returns:
- This method returns the object that was last set through
the
setResourceResolver(org.w3c.dom.ls.LSResourceResolver)
method, or null if that method has never been called
-
getConfiguration
Get the underlying Saxon Configuration object- Returns:
- the Saxon Configuration
-
getProperty
Look up the value of a property.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 classFeatureKeys
. In addition, the following properties are recognized:- Overrides:
getProperty
in classValidator
- Parameters:
name
- The property name, which is a non-null fully-qualified URI.- Returns:
- The current value of the property.
- Throws:
SAXNotRecognizedException
- If the property value can't be assigned or retrieved.SAXNotSupportedException
- When the XMLReader recognizes the property name but cannot determine its value at this time.NullPointerException
- When the name parameter is null.- See Also:
-
setProperty
public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException Set the value of a property.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 classFeatureKeys
. In addition, the following properties are recognized, and passed directly to the underlying XML parser:- Overrides:
setProperty
in classValidator
- Parameters:
name
- The property name, which is a non-null fully-qualified URI.object
- The requested value for the property.- Throws:
SAXNotRecognizedException
- If the property value can't be assigned or retrieved.SAXNotSupportedException
- When theValidator
recognizes the property name but cannot set the requested value.NullPointerException
- When the name parameter is null.
-