Package org.dom4j.io

Class SAXHelper


  • class SAXHelper
    extends Object

    SAXHelper contains some helper methods for working with SAX and XMLReader objects.

    Version:
    $Revision: 1.18 $
    Author:
    James Strachan
    • Constructor Detail

      • SAXHelper

        protected SAXHelper()
    • Method Detail

      • setParserProperty

        public static boolean setParserProperty​(XMLReader reader,
                                                String propertyName,
                                                Object value)
      • setParserFeature

        public static boolean setParserFeature​(XMLReader reader,
                                               String featureName,
                                               boolean value)
      • createXMLReader

        public static XMLReader createXMLReader​(boolean validating)
                                         throws SAXException
        Creats a default XMLReader via the org.xml.sax.driver system property or JAXP if the system property is not set. This method internally calls SAXParserFactory.newInstance().newSAXParser().getXMLReader() or XMLReaderFactory.createXMLReader(). Be sure to configure returned reader if the default configuration does not suit you. Consider setting the following properties:
         reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
         reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
         reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
         
        Parameters:
        validating - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
        Throws:
        SAXException - DOCUMENT ME!
      • createXMLReaderViaJAXP

        protected static XMLReader createXMLReaderViaJAXP​(boolean validating,
                                                          boolean namespaceAware)
        This method attempts to use JAXP to locate the SAX2 XMLReader implementation. This method uses reflection to avoid being dependent directly on the JAXP classes.
        Parameters:
        validating - DOCUMENT ME!
        namespaceAware - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • isVerboseErrorReporting

        protected static boolean isVerboseErrorReporting()