JDOM
1.0beta10

org.jdom.output
Class XMLOutputter

java.lang.Object
  |
  +--org.jdom.output.XMLOutputter
All Implemented Interfaces:
java.lang.Cloneable

public class XMLOutputter
extends java.lang.Object
implements java.lang.Cloneable

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 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(java.lang.String) 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(boolean). To omit printing of the encoding in the declaration use Format.setOmitEncoding(boolean). 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(boolean) to cause them to be expanded to <empty></empty>.

Version:
$Revision: 1.102 $, $Date: 2004/02/15 20:05:00 $
Author:
Brett McLaughlin, Jason Hunter, Jason Reid, Wolfgang Werner, Elliotte Rusty Harold, David & Will (from Post Tool Design), Dan Schaffer, Alex Chaffee, Bradley S. Huffman

Nested Class Summary
protected  class XMLOutputter.NamespaceStack
          Our own null subclass of NamespaceStack.
 
Field Summary
protected  Format currentFormat
           
protected  Format preserveFormat
           
protected  Format userFormat
           
 
Constructor Summary
XMLOutputter()
          This will create an XMLOutputter with the default Format matching Format.getRawFormat().
XMLOutputter(Format format)
          This will create an XMLOutputter with the specified format characteristics.
XMLOutputter(java.lang.String indent)
          Deprecated. Deprecated in Beta 10, use the Format class instead
XMLOutputter(java.lang.String indent, boolean newlines)
          Deprecated. Deprecated in Beta 10, use the Format class instead
XMLOutputter(java.lang.String indent, boolean newlines, java.lang.String encoding)
          Deprecated. Deprecated in Beta 10, use the Format class instead
XMLOutputter(XMLOutputter that)
          This will create an XMLOutputter with all the options as set in the given XMLOutputter.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this XMLOutputter.
 java.lang.String escapeAttributeEntities(java.lang.String str)
          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.
 java.lang.String escapeElementEntities(java.lang.String str)
          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.
 Format getFormat()
          Returns the current format object in use by the outputter.
 void output(CDATA cdata, java.io.OutputStream out)
          Print out a CDATA node.
 void output(CDATA cdata, java.io.Writer out)
          Print out a CDATA node.
 void output(Comment comment, java.io.OutputStream out)
          Print out a Comment.
 void output(Comment comment, java.io.Writer out)
          Print out a Comment.
 void output(DocType doctype, java.io.OutputStream out)
          Print out the DocType.
 void output(DocType doctype, java.io.Writer out)
          Print out the DocType.
 void output(Document doc, java.io.OutputStream out)
          This will print the Document to the given output stream.
 void output(Document doc, java.io.Writer out)
          This will print the Document to the given Writer.
 void output(Element element, java.io.OutputStream out)
          Print out an Element, including its Attributes, and all contained (child) elements, etc.
 void output(Element element, java.io.Writer out)
          Print out an Element, including its Attributes, and all contained (child) elements, etc.
 void output(EntityRef entity, java.io.OutputStream out)
          Print out a EntityRef.
 void output(EntityRef entity, java.io.Writer out)
          Print out a EntityRef.
 void output(java.util.List list, java.io.OutputStream out)
          This will handle printing out a list of nodes.
 void output(java.util.List list, java.io.Writer out)
          This will handle printing out a list of nodes.
 void output(ProcessingInstruction pi, java.io.OutputStream out)
          Print out a ProcessingInstruction.
 void output(ProcessingInstruction pi, java.io.Writer out)
          Print out a ProcessingInstruction.
 void output(Text text, java.io.OutputStream out)
          Print out a Text node.
 void output(Text text, java.io.Writer out)
          Print out a Text node.
 void outputElementContent(Element element, java.io.OutputStream out)
          This will handle printing out an Element's content only, not including its tag, and attributes.
 void outputElementContent(Element element, java.io.Writer out)
          This will handle printing out an Element's content only, not including its tag, and attributes.
 java.lang.String outputString(CDATA cdata)
          Return a string representing a CDATA node.
 java.lang.String outputString(Comment comment)
          Return a string representing a comment.
 java.lang.String outputString(DocType doctype)
          Return a string representing a DocType.
 java.lang.String outputString(Document doc)
          Return a string representing a document.
 java.lang.String outputString(Element element)
          Return a string representing an element.
 java.lang.String outputString(EntityRef entity)
          Return a string representing an entity.
 java.lang.String outputString(java.util.List list)
          Return a string representing a list of nodes.
 java.lang.String outputString(ProcessingInstruction pi)
          Return a string representing a PI.
 java.lang.String outputString(Text text)
          Return a string representing a Text node.
