-
- All Known Implementing Classes:
DomSerializer,DumpSerializer,SaxSerializer,StaxSerializer,StreamSerializer,TXWSerializer
public interface XmlSerializerLow-level typeless XML writer driven fromTypedXmlWriter.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
XmlSerializerinstance is responsible for writing one XML document.Call Sequence
TXW calls methods on this interface in the following order: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
XmlSerializerimplementation should just use the prefix specified.- Author:
- Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbeginStartTag(String uri, String localName, String prefix)Begins writing a start tag.voidcdata(StringBuilder text)Writes CDATA.voidcomment(StringBuilder comment)Writes a comment.voidendDocument()The last method to be called.voidendStartTag(String uri, String localName, String prefix)Completes the start tag.voidendTag()Writes an end tag.voidflush()Flush the buffer.voidstartDocument()The first method to be called.voidtext(StringBuilder text)Writes PCDATA.voidwriteAttribute(String uri, String localName, String prefix, StringBuilder value)Writes an attribute.voidwriteXmlns(String prefix, String uri)Writes a namespace declaration.
-
-
-
Method Detail
-
startDocument
void startDocument()
The first method to be called.
-
beginStartTag
void beginStartTag(String uri, String localName, String prefix)
Begins writing a start tag.- Parameters:
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.
-
writeAttribute
void writeAttribute(String uri, String localName, String prefix, StringBuilder value)
Writes an attribute.- Parameters:
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.
-
writeXmlns
void writeXmlns(String prefix, String uri)
Writes a namespace declaration.- Parameters:
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.
-
endStartTag
void endStartTag(String uri, String localName, String prefix)
Completes the start tag.- Parameters:
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.
-
endTag
void endTag()
Writes an end tag.
-
text
void text(StringBuilder text)
Writes PCDATA.- Parameters:
text- The character data to be written. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.
-
cdata
void cdata(StringBuilder text)
Writes CDATA.
-
comment
void comment(StringBuilder comment)
Writes a comment.- Throws:
UnsupportedOperationException- if the writer doesn't support writing a comment, it can throw this exception.
-
endDocument
void endDocument()
The last method to be called.
-
flush
void flush()
Flush the buffer. This method is called when applications invokeTypedXmlWriter.commit(boolean)method. If the implementation performs any buffering, it should flush the buffer.
-
-