org.dom4j.io
Class SAXValidator

java.lang.Object
  extended byorg.dom4j.io.SAXValidator

public class SAXValidator
extends java.lang.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.

Version:
$Revision: 1.8 $
Author:
James Strachan

Constructor Summary
SAXValidator()
           
SAXValidator(XMLReader xmlReader)
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXValidator

public SAXValidator()

SAXValidator

public SAXValidator(XMLReader xmlReader)
Method Detail

validate

public void validate(Document document)
              throws SAXException
Validates the given Document by writing it to a validating SAX Parser.

Parameters:
document - is the Document to validate
Throws:
SAXException - if a validation error occurs

getXMLReader

public XMLReader getXMLReader()
                       throws SAXException
Returns:
the XMLReader used to parse SAX events
Throws:
SAXException

setXMLReader

public void setXMLReader(XMLReader xmlReader)
                  throws SAXException
Sets the XMLReader used to parse SAX events

Parameters:
xmlReader - is the XMLReader to parse SAX events
Throws:
SAXException

getErrorHandler

public ErrorHandler getErrorHandler()
Returns:
the ErrorHandler used by SAX

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Sets the ErrorHandler used by the SAX XMLReader.

Parameters:
errorHandler - is the ErrorHandler used by SAX

createXMLReader

protected XMLReader createXMLReader()
                             throws SAXException
Factory Method to allow alternate methods of creating and configuring XMLReader objects

Throws:
SAXException

configureReader

protected void configureReader()
                        throws SAXException
Configures the XMLReader before use

Throws:
SAXException


Copyright © 2004 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge Logo