/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @param systemID is the URI for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * @param systemID * is the URI for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
/** * <p> * Reads a Document from the given <code>Reader</code> * </p> * * @param reader * is the reader for the input * @param systemID * is the URI for the input * * @return the newly created Document instance * * @throws DocumentException * if an error occurs during parsing. * @throws IOException * DOCUMENT ME! * @throws XmlPullParserException * DOCUMENT ME! */ public Document read(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
/** * DOCUMENT ME! * * @return the current document */ protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @param systemID is the URI for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @param systemID is the URI for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(Reader reader, String systemID) throws DocumentException, IOException, XmlPullParserException { Document document = read(reader); document.setName(systemID); return document; }
protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
/** * DOCUMENT ME! * * @return the current document */ protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
/** * DOCUMENT ME! * * @return the current document */ protected Document createDocument() { String encoding = getEncoding(); Document doc = documentFactory.createDocument(encoding); // set the EntityResolver doc.setEntityResolver(entityResolver); if (inputSource != null) { doc.setName(inputSource.getSystemId()); } return doc; }
protected Document roundTripText(Document document) throws Exception { StringWriter out = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(out); xmlWriter.write(document); // now lets read it back String xml = out.toString(); StringReader in = new StringReader(xml); SAXReader reader = new SAXReader(); Document newDocument = reader.read(in); // lets ensure names are same newDocument.setName(document.getName()); assertDocumentsEqual(document, newDocument); return newDocument; }
/** * Prepares a new document.<p> * * @param doc the original document * * @return a new document */ protected Document prepareDoc(Document doc) { Document newDoc = new DocumentFactory().createDocument(); newDoc.addElement(CmsConfigurationManager.N_ROOT); newDoc.setName(doc.getName()); return newDoc; }
public void testRoot() throws Exception { document.setName("doc1"); Element root = document.getRootElement(); List authors = root.elements("author"); assertTrue("Should be at least 2 authors", authors.size() == 2); Element author1 = (Element) authors.get(0); Element author2 = (Element) authors.get(1); testCopy(root); testCopy(author1); testCopy(author2); }
private static Document writeDocument(List<LogEntry> logEntries) { Document document = DocumentFactory.getInstance().createDocument(); document.setName("logEntries"); Element rootElement = document.addElement(DOCUMENT_TAG); for (LogEntry logEntry : logEntries) { Element logEntryElement = rootElement.addElement(LOGENTRY_TAG); writeLogEntry(logEntryElement, logEntry); } return document; }
public void testDocumentClone() throws Exception { document.setName("doc1"); Document doc2 = (Document) document.clone(); assertNotSame(document, doc2); assertNodesEqual(document, doc2); }
public void testSAXContentHandler() throws Exception { SAXContentHandler contentHandler = new SAXContentHandler(); xmlReader.setContentHandler(contentHandler); xmlReader.setDTDHandler(contentHandler); xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", contentHandler); for (int i = 0, size = testDocuments.length; i < size; i++) { Document docFromSAXReader = getDocument(testDocuments[i]); xmlReader.parse(getFile(testDocuments[i]).toString()); Document docFromSAXContentHandler = contentHandler.getDocument(); docFromSAXContentHandler.setName(docFromSAXReader.getName()); assertDocumentsEqual(docFromSAXReader, docFromSAXContentHandler); assertEquals(docFromSAXReader.asXML(), docFromSAXContentHandler .asXML()); } }
protected Document roundTripSAX(Document document) throws Exception { // now lets write it back as SAX events to // a SAX ContentHandler which should build up a new document SAXContentHandler contentHandler = new SAXContentHandler(); SAXWriter saxWriter = new SAXWriter(contentHandler, contentHandler, contentHandler); saxWriter.write(document); Document newDocument = contentHandler.getDocument(); // lets ensure names are same newDocument.setName(document.getName()); assertDocumentsEqual(document, newDocument); return newDocument; }
protected Document roundTripDOM(Document document) throws Exception { // now lets make a DOM object DOMWriter domWriter = new DOMWriter(); org.w3c.dom.Document domDocument = domWriter.write(document); // now lets read it back as a DOM4J object DOMReader domReader = new DOMReader(); Document newDocument = domReader.read(domDocument); // lets ensure names are same newDocument.setName(document.getName()); assertDocumentsEqual(document, newDocument); return newDocument; }