protected  void printAttributes(java.io.Writer out, java.util.List attributes, Element parent, XMLOutputter.NamespaceStack namespaces)
          This will handle printing of a Attribute list.
protected  void printCDATA(java.io.Writer out, CDATA cdata)
          This will handle printing of CDATA text.
protected  void printComment(java.io.Writer out, Comment comment)
          This will handle printing of comments.
protected  void printContentRange(java.io.Writer out, java.util.List content, int start, int end, int level, XMLOutputter.NamespaceStack namespaces)
          This will handle printing of content within a given range.
protected  void printDeclaration(java.io.Writer out, Document doc, java.lang.String encoding)
          This will handle printing of the declaration.
protected  void printDocType(java.io.Writer out, DocType docType)
          This handle printing the DOCTYPE declaration if one exists.
protected  void printElement(java.io.Writer out, Element element, int level, XMLOutputter.NamespaceStack namespaces)
          This will handle printing of a Element, its Attributes, and all contained (child) elements, etc.
protected  void printEntityRef(java.io.Writer out, EntityRef entity)
          This will handle printing a EntityRef.
protected  void printProcessingInstruction(java.io.Writer out, ProcessingInstruction pi)
          This will handle printing of processing instructions.
protected  void printString(java.io.Writer out, java.lang.String str)
          This will handle printing a string.
protected  void printText(java.io.Writer out, Text text)
          This will handle printing of Text strings.
protected  void printTextRange(java.io.Writer out, java.util.List content, int start, int end)
          This will handle printing of a sequence of CDATA or Text nodes.
 void setEncoding(java.lang.String encoding)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setExpandEmptyElements(boolean expandEmptyElements)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setFormat(Format newFormat)
          Sets the new format logic for the outputter.
 void setIndent(java.lang.String indent)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setLineSeparator(java.lang.String separator)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setNewlines(boolean newlines)
          Deprecated. Deprecated in Beta 10 since newlines will now just be added if indent is non-null
 void setOmitDeclaration(boolean omitDeclaration)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setOmitEncoding(boolean omitEncoding)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setTextNormalize(boolean textNormalize)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setTextTrim(boolean textTrim)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 void setTrimAllWhite(boolean trimAllWhite)
          Deprecated. Deprecated in Beta 10, use the Format class instead
 java.lang.String toString()
          Return a string listing of the settings for this XMLOutputter instance.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userFormat

protected Format userFormat

preserveFormat

protected Format preserveFormat

currentFormat

protected Format currentFormat
Constructor Detail

XMLOutputter

public XMLOutputter()
This will create an XMLOutputter with the default Format matching Format.getRawFormat().


XMLOutputter

public XMLOutputter(Format format)
This will create an XMLOutputter with the specified format characteristics.


XMLOutputter

public XMLOutputter(java.lang.String indent)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will create an XMLOutputter with the given indent added but no new lines added; all whitespace from the element text content is included as well.

Parameters:
indent - the indent string, usually some number of spaces

XMLOutputter

public XMLOutputter(java.lang.String indent,
                    boolean newlines)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will create an XMLOutputter with the given indent that prints newlines only if newlines is true; all whitespace from the element text content is included as well.

Parameters:
indent - the indent String, usually some number of spaces
newlines - true indicates new lines should be printed, else new lines are ignored (compacted).

XMLOutputter

public XMLOutputter(java.lang.String indent,
                    boolean newlines,
                    java.lang.String encoding)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will create an XMLOutputter with the given indent and new lines printing only if newlines is true, and encoding format encoding.

Parameters:
indent - the indent String, usually some number of spaces
newlines - true indicates new lines should be printed, else new lines are ignored (compacted).
encoding - set encoding format. Use XML-style names like "UTF-8" or "ISO-8859-1" or "US-ASCII"

XMLOutputter

public XMLOutputter(XMLOutputter that)
This will create an XMLOutputter with all the options as set in the given XMLOutputter. Note that XMLOutputter two = (XMLOutputter)one.clone(); would work equally well.

Parameters:
that - the XMLOutputter to clone
Method Detail

setFormat

public void setFormat(Format newFormat)
Sets the new format logic for the outputter.

Parameters:
newFormat - the format to use for output

getFormat

public Format getFormat()
Returns the current format object in use by the outputter.


setLineSeparator

