/** * Gets a new Document read from the input source. * * @return Returns Document. * @throws ParserConfigurationException if construction problems occur * @throws SAXException if the document has xml sax problems * @throws IOException if i/o exceptions occur */ public static Document newDocument(InputSource inp) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder db; synchronized (dbf) { try { db = dbf.newDocumentBuilder(); } catch (Exception e){ // Under some peculiar conditions (classloader issues), just scrap the old dbf, create a new one and try again. dbf = getDOMFactory(); db = dbf.newDocumentBuilder(); } } db.setEntityResolver(new DefaultEntityResolver()); db.setErrorHandler(new ParserErrorHandler()); return (db.parse(inp)); }
/** * Gets a new Document read from the input source. * * @return Returns Document. * @throws ParserConfigurationException if construction problems occur * @throws SAXException if the document has xml sax problems * @throws IOException if i/o exceptions occur */ public static Document newDocument(InputSource inp) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder db; synchronized (dbf) { try { db = dbf.newDocumentBuilder(); } catch (Exception e){ // Under some peculiar conditions (classloader issues), just scrap the old dbf, create a new one and try again. dbf = getDOMFactory(); db = dbf.newDocumentBuilder(); } } db.setEntityResolver(new DefaultEntityResolver()); db.setErrorHandler(new ParserErrorHandler()); return (db.parse(inp)); }