/** * Create and initialize the SAX reader. * * @return the SAX reader instance. * @throws DocumentException if DOCTYPE processing cannot be disabled * @since 1.4.9 */ protected SAXReader createReader() throws DocumentException { final SAXReader reader = new SAXReader(); try { reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); } catch (SAXException e) { throw new DocumentException("Cannot disable DOCTYPE processing", e); } return reader; } }
public void readXML(URL u) throws IOException, DocumentException { InputStream in = progessMonitoredInputStream(u.openConnection(), "Loading analysis"); dataSource = u.toString(); try { readXML(in); } catch (IOException e) { throw newIOException(u, e); } catch (DocumentException e) { throw new DocumentException("Failing reading " + u, e); } }
} catch (SAXException e) { AnalysisContext.logError("Couldn't create XMLReaderFactory", e); throw new DocumentException("Sax error ", e); } catch (SAXParseException e) { if (base != null) { throw new DocumentException("Parse error at line " + e.getLineNumber() + " : " + e.getColumnNumber() + " of " + base, e); throw new DocumentException("Parse error at line " + e.getLineNumber() + " : " + e.getColumnNumber(), e); } catch (SAXException e) { throw new DocumentException("Sax error while parsing " + base, e); throw new DocumentException("Sax error ", e); } finally { Util.closeSilently(reader);
/** * Read XML data from given file into this object, populating given Project * as a side effect. * * @param file * the file */ public void readXML(File file) throws IOException, DocumentException { project.setCurrentWorkingDirectory(file.getParentFile()); dataSource = file.getAbsolutePath(); InputStream in = progessMonitoredInputStream(file, "Loading analysis"); try { readXML(in, file); } catch (IOException e) { throw newIOException(file, e); } catch (DocumentException e) { throw new DocumentException("Failing reading " + file, e); } }
DocumentException e2 = new DocumentException("Error parsing " + newFilename); e2.initCause(e); if (verbose) {
throw new DocumentException("Cannot have text content outside of the root document"); throw new DocumentException("Cannot have an entityref outside of the root document"); throw new DocumentException("Cannot have text content outside of the root document");
/** * Sets the DOM {@link org.w3c.dom.Document}implementation class name used * by the writer when creating DOM documents. * * @param name * is the name of the Class implementing the {@link * org.w3c.dom.Document} interface * * @throws DocumentException * if the class could not be loaded */ public void setDomDocumentClassName(String name) throws DocumentException { try { this.domDocumentClass = Class.forName(name, true, DOMWriter.class .getClassLoader()); } catch (Exception e) { throw new DocumentException("Could not load the DOM Document " + "class: " + name, e); } }
/** * Parses the specified {@link java.io.InputStream} * * @param source * the input stream to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(InputStream source) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the the given URL or filename. * * @param source * the location to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(String source) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the specified {@link java.io.Reader} * * @param source * the input reader to use * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(Reader source) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the specified {@link org.xml.sax.InputSource} * * @param source * the source to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(InputSource source) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the the given URL. * * @param source * the URL to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(URL source) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Reads a Document from the given {@link java.io.Reader}and writes it to * the specified {@link XMLWriter}using SAX. Registered {@link * ElementModifier} objects are invoked on the fly. * * @param source * is the <code>java.io.Reader</code> to read from. * * @return the newly created Document instance * * @throws DocumentException * DocumentException org.dom4j.DocumentException} if an error * occurs during parsing. */ public Document modify(Reader source) throws DocumentException { try { return installModifyReader().read(source); } catch (SAXModifyException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Reads a Document from the given {@link java.net.URL}and writes it to the * specified {@link XMLWriter}using SAX. Registered {@link ElementModifier} * objects are invoked on the fly. * * @param source * is the <code>java.net.URL</code> to read from. * * @return the newly created Document instance * * @throws DocumentException * DocumentException org.dom4j.DocumentException} if an error * occurs during parsing. */ public Document modify(URL source) throws DocumentException { try { return installModifyReader().read(source); } catch (SAXModifyException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Reads a Document from the given {@link org.xml.sax.InputSource}and * writes it to the specified {@link XMLWriter}using SAX. Registered * {@link ElementModifier}objects are invoked on the fly. * * @param source * is the <code>org.xml.sax.InputSource</code> to read from. * * @return the newly created Document instance * * @throws DocumentException * DocumentException org.dom4j.DocumentException} if an error * occurs during parsing. */ public Document modify(InputSource source) throws DocumentException { try { return installModifyReader().read(source); } catch (SAXModifyException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Reads a Document from the given {@link java.io.InputStream}and writes it * to the specified {@link XMLWriter}using SAX. Registered {@link * ElementModifier} objects are invoked on the fly. * * @param source * is the <code>java.io.InputStream</code> to read from. * * @return the newly created Document instance * * @throws DocumentException * DocumentException org.dom4j.DocumentException} if an error * occurs during parsing. */ public Document modify(InputStream source) throws DocumentException { try { return installModifyReader().read(source); } catch (SAXModifyException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the specified {@link java.io.Reader} * * @param source * the input reader to parse * @param systemId * is the URI for the input * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing */ public Document read(Reader source, String systemId) throws DocumentException { try { return getReader().read(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the the given URL or filename. * * @param url * the URL or filename to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing * @throws IOException * when an error occurs while writing to the {@link * org.dom4j.io.XMLWriter} */ public Document modify(String url) throws DocumentException, IOException { try { return installModifier().modify(url); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
/** * Parses the the given URL. * * @param source * the URL to parse * * @return the resulting DOM4J document * * @throws DocumentException * when an error occurs while parsing * @throws IOException * when an error occurs while writing to the {@link * org.dom4j.io.XMLWriter} */ public Document modify(URL source) throws DocumentException, IOException { try { return installModifier().modify(source); } catch (JAXBRuntimeException ex) { Throwable cause = ex.getCause(); throw new DocumentException(cause.getMessage(), cause); } }
private SAXReader installModifyReader() throws DocumentException { try { SAXModifyReader reader = getSAXModifyReader(); if (isPruneElements()) { modifyReader.setDispatchHandler(new PruningDispatchHandler()); } reader.resetHandlers(); for (Map.Entry<String, ElementModifier> entry : this.modifiers.entrySet()) { SAXModifyElementHandler handler = new SAXModifyElementHandler( entry.getValue()); reader.addHandler(entry.getKey(), handler); } reader.setXMLWriter(getXMLWriter()); reader.setXMLReader(getXMLReader()); return reader; } catch (SAXException ex) { throw new DocumentException(ex.getMessage(), ex); } }