APIdia Launch Partner
Top Description Methods
com.sun.org.apache.xml.internal.serialize

public Interface Serializer

Known Direct Implementers
com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer
Annotations
@Deprecated
Imports
java.io.IOException, .OutputStream, .Writer, org.xml.sax.ContentHandler, .DocumentHandler

Deprecated

As of JDK 9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation is replaced by that of Xalan. Main class com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl is replaced by com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl.

Interface for a DOM serializer implementation, factory for DOM and SAX serializers, and static methods for serializing DOM documents.

To serialize a document using SAX events, create a compatible serializer and pass it around as a org.xml.sax.DocumentHandler. If an I/O error occurs while serializing, it will be thrown by DocumentHandler#endDocument. The SAX serializer may also be used as org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler and org.xml.sax.ext.LexicalHandler.

To serialize a DOM document or DOM element, create a compatible serializer and call it's DOMSerializer#serialize(Document) or DOMSerializer#serialize(Element) methods. Both methods would produce a full XML document, to serizlie only the portion of the document use OutputFormat#setOmitXMLDeclaration and specify no document type.

The OutputFormat dictates what underlying serialized is used to serialize the document based on the specified method. If the output format or method are missing, the default is an XML serializer with UTF-8 encoding and now indentation.

Authors
Assaf Arkin, Scott Boag
See Also
DocumentHandler, ContentHandler, OutputFormat, DOMSerializer

Method Summary

Modifier and TypeMethod and Description
public ContentHandler
asContentHandler()

Return a ContentHandler interface into this serializer.

public DocumentHandler
asDocumentHandler()
References Deprecated DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.

Return a DocumentHandler interface into this serializer.

public DOMSerializer
asDOMSerializer()
References Deprecated DOMSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

Return a DOMSerializer interface into this serializer.

public void
setOutputByteStream(OutputStream output)

Specifies an output stream to which the document should be serialized.

public void
setOutputCharStream(Writer output)

Specifies a writer to which the document should be serialized.

public void
setOutputFormat(OutputFormat
The output format to use
format
)
References Deprecated OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

Specifies an output format for this serializer.

Method Detail

asContentHandlerback to summary
public ContentHandler asContentHandler() throws IOException

Return a ContentHandler interface into this serializer. If the serializer does not support the ContentHandler interface, it should return null.

asDocumentHandlerback to summary
public DocumentHandler asDocumentHandler() throws IOException

References Deprecated

DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Return a DocumentHandler interface into this serializer. If the serializer does not support the DocumentHandler interface, it should return null.

asDOMSerializerback to summary
public DOMSerializer asDOMSerializer() throws IOException

References Deprecated

DOMSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Return a DOMSerializer interface into this serializer. If the serializer does not support the DOMSerializer interface, it should return null.

setOutputByteStreamback to summary
public void setOutputByteStream(OutputStream output)

Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

setOutputCharStreamback to summary
public void setOutputCharStream(Writer output)

Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

setOutputFormatback to summary
public void setOutputFormat(OutputFormat format)

References Deprecated

OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document.

Parameters
format:OutputFormat

The output format to use