Top Description Fields Constructors Methods
org.dom4j.io

public Class SAXValidator

extends Object
Class Inheritance
Imports
java.io.IOException, org.dom4j.Document, org.xml.sax.ContentHandler, .ErrorHandler, .SAXException, .XMLReader, org.xml.sax.helpers.DefaultHandler

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.

Author
James Strachan
Version
$Revision: 1.10 $

Field Summary

Modifier and TypeField and Description
private ErrorHandler
errorHandler

ErrorHandler class to use

private XMLReader
xmlReader

XMLReader used to parse the SAX events

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected void
configureReader()

Configures the XMLReader before use

protected XMLReader

Returns:

DOCUMENT ME!
createXMLReader
()

Factory Method to allow alternate methods of creating and configuring XMLReader objects

public ErrorHandler

Returns:

the ErrorHandler used by SAX
getErrorHandler
()

DOCUMENT ME!

public XMLReader

Returns:

the XMLReader used to parse SAX events
getXMLReader
()

DOCUMENT ME!

public void
setErrorHandler(ErrorHandler
is the ErrorHandler used by SAX
errorHandler
)

Sets the ErrorHandler used by the SAX XMLReader.

public void
setXMLReader(XMLReader
is the XMLReader to parse SAX events
reader
)

Sets the XMLReader used to parse SAX events

public void
validate(Document
is the Document to validate
document
)

Validates the given Document by writing it to a validating SAX Parser.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorHandlerback to summary
private ErrorHandler errorHandler

ErrorHandler class to use

xmlReaderback to summary
private XMLReader xmlReader

XMLReader used to parse the SAX events

Constructor Detail

SAXValidatorback to summary
public SAXValidator()
SAXValidatorback to summary
public SAXValidator(XMLReader xmlReader)

Method Detail

configureReaderback to summary
protected void configureReader() throws SAXException

Configures the XMLReader before use

Exceptions
SAXException:
DOCUMENT ME!
createXMLReaderback to summary
protected XMLReader createXMLReader() throws SAXException

Factory Method to allow alternate methods of creating and configuring XMLReader objects

Returns:XMLReader

DOCUMENT ME!

Exceptions
SAXException:
DOCUMENT ME!
getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

DOCUMENT ME!

Returns:ErrorHandler

the ErrorHandler used by SAX

getXMLReaderback to summary
public XMLReader getXMLReader() throws SAXException

DOCUMENT ME!

Returns:XMLReader

the XMLReader used to parse SAX events

Exceptions
SAXException:
DOCUMENT ME!
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

Sets the ErrorHandler used by the SAX XMLReader.

Parameters
errorHandler:ErrorHandler

is the ErrorHandler used by SAX

setXMLReaderback to summary
public void setXMLReader(XMLReader reader) throws SAXException

Sets the XMLReader used to parse SAX events

Parameters
reader:XMLReader

is the XMLReader to parse SAX events

Exceptions
SAXException:
DOCUMENT ME!
validateback to summary
public void validate(Document document) throws SAXException

Validates the given Document by writing it to a validating SAX Parser.

Parameters
document:Document

is the Document to validate

Exceptions
SAXException:
if a validation error occurs
RuntimeException:
DOCUMENT ME!