public class Validator
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ErrorHandler
new Validator(readerForXML);
new Validator(readerForXML, systemIdForValidation);
new Validator(readerForXML, systemIdForValidation, doctypeName);
Modifier | Constructor and Description |
---|---|
|
Validator(org.w3c.dom.Document document,
java.lang.String systemID,
java.lang.String doctype)
DOM-style constructor: allows Document validation post-manipulation
of the DOM tree's contents.
|
|
Validator(org.xml.sax.InputSource sourceForValidation)
Basic constructor.
|
protected |
Validator(org.xml.sax.InputSource inputSource,
boolean usingDoctypeReader)
Deprecated.
Use the protected three arg constructor instead.
|
|
Validator(org.xml.sax.InputSource sourceForValidation,
java.lang.String systemID)
Extended constructor.
|
protected |
Validator(org.xml.sax.InputSource inputSource,
java.lang.String systemId,
boolean usingDoctypeReader)
Baseline constructor: called by all others
|
|
Validator(org.xml.sax.InputSource sourceForValidation,
java.lang.String systemID,
java.lang.String doctype)
Full constructor.
|
|
Validator(java.io.Reader readerForValidation)
Basic constructor.
|
|
Validator(java.io.Reader readerForValidation,
java.lang.String systemID)
Extended constructor.
|
|
Validator(java.io.Reader readerForValidation,
java.lang.String systemID,
java.lang.String doctype)
Full constructor.
|
|
Validator(java.lang.String stringForValidation)
Basic constructor.
|
|
Validator(java.lang.String stringForValidation,
java.lang.String systemID)
Extended constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
assertIsValid()
Assert that a document is valid.
|
void |
error(org.xml.sax.SAXParseException exception)
ErrorHandler interface method.
|
void |
fatalError(org.xml.sax.SAXParseException exception)
ErrorHandler interface method.
|
boolean |
isValid()
Perform the validation of the source against DTD / Schema.
|
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Entity Resolver method: allows us to override an existing systemID
referenced in the markup DOCTYPE instruction.
|
void |
setJAXP12SchemaSource(java.lang.Object schemaSource)
As per JAXP 1.2 changes, which introduced a standard way for parsers to
support schema validation.
|
java.lang.String |
toString() |
void |
useXMLSchema(boolean use)
Turn on XML Schema validation.
|
void |
warning(org.xml.sax.SAXParseException exception)
ErrorHandler interface method.
|
protected Validator(org.xml.sax.InputSource inputSource, boolean usingDoctypeReader) throws org.xml.sax.SAXException, ConfigurationException
org.xml.sax.SAXException
ConfigurationException
protected Validator(org.xml.sax.InputSource inputSource, java.lang.String systemId, boolean usingDoctypeReader) throws org.xml.sax.SAXException, ConfigurationException
inputSource
- systemId
- usingDoctypeReader
- org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned onpublic Validator(org.w3c.dom.Document document, java.lang.String systemID, java.lang.String doctype) throws org.xml.sax.SAXException, ConfigurationException
document
- systemID
- doctype
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(java.io.Reader readerForValidation) throws org.xml.sax.SAXException, ConfigurationException
readerForValidation
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(java.lang.String stringForValidation) throws org.xml.sax.SAXException, ConfigurationException
stringForValidation
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(org.xml.sax.InputSource sourceForValidation) throws org.xml.sax.SAXException, ConfigurationException
readerForValidation
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(java.io.Reader readerForValidation, java.lang.String systemID) throws org.xml.sax.SAXException, ConfigurationException
readerForValidation
- systemID
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(java.lang.String stringForValidation, java.lang.String systemID) throws org.xml.sax.SAXException, ConfigurationException
stringForValidation
- systemID
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(org.xml.sax.InputSource sourceForValidation, java.lang.String systemID) throws org.xml.sax.SAXException, ConfigurationException
sourceForValidation
- systemID
- org.xml.sax.SAXException
- if unable to obtain new Sax parser via JAXP factoryConfigurationException
- if validation could not be turned onpublic Validator(org.xml.sax.InputSource sourceForValidation, java.lang.String systemID, java.lang.String doctype) throws org.xml.sax.SAXException, ConfigurationException
sourceForValidation
- systemID
- doctype
- org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned onpublic Validator(java.io.Reader readerForValidation, java.lang.String systemID, java.lang.String doctype) throws org.xml.sax.SAXException, ConfigurationException
readerForValidation
- systemID
- doctype
- org.xml.sax.SAXException
ConfigurationException
- if validation could not be turned onpublic void useXMLSchema(boolean use) throws org.xml.sax.SAXException
This feature should work with any XML parser that is JAXP 1.2 compliant and supports XML Schema validation.
For a fully JAXP 1.2 compliant parser the property http://java.sun.com/xml/jaxp/properties/schemaLanguage
is set,
if this fails the method falls back to the features
http://apache.org/xml/features/validation/schema &
http://apache.org/xml/features/validation/dynamic which should
cover early versions of Xerces 2 as well.
use
- indicate that XML Schema should be used to validate
documents.org.xml.sax.SAXException
setJAXP12SchemaSource(Object)
public boolean isValid()
public void assertIsValid()
public java.lang.String toString()
toString
in class java.lang.Object
public void warning(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
exception
- org.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
exception
- org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
exception
- org.xml.sax.SAXException
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
resolveEntity
in interface org.xml.sax.EntityResolver
resolveEntity
in class org.xml.sax.helpers.DefaultHandler
publicId
- systemId
- public void setJAXP12SchemaSource(java.lang.Object schemaSource) throws org.xml.sax.SAXException
schemaSource
- This can be one of the following:
org.xml.sax.SAXException
- if this method of validating isn't supported.http://java.sun.com/webservices/jaxp/change-requests-11.html