Public Member Functions | |
XMLOutputter () | |
XMLOutputter (Format format) | |
XMLOutputter (XMLOutputter that) | |
void | setFormat (Format newFormat) |
Format | getFormat () |
void | output (Document doc, OutputStream out) throws IOException |
void | output (DocType doctype, OutputStream out) throws IOException |
void | output (Element element, OutputStream out) throws IOException |
void | outputElementContent (Element element, OutputStream out) throws IOException |
void | output (List list, OutputStream out) throws IOException |
void | output (CDATA cdata, OutputStream out) throws IOException |
void | output (Text text, OutputStream out) throws IOException |
void | output (Comment comment, OutputStream out) throws IOException |
void | output (ProcessingInstruction pi, OutputStream out) throws IOException |
void | output (EntityRef entity, OutputStream out) throws IOException |
void | output (Document doc, Writer out) throws IOException |
void | output (DocType doctype, Writer out) throws IOException |
void | output (Element element, Writer out) throws IOException |
void | outputElementContent (Element element, Writer out) throws IOException |
void | output (List list, Writer out) throws IOException |
void | output (CDATA cdata, Writer out) throws IOException |
void | output (Text text, Writer out) throws IOException |
void | output (Comment comment, Writer out) throws IOException |
void | output (ProcessingInstruction pi, Writer out) throws IOException |
void | output (EntityRef entity, Writer out) throws IOException |
String | outputString (Document doc) |
String | outputString (DocType doctype) |
String | outputString (Element element) |
String | outputString (List list) |
String | outputString (CDATA cdata) |
String | outputString (Text text) |
String | outputString (Comment comment) |
String | outputString (ProcessingInstruction pi) |
String | outputString (EntityRef entity) |
String | escapeAttributeEntities (String str) |
String | escapeElementEntities (String str) |
Object | clone () |
String | toString () |
Protected Member Functions | |
void | printDeclaration (Writer out, Document doc, String encoding) throws IOException |
void | printDocType (Writer out, DocType docType) throws IOException |
void | printComment (Writer out, Comment comment) throws IOException |
void | printProcessingInstruction (Writer out, ProcessingInstruction pi) throws IOException |
void | printEntityRef (Writer out, EntityRef entity) throws IOException |
void | printCDATA (Writer out, CDATA cdata) throws IOException |
void | printText (Writer out, Text text) throws IOException |
void | printElement (Writer out, Element element, int level, NamespaceStack namespaces) throws IOException |
void | printAttributes (Writer out, List attributes, Element parent, NamespaceStack namespaces) throws IOException |
Protected Attributes | |
Format | currentFormat = userFormat |
Static Protected Attributes | |
final Format | preserveFormat = Format.getRawFormat() |
Format#getPrettyFormat()
. For whitespace-normalized output, use Format#getCompactFormat()
.
There are 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 Format#setEncoding
method. The default encoding is UTF-8.
The methods outputString(...)
are for convenience only; for top performance you should call one of the 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 Format#setOmitDeclaration
. To omit printing of the encoding in the declaration use 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 Format#setExpandEmptyElements
to cause them to be expanded to <empty></empty>.
Jason Hunter
Jason Reid
Wolfgang Werner
Elliotte Rusty Harold
David & Will (from Post Tool Design)
Dan Schaffer
Alex Chaffee
Bradley S. Huffman
|
This will create an |
|
This will create an |
|
This will create an
|
|
Returns a copy of this XMLOutputter. |
|
This will take the pre-defined entities in XML 1.0 and convert their character representation to the appropriate entity reference, suitable for XML attributes. It does not convert the single quote (') because it's not necessary as the outputter writes attributes surrounded by double-quotes.
|
|
This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.
|
|
Returns the current format in use by the outputter. Note the Format object returned is a clone of the one used internally. |
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
|
|
Print out an
|
|
Print out the
|
|
This will print the Warning: using your own Writer may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.
|
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
Print out a
|
|
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
|
|
Print out an
|
|
Print out the
|
|
This will print the
|
|
This will handle printing out an
|
|
This will handle printing out an
|
|
Return a string representing an entity. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a PI. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a comment. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a Text node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a CDATA node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a list of nodes. The list is assumed to contain legal JDOM nodes.
|
|
Return a string representing an element. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a DocType. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
Return a string representing a document. Uses an internal StringWriter. Warning: a String is Unicode, which may not match the outputter's specified encoding.
|
|
This will handle printing of a
|
|
This will handle printing of
|
|
This will handle printing of comments.
|
|
This will handle printing of the declaration. Assumes XML version 1.0 since we don't directly know.
|
|
This handle printing the DOCTYPE declaration if one exists.
|
|
This will handle printing of a
|
|
This will handle printing a
|
|
This will handle printing of processing instructions.
|
|
This will handle printing of
|
|
Sets the new format logic for the outputter. Note the Format object is cloned internally before use.
|
|
Return a string listing of the settings for this XMLOutputter instance.
|