public interface

Serializer

org.apache.xml.serialize.Serializer
Known Indirect Subclasses

This interface is deprecated.
This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information.

Class Overview

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 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 serialize(Document) or serialize(Element) methods. Both methods would produce a full XML document, to serizlie only the portion of the document use setOmitXMLDeclaration(boolean) 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.

See Also

Summary

Public Methods
abstract ContentHandler asContentHandler()
Return a ContentHandler interface into this serializer.
abstract DOMSerializer asDOMSerializer()
Return a DOMSerializer interface into this serializer.
abstract DocumentHandler asDocumentHandler()
Return a DocumentHandler interface into this serializer.
abstract void setOutputByteStream(OutputStream output)
Specifies an output stream to which the document should be serialized.
abstract void setOutputCharStream(Writer output)
Specifies a writer to which the document should be serialized.
abstract void setOutputFormat(OutputFormat format)
Specifies an output format for this serializer.

Public Methods

public abstract ContentHandler asContentHandler ()

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

Throws
IOException

public abstract DOMSerializer asDOMSerializer ()

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

Throws
IOException

public abstract DocumentHandler asDocumentHandler ()

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

Throws
IOException

public abstract 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.

public abstract 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.

public abstract void setOutputFormat (OutputFormat format)

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 The output format to use