org.apache.xml.serialize

Interface Serializer

public interface Serializer

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 or DOMSerializer methods. Both methods would produce a full XML document, to serizlie only the portion of the document use OutputFormat 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.

Version: $Revision: 1.14 $ $Date: 2004/02/24 23:34:03 $

Author: Assaf Arkin Scott Boag

See Also: DocumentHandler ContentHandler OutputFormat DOMSerializer

Method Summary
ContentHandlerasContentHandler()
Return a ContentHandler interface into this serializer.
DocumentHandlerasDocumentHandler()
Return a DocumentHandler interface into this serializer.
DOMSerializerasDOMSerializer()
Return a DOMSerializer interface into this serializer.
voidsetOutputByteStream(OutputStream output)
Specifies an output stream to which the document should be serialized.
voidsetOutputCharStream(Writer output)
Specifies a writer to which the document should be serialized.
voidsetOutputFormat(OutputFormat format)
Specifies an output format for this serializer.

Method Detail

asContentHandler

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

asDocumentHandler

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

asDOMSerializer

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

setOutputByteStream

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.

setOutputCharStream

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.

setOutputFormat

public 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

Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.