try { XRLog.load(Level.WARNING, "falling back on the default parser"); SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); xmlReader = parser.getXMLReader(); xmlReaderClass = "SAXParserFactory default"; } catch ( Exception ex ) { XRLog.general(ex.getMessage()); } } if ( xmlReader == null ) {
    public static final XMLReader newXMLReader() {        XMLReader xmlReader = null;        String xmlReaderClass = Configuration.valueFor("xr.load.xml-reader");                //TODO: if it doesn't find the parser, note that in a static boolean--otherwise        // you get exceptions on every load        try {            if ( xmlReaderClass != null &&                  !xmlReaderClass.toLowerCase().equals("default") &&                  XMLResource.useConfiguredParser ) {                try {                    Class.forName(xmlReaderClass);                } catch (Exception ex) {                    XMLResource.useConfiguredParser = false;                    XRLog.load(Level.WARNING,                            "The XMLReader class you specified as a configuration property " +                            "could not be found. Class.forName() failed on "                            + xmlReaderClass +". Please check classpath. Use value 'default' in " +                            "FS configuration if necessary. Will now try JDK default.");                }                if ( XMLResource.useConfiguredParser ) {                    xmlReader = XMLReaderFactory.createXMLReader( xmlReaderClass );                }            }        } catch ( Exception ex ) {            XRLog.load(Level.WARNING,                    "Could not instantiate custom XMLReader class for XML parsing: "                    + xmlReaderClass +". Please check classpath. Use value 'default' in " +                    "FS configuration if necessary. Will now try JDK default.", ex);        }        if ( xmlReader == null ) {            try {                // JDK default                // HACK: if                 if ( System.getProperty("org.xml.sax.driver") == null ) {                    String newDefault = "org.apache.crimson.parser.XMLReaderImpl";                     XRLog.load(Level.WARNING,                    "No value for system property 'org.xml.sax.driver'.");                }                xmlReader = XMLReaderFactory.createXMLReader();                 xmlReaderClass = "{JDK default}";            } catch ( Exception ex ) {                XRLog.general(ex.getMessage());            }        }        if ( xmlReader == null ) {            throw new XRRuntimeException("Could not instantiate any SAX 2 parser, including JDK default. " +                    "The name of the class to use should have been read from the org.xml.sax.driver System " +                    "property, which is set to: " + System.getProperty("org.xml.sax.driver"));        }        XRLog.load( "SAX XMLReader in use (parser): " + xmlReader.getClass().getName() );        return xmlReader;    }