All Packages Class Hierarchy This Package Previous Next Index
Class com.kvisco.xml.XMLPrinter
com.kvisco.xml.XMLPrinter
- public class XMLPrinter
A class for printing XML nodes
- Author:
- Keith Visco
-
DEFAULT_INDENT
- The default indent size
-
XMLPrinter(PrintWriter)
- Creates a new XML Printer using the given PrintWriter
for output
-
XMLPrinter(PrintWriter, int)
- Creates a new XML Printer using the given PrintWriter
for output, and nodes are indenting using the specified
indent size
-
print(Node)
- Prints the given Node
-
printCDATASection(String)
- Prints the given Data as a CDATA section
-
printClosingTag(String)
- prints the closing tag using the given name
-
printComment(String)
- Prints the given data as a comment
-
printDoctype(DocumentType)
-
-
printEmptyElement(String, NamedNodeMap)
- Prints an empty element with the given name
and attributes
-
printEntityReference(String)
- prints the entity reference with the given name
-
printProcessingInstruction(String, String)
- Prints the processing instruction
-
printStartTag(String, NamedNodeMap)
- Prints the Start of an element
-
printText(String)
-
-
printXMLDeclaration(String, String)
- prints the XML declaration
-
setIndentSize(int)
- Sets the indent size
-
setUnescapeCDATA(boolean)
- Sets whether or not to "unwrap" CDATA Sections
when printing.
-
setUseEmptyElementShorthand(boolean)
-
-
setUseFormat(boolean)
- Sets whether or not this XMLPrinter should add whitespace
to pretty print the XML tree
DEFAULT_INDENT
public static final int DEFAULT_INDENT
- The default indent size
XMLPrinter
public XMLPrinter(PrintWriter writer)
- Creates a new XML Printer using the given PrintWriter
for output
- Parameters:
- writer - the PrintWriter to use for output
XMLPrinter
public XMLPrinter(PrintWriter writer,
int indent)
- Creates a new XML Printer using the given PrintWriter
for output, and nodes are indenting using the specified
indent size
- Parameters:
- writer - the PrintWriter to use for output
- indent - the number of spaces to indent
print
public void print(Node node)
- Prints the given Node
- Parameters:
- node - the Node to print
printCDATASection
public void printCDATASection(String data)
- Prints the given Data as a CDATA section
printClosingTag
public void printClosingTag(String name)
- prints the closing tag using the given name
- Parameters:
- name - the name of the element to print a closing
tag for
printComment
public void printComment(String data)
- Prints the given data as a comment
- Parameters:
- data - the character data to print as a comment
printDoctype
public void printDoctype(DocumentType docType)
printEmptyElement
public void printEmptyElement(String name,
NamedNodeMap attributes)
- Prints an empty element with the given name
and attributes
- Parameters:
- name - the element name
- attributes - the element's attlist
printEntityReference
public void printEntityReference(String entityName)
- prints the entity reference with the given name
- Parameters:
- the - name of the entity reference
printProcessingInstruction
public void printProcessingInstruction(String target,
String data)
- Prints the processing instruction
- Parameters:
- target, - the pi target
- data - the contents of the pi
printStartTag
public void printStartTag(String name,
NamedNodeMap attributes)
- Prints the Start of an element
- Parameters:
- name - the element name
- attributes - the element's attlist
printText
public void printText(String data)
printXMLDeclaration
public void printXMLDeclaration(String version,
String encoding)
- prints the XML declaration
- Parameters:
- version - the xml version
- encoding, - the character encoding. If null, UTF-8 is
the default encoding.
setIndentSize
public void setIndentSize(int indent)
- Sets the indent size
- Parameters:
- indent - the number of spaces to indent
setUnescapeCDATA
public void setUnescapeCDATA(boolean unescape)
- Sets whether or not to "unwrap" CDATA Sections
when printing. By Default CDATA Sections are left as is.
- Parameters:
- unescape - the boolean indicating whether or not
to unescape CDATA Sections
setUseEmptyElementShorthand
public void setUseEmptyElementShorthand(boolean useShorthand)
setUseFormat
public void setUseFormat(boolean useFormat)
- Sets whether or not this XMLPrinter should add whitespace
to pretty print the XML tree
- Parameters:
- useFormat - a boolean to indicate whether to allow the
XMLPrinter to add whitespace to the XML tree. (false by default)
All Packages Class Hierarchy This Package Previous Next Index