public class SAXValidator extends Object
SAXValidator
validates an XML document by
writing the document to a text buffer and parsing it with a validating
SAX parser.
This could be implemented much more efficiently by validating against the
dom4j object model directly but at least allows the reuse of existing
SAX based validating parsers.
Modifier and Type | Field and Description |
---|---|
private ErrorHandler |
errorHandler
ErrorHandler class to use
|
private XMLReader |
xmlReader
XMLReader used to parse the SAX events |
Constructor and Description |
---|
SAXValidator() |
SAXValidator(XMLReader xmlReader) |
Modifier and Type | Method and Description |
---|---|
protected void |
configureReader()
Configures the XMLReader before use
|
protected XMLReader |
createXMLReader()
Factory Method to allow alternate methods of
creating and configuring XMLReader objects
|
ErrorHandler |
getErrorHandler() |
XMLReader |
getXMLReader() |
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the
ErrorHandler used by the SAX
XMLReader . |
void |
setXMLReader(XMLReader xmlReader)
Sets the
XMLReader used to parse SAX events |
void |
validate(Document document)
Validates the given
Document by writing it to a
validating SAX Parser. |
private ErrorHandler errorHandler
public SAXValidator()
public SAXValidator(XMLReader xmlReader)
public void validate(Document document) throws SAXException
Document
by writing it to a
validating SAX Parser.document
- is the Document to validateSAXException
public XMLReader getXMLReader() throws SAXException
XMLReader
used to parse SAX eventsSAXException
public void setXMLReader(XMLReader xmlReader) throws SAXException
XMLReader
used to parse SAX eventsxmlReader
- is the XMLReader
to parse SAX eventsSAXException
public ErrorHandler getErrorHandler()
ErrorHandler
used by SAXpublic void setErrorHandler(ErrorHandler errorHandler)
ErrorHandler
used by the SAX
XMLReader
.errorHandler
- is the ErrorHandler
used by SAXprotected XMLReader createXMLReader() throws SAXException
SAXException
protected void configureReader() throws SAXException
SAXException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses