Top Description Methods
com.sun.xml.txw2.output

public Interface XmlSerializer

Known Direct Implementers
com.sun.xml.txw2.output.DomSerializer, com.sun.xml.txw2.output.DumpSerializer, com.sun.xml.txw2.output.SaxSerializer, com.sun.xml.txw2.output.StaxSerializer, com.sun.xml.txw2.output.StreamSerializer, com.sun.xml.txw2.output.TXWSerializer
Imports
com.sun.xml.txw2.TypedXmlWriter

Low-level typeless XML writer driven from 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.

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 XmlSerializer implementation should just use the prefix specified.

Author
Kohsuke Kawaguchi ([email protected])

Method Summary

Modifier and TypeMethod and Description
public void
beginStartTag(String
the namespace URI of the element. Can be empty but never be null.
uri
,
String
the local name of the element.
localName
,
String
the prefix that should be used for this element. Can be empty, but never null.
prefix
)

Begins writing a start tag.

public void
cdata(StringBuilder
CDATA
text
)

Writes CDATA.

public void
comment(StringBuilder
a comment
comment
)

Writes a comment.

public void
endDocument()

The last method to be called.

public void
endStartTag(String
the namespace URI of the element. Can be empty but never be null.
uri
,
String
the local name of the element.
localName
,
String
the prefix that should be used for this element. Can be empty, but never null.
prefix
)

Completes the start tag.

public void
endTag()

Writes an end tag.

public void
flush()

Flush the buffer.

public void
startDocument()

The first method to be called.

public void
text(StringBuilder
The character data to be written. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.
text
)

Writes PCDATA.

public void
writeAttribute(String
the namespace URI of the attribute. Can be empty but never be null.
uri
,
String
the local name of the attribute.
localName
,
String
the prefix that should be used for this attribute. Can be empty, but never null.
prefix
,
StringBuilder
The value of the attribute. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.
value
)

Writes an attribute.

public void
writeXmlns(String
the prefix that is allocated. Can be empty but never be null.
prefix
,
String
the namespace URI to be declared. Can be empty but never be null.
uri
)

Writes a namespace declaration.

Method Detail

beginStartTagback to summary
public void beginStartTag(String uri, String localName, String prefix)

Begins writing a start tag.

Parameters
uri:String

the namespace URI of the element. Can be empty but never be null.

localName:String

the local name of the element.

prefix:String

the prefix that should be used for this element. Can be empty, but never null.

cdataback to summary
public void cdata(StringBuilder text)

Writes CDATA.

Parameters
text:StringBuilder

CDATA

commentback to summary
public void comment(StringBuilder comment)

Writes a comment.

Parameters
comment:StringBuilder

a comment

Exceptions
UnsupportedOperationException:
if the writer doesn't support writing a comment, it can throw this exception.
endDocumentback to summary
public void endDocument()

The last method to be called.

endStartTagback to summary
public void endStartTag(String uri, String localName, String prefix)

Completes the start tag.

Parameters
uri:String

the namespace URI of the element. Can be empty but never be null.

localName:String

the local name of the element.

prefix:String

the prefix that should be used for this element. Can be empty, but never null.

endTagback to summary
public void endTag()

Writes an end tag.

flushback to summary
public void flush()

Flush the buffer. This method is called when applications invoke TypedXmlWriter#commit(boolean) method. If the implementation performs any buffering, it should flush the buffer.

startDocumentback to summary
public void startDocument()

The first method to be called.

textback to summary
public void text(StringBuilder text)

Writes PCDATA.

Parameters
text:StringBuilder

The character data to be written. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.

writeAttributeback to summary
public void writeAttribute(String uri, String localName, String prefix, StringBuilder value)

Writes an attribute.

Parameters
uri:String

the namespace URI of the attribute. Can be empty but never be null.

localName:String

the local name of the attribute.

prefix:String

the prefix that should be used for this attribute. Can be empty, but never null.

value:StringBuilder

The value of the attribute. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.

writeXmlnsback to summary
public void writeXmlns(String prefix, String uri)

Writes a namespace declaration.

Parameters
prefix:String

the prefix that is allocated. Can be empty but never be null.

uri:String

the namespace URI to be declared. Can be empty but never be null.