org.freecompany.xmlwriter
public class XmlWriter extends FilterWriter implements ContentHandler, LexicalHandler
XmlWriter
is a SAX ContentHandler
that simply writes the corresponding events as an XML document.
Field Summary | |
---|---|
protected int | depth |
protected CharSequence | encoding |
protected boolean | endElementGenerated |
protected boolean | indented |
protected Locator | locator |
static int | NO_AUTOFLUSH
A value for the autoflush threshold that disables the feature. |
protected Map<String,CharSequence> | pending |
protected Map<String,CharSequence> | prefixes |
protected Boolean | standalone |
protected boolean | startElementPending
State flags for internal use. |
protected int | threshold |
protected CharSequence | version |
protected static String | XMLNS |
Constructor Summary | |
---|---|
XmlWriter(Writer out)
Creates an XmlWriter that wraps another writer. |
Method Summary | |
---|---|
XmlWriter | append(Node root)
Writes a DOM subtree. |
XmlWriter | appendInternal(char value)
Override to convert exception types to SAX. |
XmlWriter | appendInternal(CharSequence value)
Override to convert exception types to SAX. |
void | cData(CharSequence s)
Creates a CDATA section in the output. |
void | characters(char[] characters, int offset, int length)
Writes text to the output. |
void | characters(CharSequence s)
Writes character data while performing escapes as defined in the XML
1.0 specification, section 2.4. |
void | comment(char[] characters, int offset, int index) |
void | createElement(QName qname)
Creates an empty element with no attributes. |
void | createElement(QName qname, CharSequence content)
Creates an element with no attributes and the specified text content. |
void | createElement(QName qname, Attributes attrs)
Creates an empty element with the specified attributes. |
void | createElement(QName qname, Attributes attrs, CharSequence content)
Creates an element with the specified attributes and text content. |
void | createElement(CharSequence uri, CharSequence name)
Creates an empty element with no attributes. |
void | createElement(CharSequence uri, CharSequence name, CharSequence content)
Creates an element with no attributes and the specified text content. |
void | createElement(CharSequence uri, CharSequence name, Attributes attrs)
Creates an empty element with the specified attributes. |
void | createElement(CharSequence uri, CharSequence name, Attributes attrs, CharSequence content)
Creates an element with the specified attributes and text content. |
void | endCDATA()
Ends a CDATA section in the output. |
void | endDocument() |
void | endDTD() |
void | endElement(QName qname)
Ends an element. |
void | endElement(String uri, String name)
Ends an element. |
void | endElement(String uri, String name, String qname)
Ends an element. |
void | endEntity(String name) |
void | endPrefixMapping(String prefix)
Adds a set of namespace mappings to the current namespace context. |
protected void | finishPendingStartElement() |
protected void | flushInternal() |
int | getAutoFlush()
Gets the autoflush threshold. |
int | getDepth()
Gets the current output tree depth. |
CharSequence | getEncoding() |
Boolean | getStandalone() |
CharSequence | getVersion() |
void | ignorableWhitespace(char[] characters, int offset, int length) |
protected void | indent(int depth) |
boolean | isIndented() |
void | processingInstruction(String target, String data) |
void | setAutoFlush(int threshold)
Sets the document depth at which the underlying writer is
automatically flushed. |
void | setDocumentLocator(Locator locator) |
void | setEncoding(CharSequence encoding) |
void | setIndented(boolean indented) |
void | setStandalone(Boolean standalone) |
void | setVersion(CharSequence version) |
void | skippedEntity(String name) |
void | startCDATA()
Starts a CDATA section in the output. |
void | startDocument() |
void | startDTD(String name, String publicid, String systemid) |
void | startElement(QName qname)
Start an element with no attributes. |
void | startElement(QName qname, Attributes attrs)
Start an element with the specified attributes. |
void | startElement(String uri, String name)
Start an element with no attributes. |
void | startElement(String uri, String name, String qname)
Start an element with no attributes. |
void | startElement(String uri, String name, String qname, Attributes attrs)
Start an element with the specified attributes. |
void | startEntity(String name) |
void | startPrefixMapping(String prefix, String uri)
Adds a namespace mapping to the current namespace context. |
protected void | writeAttributes(Attributes attrs) |
protected void | writeNamespace(CharSequence uri, CharSequence prefix) |
protected void | writeQName(CharSequence uri, CharSequence name) |
protected void | writeWithEscapes(CharSequence value, CharSequence charsToEscape) |
XmlWriter
that wraps another writer.Parameters: out the wrapped writer
Parameters: root the root of the DOM subtree
Throws: IOException when the underlying writer does
Throws: IOException when the underlying writer does
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element content the text value of the element
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element attrs the attribute names mapped to their corresponding values
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element attrs the attribute names mapped to their corresponding values content the text value of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element content the text value of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element attrs the attribute names mapped to their corresponding values
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element attrs the attribute names mapped to their corresponding values content the text value of the element
Throws: IOException when the underlying writer does
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element
Throws: IOException when the underlying writer does
Parameters: map a map of namespace URIs to prefixes.
Returns: the current autoflush threshold
Parameters: threshold the new threshold value
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element
Throws: IOException when the underlying writer does
Parameters: qname the qualified name of the element attrs the attribute names mapped to their corresponding values
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element
Throws: IOException when the underlying writer does
Parameters: uri the namespace URI of the element name the local name of the element attrs the attribute names mapped to their corresponding values
Throws: IOException when the underlying writer does
Parameters: uri the URI of the new namespace prefix the prefix used when writing tags in the namespace