Outputs a JDOM document as a stream of bytes. The outputter can manage many styles of document formatting, from untouched to pretty printed. The default is to output the document content exactly as created, but this can be changed by setting a new Format object. For pretty-print output, use
{@link Format#getPrettyFormat()}
. For whitespace-normalized output, use
{@link Format#getCompactFormat()}
.
There are {@link #output output(...)}
methods to print any of the standard JDOM classes, including Document and Element, to either a Writer or an OutputStream. Warning: When outputting to a Writer, make sure the writer's encoding matches the encoding setting in the Format object. This ensures the encoding in which the content is written (controlled by the Writer configuration) matches the encoding placed in the document's XML declaration (controlled by the XMLOutputter). Because a Writer cannot be queried for its encoding, the information must be passed to the Format manually in its constructor or via the {@link Format#setEncoding}
method. The default encoding is UTF-8.
The methods {@link #outputString outputString(...)}
are for convenience only; for top performance you should call one of the {@link #output output(...)}
methods and pass in your own Writer or OutputStream if possible.
XML declarations are always printed on their own line followed by a line seperator (this doesn't change the semantics of the document). To omit printing of the declaration use {@link Format#setOmitDeclaration}
. To omit printing of the encoding in the declaration use {@link Format#setOmitEncoding}
. Unfortunatly there is currently no way to know the original encoding of the document.
Empty elements are by default printed as <empty/>, but this can be configured with {@link Format#setExpandEmptyElements}
to cause them to be expanded to <empty></empty>.
@version $Revision: 1.117 $, $Date: 2009/07/23 05:54:23 $
@author Brett McLaughlin
@author Jason Hunter
@author Jason Reid
@author Wolfgang Werner
@author Elliotte Rusty Harold
@author David & Will (from Post Tool Design)
@author Dan Schaffer
@author Alex Chaffee
@author Bradley S. Huffman