Search in sources :

Example 41 with XMLWriter

use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.

the class DavResource method getPropertiesAsText.

protected String getPropertiesAsText(DavContext ctxt) throws IOException {
    Element e = org.dom4j.DocumentHelper.createElement(DavElements.E_PROP);
    for (ResourceProperty rp : mProps.values()) rp.toElement(ctxt, e, false);
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setTrimText(false);
    format.setOmitEncoding(false);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLWriter writer = new XMLWriter(baos, format);
    writer.write(e);
    return new String(baos.toByteArray());
}
Also used : ResourceProperty(com.zimbra.cs.dav.property.ResourceProperty) Element(org.dom4j.Element) OutputFormat(org.dom4j.io.OutputFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) XMLWriter(org.dom4j.io.XMLWriter)

Example 42 with XMLWriter

use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.

the class DomUtil method writeDocumentToStream.

public static void writeDocumentToStream(Document doc, OutputStream out) throws IOException {
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setTrimText(false);
    format.setOmitEncoding(false);
    XMLWriter writer = new XMLWriter(out, format);
    writer.write(doc);
}
Also used : OutputFormat(org.dom4j.io.OutputFormat) XMLWriter(org.dom4j.io.XMLWriter)

Aggregations

XMLWriter (org.dom4j.io.XMLWriter)42 Document (org.dom4j.Document)21 OutputFormat (org.dom4j.io.OutputFormat)17 IOException (java.io.IOException)15 Element (org.dom4j.Element)15 FileOutputStream (java.io.FileOutputStream)14 File (java.io.File)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 SAXReader (org.dom4j.io.SAXReader)9 FileWriter (java.io.FileWriter)6 StringWriter (java.io.StringWriter)5 BufferedWriter (java.io.BufferedWriter)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)3 PrintWriter (java.io.PrintWriter)3 Writer (java.io.Writer)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TreeSet (java.util.TreeSet)3