Configured with three variables passed to the constructor:
indent
String
added at each level
of output; e.g. two spaces or a tablineSeparator
String
to break lines with,
no line breaking is performed if this is null or the empty string
encoding
Options can be set with these 10 methods:
public void setLineSeparator(String separator)
public void setNewlines(boolean newlines)
public void setEncoding(String encoding)
public void setOmitEncoding(boolean omitEncoding)
public void setOmitDeclaration(boolean omitDeclaration)
public void setExpandEmptyElements(boolean expandEmptyElements)
public void setIndent(String indent)
public void setTextNormalize(boolean textNormalize)
public void setTrimAllWhite(boolean trimAllWhite)
public void setTextTrim(boolean textTrim)
The output()
method writes a Document
onto a given
OutputStream
:
public void output(Document doc, OutputStream out) throws IOException
public void output(Document doc, Writer writer) throws IOException
There are also output()
methods for other JDOM classes:
public void output(Element element, Writer out) throws IOException
public void output(Element element, OutputStream out)
public void outputElementContent(Element element, Writer out) throws IOException
public void outputElementContent(Element element, OutputStream out) throws IOException
public void output(CDATA cdata, Writer out) throws IOException
public void output(CDATA cdata, OutputStream out) throws IOException
public void output(Comment comment, Writer out) throws IOException
public void output(Comment comment, OutputStream out) throws IOException
public void output(Text text, Writer out) throws IOException
public void output(Text text, OutputStream out) throws IOException
public void output(Entity entity, Writer out) throws IOException
public void output(Entity entity, OutputStream out) throws IOException
public void output(ProcessingInstruction processingInstruction, Writer out)
throws IOException
public void output(ProcessingInstruction processingInstruction, OutputStream out)
throws IOException
Use the outputString()
methods to
store a document in a string:
public String outputString(Document doc) throws IOException
public String outputString(Element element) throws IOException
public String outputString(CDATA cdata)
public String outputString(Comment comment)
public String outputString(DocType doctype)
public String outputString(EntityRef entity)
public String outputString(ProcessingInstruction pi)
public String outputString(Text text)