public void setLineSeparator(java.lang.String separator)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set the newline separator (lineSeparator). The default is \r\n. Note that if the "newlines" property is false, this value is irrelevant. To make it output the system default line ending string, call setLineSeparator(System.getProperty("line.separator"))

To output "UNIX-style" documents, call setLineSeparator("\n"). To output "Mac-style" documents, call setLineSeparator("\r"). DOS-style documents use CR-LF ("\r\n"), which is the default.

Note that this only applies to newlines generated by the outputter. If you parse an XML document that contains newlines embedded inside a text node, and you do not call setTextNormalize, then the newlines will be output verbatim, as "\n" which is how parsers normalize them.

Parameters:
separator - String line separator to use.
See Also:
setNewlines(boolean), setTextNormalize(boolean)

setNewlines

public void setNewlines(boolean newlines)
Deprecated. Deprecated in Beta 10 since newlines will now just be added if indent is non-null

Sets whether newlines (lineSeparator) should be added during output as an attempt to beautify code without pre-existing whitespace. Usually called in conjunction with setIndent(java.lang.String).

Parameters:
newlines - true indicates new lines should be added for beautification.
See Also:
setLineSeparator(String)

setEncoding

public void setEncoding(java.lang.String encoding)
Deprecated. Deprecated in Beta 10, use the Format class instead

Sets the output encoding. The name should be an accepted XML encoding.

Parameters:
encoding - the encoding format. Use XML-style names like "UTF-8" or "ISO-8859-1" or "US-ASCII"

setOmitEncoding

public void setOmitEncoding(boolean omitEncoding)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) includes the encoding of the document. It is common to omit this in uses such as WML and other wireless device protocols.

Parameters:
omitEncoding - boolean indicating whether or not the XML declaration should indicate the document encoding.

setOmitDeclaration

public void setOmitDeclaration(boolean omitDeclaration)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether the XML declaration (<?xml version="1.0"?gt;) will be omitted or not. It is common to omit this in uses such as SOAP and XML-RPC calls.

Parameters:
omitDeclaration - boolean indicating whether or not the XML declaration should be omitted.

setExpandEmptyElements

public void setExpandEmptyElements(boolean expandEmptyElements)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether empty elements are expanded from <tagName/> to <tagName></tagName>.

Parameters:
expandEmptyElements - boolean indicating whether or not empty elements should be expanded.

setTrimAllWhite

public void setTrimAllWhite(boolean trimAllWhite)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether content between tags consisting of all whitespace is printed or trimmed.

Default: false

Parameters:
trimAllWhite - boolean true=>content consisting of only whitespace is not print, false=>use text verbatim

setTextTrim

public void setTextTrim(boolean textTrim)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether the text has leading/trailing whitespace trimmed.

Default: false

Parameters:
textTrim - boolean true=>trim the leading/trailing whitespace, false=>use text verbatim

setTextNormalize

public void setTextNormalize(boolean textNormalize)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set whether the text is output verbatim (false) or with whitespace normalized as per Element.getTextNormalize().

Default: false

Parameters:
textNormalize - boolean true=>normalize the whitespace, false=>use text verbatim

setIndent

public void setIndent(java.lang.String indent)
Deprecated. Deprecated in Beta 10, use the Format class instead

This will set the indent String to use; this is usually a String of empty spaces. If you pass null, or the empty string (""), then no indentation will happen. Default: none (null)

Parameters:
indent - String to use for indentation.

output

public void output(Document doc,
                   java.io.OutputStream out)
            throws java.io.IOException
This will print the Document to the given output stream. The characters are printed using the encoding specified in the constructor, or a default of UTF-8.

Parameters:
doc - Document to format.
out - OutputStream to use.
Throws:
java.io.IOException - - if there's any problem writing.

output

