Package org.dom4j.io

Class 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.

    • Constructor Summary

      Constructors 
      Constructor Description
      SAXValidator()  
      SAXValidator​(org.xml.sax.XMLReader xmlReader)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configureReader()
      Configures the XMLReader before use
      protected org.xml.sax.XMLReader createXMLReader()
      Factory Method to allow alternate methods of creating and configuring XMLReader objects
      org.xml.sax.ErrorHandler getErrorHandler()
      DOCUMENT ME!
      org.xml.sax.XMLReader getXMLReader()
      DOCUMENT ME!
      void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)
      Sets the ErrorHandler used by the SAX XMLReader.
      void setXMLReader​(org.xml.sax.XMLReader reader)
      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​(org.xml.sax.XMLReader xmlReader)
    • Method Detail

      • validate

        public void validate​(Document document)
                      throws org.xml.sax.SAXException
        Validates the given Document by writing it to a validating SAX Parser.
        Parameters:
        document - is the Document to validate
        Throws:
        org.xml.sax.SAXException - if a validation error occurs
        java.lang.RuntimeException - DOCUMENT ME!
      • getXMLReader

        public org.xml.sax.XMLReader getXMLReader()
                                           throws org.xml.sax.SAXException
        DOCUMENT ME!
        Returns:
        the XMLReader used to parse SAX events
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • setXMLReader

        public void setXMLReader​(org.xml.sax.XMLReader reader)
                          throws org.xml.sax.SAXException
        Sets the XMLReader used to parse SAX events
        Parameters:
        reader - is the XMLReader to parse SAX events
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • getErrorHandler

        public org.xml.sax.ErrorHandler getErrorHandler()
        DOCUMENT ME!
        Returns:
        the ErrorHandler used by SAX
      • setErrorHandler

        public void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)
        Sets the ErrorHandler used by the SAX XMLReader.
        Parameters:
        errorHandler - is the ErrorHandler used by SAX
      • createXMLReader

        protected org.xml.sax.XMLReader createXMLReader()
                                                 throws org.xml.sax.SAXException
        Factory Method to allow alternate methods of creating and configuring XMLReader objects
        Returns:
        DOCUMENT ME!
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!
      • configureReader

        protected void configureReader()
                                throws org.xml.sax.SAXException
        Configures the XMLReader before use
        Throws:
        org.xml.sax.SAXException - DOCUMENT ME!