DomSerializer
, DumpSerializer
, SaxSerializer
, StaxSerializer
, StreamSerializer
, TXWSerializer
public interface XmlSerializer
TypedXmlWriter
.
Applications can use one of the predefined implementations to send TXW output to the desired location/format, or they can choose to implement this interface for custom output.
One XmlSerializer
instance is responsible for writing
one XML document.
WHOLE_SEQUENCE := startDocument ELEMENT endDocument ELEMENT := beginStartTag writeXmlns* writeAttribute* endStartTag CONTENT endTag CONTENT := (text|ELEMENT)*
TXW maintains all the in-scope namespace bindings and prefix allocation.
The XmlSerializer
implementation should just use the prefix
specified.
Modifier and Type | Method | Description |
---|---|---|
void |
beginStartTag(java.lang.String uri,
java.lang.String localName,
java.lang.String prefix) |
Begins writing a start tag.
|
void |
cdata(java.lang.StringBuilder text) |
Writes CDATA.
|
void |
comment(java.lang.StringBuilder comment) |
Writes a comment.
|
void |
endDocument() |
The last method to be called.
|
void |
endStartTag(java.lang.String uri,
java.lang.String localName,
java.lang.String prefix) |
Completes the start tag.
|
void |
endTag() |
Writes an end tag.
|
void |
flush() |
Flush the buffer.
|
void |
startDocument() |
The first method to be called.
|
void |
text(java.lang.StringBuilder text) |
Writes PCDATA.
|
void |
writeAttribute(java.lang.String uri,
java.lang.String localName,
java.lang.String prefix,
java.lang.StringBuilder value) |
Writes an attribute.
|
void |
writeXmlns(java.lang.String prefix,
java.lang.String uri) |
Writes a namespace declaration.
|
void startDocument()
void beginStartTag(java.lang.String uri, java.lang.String localName, java.lang.String prefix)
uri
- the namespace URI of the element. Can be empty but never be null.prefix
- the prefix that should be used for this element. Can be empty,
but never null.void writeAttribute(java.lang.String uri, java.lang.String localName, java.lang.String prefix, java.lang.StringBuilder value)
value
- The value of the attribute. It's the callee's responsibility to
escape special characters (such as <, >, and &) in this buffer.uri
- the namespace URI of the attribute. Can be empty but never be null.prefix
- the prefix that should be used for this attribute. Can be empty,
but never null.void writeXmlns(java.lang.String prefix, java.lang.String uri)
uri
- the namespace URI to be declared. Can be empty but never be null.prefix
- the prefix that is allocated. Can be empty but never be null.void endStartTag(java.lang.String uri, java.lang.String localName, java.lang.String prefix)
uri
- the namespace URI of the element. Can be empty but never be null.prefix
- the prefix that should be used for this element. Can be empty,
but never null.void endTag()
void text(java.lang.StringBuilder text)
text
- The character data to be written. It's the callee's responsibility to
escape special characters (such as <, >, and &) in this buffer.void cdata(java.lang.StringBuilder text)
void comment(java.lang.StringBuilder comment)
java.lang.UnsupportedOperationException
- if the writer doesn't support writing a comment, it can throw this exception.void endDocument()
void flush()
TypedXmlWriter.commit(boolean)
method. If the implementation performs any buffering, it should flush the buffer.Copyright © 2017 Oracle Corporation. All rights reserved.