/** * This provides an <code>EventReader</code> that will read from * the specified source. When reading from a source the character * encoding should be the same as the source XML document. * * @param source this is the source to read the document with * * @return this is used to return the event reader implementation */ private EventReader provide(InputSource source) throws Exception { DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(source); return new DocumentReader(document); } }
/** * This provides an <code>EventReader</code> that will read from * the specified source. When reading from a source the character * encoding should be the same as the source XML document. * * @param source this is the source to read the document with * * @return this is used to return the event reader implementation */ private EventReader provide(InputSource source) throws Exception { DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(source); return new DocumentReader(document); } }
/** * This provides an <code>EventReader</code> that will read from * the specified source. When reading from a source the character * encoding should be the same as the source XML document. * * @param source this is the source to read the document with * * @return this is used to return the event reader implementation */ private EventReader provide(InputSource source) throws Exception { DocumentBuilder builder = factory.newDocumentBuilder(); try { return new DocumentReader(builder.parse(source)); } catch (SAXException e) { // On Apache, this should be thrown when disallowing DOCTYPE throw new RuntimeException("A DOCTYPE was passed into the XML document, and this is blocked on purpose due to security issues", e); } catch (IOException e) { // XXE that points to a file that doesn't exist throw new RuntimeException("IOException occurred, XXE may still possible", e); } } }