public void output(DocType doctype,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out the DocType.

Parameters:
doctype - DocType to output.
out - OutputStream to use.
java.io.IOException

output

public void output(Element element,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out an Element, including its Attributes, and all contained (child) elements, etc.

Parameters:
element - Element to output.
out - Writer to use.
java.io.IOException

outputElementContent

public void outputElementContent(Element element,
                                 java.io.OutputStream out)
                          throws java.io.IOException
This will handle printing out an Element's content only, not including its tag, and attributes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".

Parameters:
element - Element to output.
out - OutputStream to use.
java.io.IOException

output

public void output(java.util.List list,
                   java.io.OutputStream out)
            throws java.io.IOException
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>".

Parameters:
list - List of nodes.
out - OutputStream to use.
java.io.IOException

output

public void output(CDATA cdata,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out a CDATA node.

Parameters:
cdata - CDATA to output.
out - OutputStream to use.
java.io.IOException

output

public void output(Text text,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out a Text node. Perfoms the necessary entity escaping and whitespace stripping.

Parameters:
text - Text to output.
out - OutputStream to use.
java.io.IOException

output

public void output(Comment comment,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out a Comment.

Parameters:
comment - Comment to output.
out - OutputStream to use.
java.io.IOException

output

public void output(ProcessingInstruction pi,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out a ProcessingInstruction.

Parameters:
pi - ProcessingInstruction to output.
out - OutputStream to use.
java.io.IOException

output

public void output(EntityRef entity,
                   java.io.OutputStream out)
            throws java.io.IOException
Print out a EntityRef.

Parameters:
entity - EntityRef to output.
out - OutputStream to use.
java.io.IOException

output

public void output(Document doc,
                   java.io.Writer out)
            throws java.io.IOException
This will print the Document to the given Writer.

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.

Parameters:
doc - Document to format.
out - Writer to use.
Throws:
java.io.IOException - - if there's any problem writing.

output

public void output(DocType doctype,
                   java.io.Writer out)
            throws java.io.IOException
Print out the DocType.

Parameters:
doctype - DocType to output.
out - Writer to use.
java.io.IOException

output

public void output(Element element,
                   java.io.Writer out)
            throws java.io.IOException
Print out an Element, including its Attributes, and all contained (child) elements, etc.

Parameters:
element - Element to output.
out - Writer to use.
java.io.IOException

outputElementContent

public void outputElementContent(Element element,
                                 java.io.Writer out)
                          throws java.io.IOException
This will handle printing out an Element's content only, not including its tag, and attributes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".

Parameters:
element - Element to output.
out - Writer to use.
java.io.IOException

output

public void output(java.util.List list,
                   java.io.Writer out)
            throws java.io.IOException
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>".

Parameters:
list - List of nodes.
out - Writer to use.
java.io.IOException

output

public void output(CDATA cdata,
                   java.io.Writer out)
            throws java.io.IOException
Print out a CDATA node.

Parameters:
cdata - CDATA to output.
out - Writer to use.
java.io.IOException

output

public void output(Text text,
                   java.io.Writer out)
            throws java.io.IOException
Print out a Text node. Perfoms the necessary entity escaping and whitespace stripping.

Parameters:
text - Text to output.
out - Writer to use.
java.io.IOException

output

public void output(Comment comment,
                   java.io.Writer out)
            throws java.io.IOException
Print out a Comment.

Parameters:
comment - Comment to output.
out - Writer to use.
java.io.IOException

output

public void output(ProcessingInstruction pi,
                   java.io.Writer out)
            throws java.io.IOException
Print out a ProcessingInstruction.

Parameters:
pi - ProcessingInstruction to output.
out - Writer to use.
java.io.IOException

output

public void output(EntityRef entity,
                   java.io.Writer out)
            throws java.io.IOException
Print out a EntityRef.

Parameters:
entity - EntityRef to output.
out - Writer to use.
java.io.IOException

outputString

public java.lang.String outputString(Document doc)
Return a string representing a document. Uses an internal StringWriter. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
doc - Document to format.

outputString

public java.lang.String outputString(DocType doctype)
Return a string representing a DocType. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
doctype - DocType to format.

outputString

public java.lang.String outputString(Element element)
Return a string representing an element. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
element - Element to format.

outputString

public java.lang.String outputString(java.util.List list)
Return a string representing a list of nodes. The list is assumed to contain legal JDOM nodes.

Parameters:
list - List to format.

outputString

public java.lang.String outputString(CDATA cdata)
Return a string representing a CDATA node. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
cdata - CDATA to format.

outputString

public java.lang.String outputString(Text text)
Return a string representing a Text node. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
text - Text to format.

outputString

public java.lang.String outputString(Comment comment)
Return a string representing a comment. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
comment - Comment to format.

outputString

public java.lang.String outputString(ProcessingInstruction pi)
Return a string representing a PI. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
pi - ProcessingInstruction to format.

outputString

public java.lang.String outputString(EntityRef entity)
Return a string representing an entity. Warning: a String is Unicode, which may not match the outputter's specified encoding.

Parameters:
entity - EntityRef to format.

printDeclaration

protected void printDeclaration(java.io.Writer out,
                                Document doc,
                                java.lang.String encoding)
                         throws java.io.IOException
This will handle printing of the declaration. Assumes XML version 1.0 since we don't directly know.

Parameters:
doc - Document whose declaration to write.
out - Writer to use.
encoding - The encoding to add to the declaration
java.io.IOException

printDocType

protected void printDocType(java.io.Writer out,
                            DocType docType)
                     throws java.io.IOException
This handle printing the DOCTYPE declaration if one exists.

Parameters:
docType - Document whose declaration to write.
out - Writer to use.
java.io.IOException

printComment

protected void printComment(java.io.Writer out,
                            Comment comment)
                     throws java.io.IOException
This will handle printing of comments.

Parameters:
comment - Comment to write.
out - Writer to use.
java.io.IOException

printProcessingInstruction

protected void printProcessingInstruction(java.io.Writer out,
                                          ProcessingInstruction pi)
                                   throws java.io.IOException
This will handle printing of processing instructions.

Parameters:
pi - ProcessingInstruction to write.
out - Writer to use.
java.io.IOException

printEntityRef

protected void printEntityRef(java.io.Writer out,
                              EntityRef entity)
                       throws java.io.IOException
This will handle printing a EntityRef. Only the entity reference such as &entity; will be printed. However, subclasses are free to override this method to print the contents of the entity instead.

Parameters:
entity - EntityRef to output.
out - Writer to use.
java.io.IOException

printCDATA

protected void printCDATA(java.io.Writer out,
                          CDATA cdata)
                   throws java.io.IOException
This will handle printing of CDATA text.

Parameters:
cdata - CDATA to output.
out - Writer to use.
java.io.IOException

printText

protected void printText(java.io.Writer out,
                         Text text)
                  throws java.io.IOException
This will handle printing of Text strings.

Parameters:
text - Text to write.
out - Writer to use.
java.io.IOException

printString

protected void printString(java.io.Writer out,
                           java.lang.String str)
                    throws java.io.IOException
This will handle printing a string. Escapes the element entities, trims interior whitespace, etc. if necessary.

java.io.IOException

printElement

protected void printElement(java.io.Writer out,
                            Element element,
                            int level,
                            XMLOutputter.NamespaceStack namespaces)
                     throws java.io.IOException
This will handle printing of a Element, its Attributes, and all contained (child) elements, etc.

Parameters:
element - Element to output.
out - Writer to use.
level - int level of indention.
namespaces - List stack of Namespaces in scope.
java.io.IOException

printContentRange

protected void printContentRange(java.io.Writer out,
                                 java.util.List content,
                                 int start,
                                 int end,
                                 int level,
                                 XMLOutputter.NamespaceStack namespaces)
                          throws java.io.IOException
This will handle printing of content within a given range. The range to print is specified in typical Java fashion; the starting index is inclusive, while the ending index is exclusive.

Parameters:
content - List of content to output
start - index of first content node (inclusive.
end - index of last content node (exclusive).
out - Writer to use.
level - int level of indentation.
namespaces - List stack of Namespaces in scope.
java.io.IOException

printTextRange

protected void printTextRange(java.io.Writer out,
                              java.util.List content,
                              int start,
                              int end)
                       throws java.io.IOException
This will handle printing of a sequence of CDATA or Text nodes. It is a error to have any other pass this method any other type of node.

Parameters:
content - List of content to output
start - index of first content node (inclusive).
end - index of last content node (exclusive).
out - Writer to use.
java.io.IOException

printAttributes

protected void printAttributes(java.io.Writer out,
                               java.util.List attributes,
                               Element parent,
                               XMLOutputter.NamespaceStack namespaces)
                        throws java.io.IOException
This will handle printing of a Attribute list.

Parameters:
attributes - List of Attribute objcts
out - Writer to use
java.io.IOException

escapeAttributeEntities

public java.lang.String escapeAttributeEntities(java.lang.String str)
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.

Parameters:
str - String input to escape.
Returns:
String with escaped content.

escapeElementEntities

public java.lang.String escapeElementEntities(java.lang.String str)
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.

Parameters:
str - String input to escape.
Returns:
String with escaped content.

clone

public java.lang.Object clone()
Returns a copy of this XMLOutputter.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Return a string listing of the settings for this XMLOutputter instance.

Overrides:
toString in class java.lang.Object
Returns:
a string listing the settings for this XMLOutputter instance

JDOM
1.0beta10

Copyright © 2004 Jason Hunter, Brett McLaughlin. All Rights Reserved.