Class ValidatorImpl
- java.lang.Object
-
- javax.xml.validation.Validator
-
- com.saxonica.ee.jaxp.ValidatorImpl
-
public class ValidatorImpl extends javax.xml.validation.ValidatorThis class in the Saxon implementation of the JAXP 1.3 Validator "interface" (which is actually defined as an abstract class). It is used to validate a source document against a schema.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classValidatorImpl.InvalidityHandlerWrappingErrorHandlerInterface for reporting validation errors found during validation of an instance document against a schema.
-
Constructor Summary
Constructors Constructor Description ValidatorImpl(PipelineConfiguration pipe, PreparedSchema schema)Create the Validator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationgetConfiguration()Get the underlying Saxon Configuration objectorg.xml.sax.ErrorHandlergetErrorHandler()Gets the currentErrorHandlerset to thisValidator.java.lang.ObjectgetProperty(java.lang.String name)Look up the value of a property.org.w3c.dom.ls.LSResourceResolvergetResourceResolver()Gets the currentLSResourceResolvervoidreset()voidsetErrorHandler(org.xml.sax.ErrorHandler errorHandler)Sets theErrorHandlerto receive errors encountered during thevalidatemethod invocation.voidsetProperty(java.lang.String name, java.lang.Object object)Set the value of a property.voidsetResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)Sets theLSResourceResolverto customize resource resolution while in a validation episode.voidvalidate(javax.xml.transform.Source source, javax.xml.transform.Result result)
-
-
-
Constructor Detail
-
ValidatorImpl
public ValidatorImpl(PipelineConfiguration pipe, PreparedSchema schema)
Create the Validator- Parameters:
pipe- the pipeline configurationschema- the schema against which validation takes place
-
-
Method Detail
-
reset
public void reset()
- Specified by:
resetin classjavax.xml.validation.Validator
-
validate
public void validate(javax.xml.transform.Source source, javax.xml.transform.Result result) throws org.xml.sax.SAXException, java.io.IOException- Specified by:
validatein classjavax.xml.validation.Validator- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Sets theErrorHandlerto receive errors encountered during thevalidatemethod invocation.Error handler can be used to customize the error handling process during a validation. When an
ErrorHandleris set, errors found during the validation will be first sent to theErrorHandler.The error handler can abort further validation immediately by throwing
SAXExceptionfrom the handler. Or for example it can print an error to the screen and try to continue the validation by returning normally from theErrorHandlerIf any
Throwableis thrown from anErrorHandler, the caller of thevalidatemethod will be thrown the sameThrowableobject.Validatoris not allowed to throwSAXExceptionwithout first reporting it toErrorHandler.When the
ErrorHandleris null, the implementation will behave as if the followingErrorHandleris set:class DraconianErrorHandler implements
ErrorHandler{ public void fatalError(SAXParseExceptione ) throwsSAXException{ throw e; } public void error(SAXParseExceptione ) throwsSAXException{ throw e; } public void warning(SAXParseExceptione ) throwsSAXException{ // noop } }When a new
Validatorobject is created, initially this field is set to null.- Specified by:
setErrorHandlerin classjavax.xml.validation.Validator- Parameters:
errorHandler- A new error handler to be set. This parameter can be null.
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Gets the currentErrorHandlerset to thisValidator.- Specified by:
getErrorHandlerin classjavax.xml.validation.Validator- 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 thisValidatorhas created. - See Also:
setErrorHandler(ErrorHandler)
-
setResourceResolver
public void setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)
Sets theLSResourceResolverto customize resource resolution while in a validation episode.- Specified by:
setResourceResolverin classjavax.xml.validation.Validator- Parameters:
resourceResolver- A new resource resolver to be set. This parameter can be null.
-
getResourceResolver
public org.w3c.dom.ls.LSResourceResolver getResourceResolver()
Gets the currentLSResourceResolver- Specified by:
getResourceResolverin classjavax.xml.validation.Validator- 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
public Configuration getConfiguration()
Get the underlying Saxon Configuration object- Returns:
- the Saxon Configuration
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionLook up the value of a property.The property name is any fully-qualified URI. It is possible for a
Validatorto 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.Validators 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:XMLConstants.FEATURE_SECURE_PROCESSINGXMLConstants.ACCESS_EXTERNAL_DTDXMLConstants.ACCESS_EXTERNAL_SCHEMA
- Overrides:
getPropertyin classjavax.xml.validation.Validator- Parameters:
name- The property name, which is a non-null fully-qualified URI.- Returns:
- The current value of the property.
- Throws:
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.- See Also:
setProperty(String, Object)
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object object) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSet the value of a property.The property name is any fully-qualified URI. It is possible for a
Validatorto 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:XMLConstants.FEATURE_SECURE_PROCESSINGXMLConstants.ACCESS_EXTERNAL_DTDXMLConstants.ACCESS_EXTERNAL_SCHEMA
- Overrides:
setPropertyin classjavax.xml.validation.Validator- Parameters:
name- The property name, which is a non-null fully-qualified URI.object- The requested value for the property.- Throws:
org.xml.sax.SAXNotRecognizedException- If the property value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException- When theValidatorrecognizes the property name but cannot set the requested value.java.lang.NullPointerException- When the name parameter is null.
-
-