org.apache.xml.serialize

Class XML11Serializer

public class XML11Serializer extends XMLSerializer

Implements an XML serializer supporting both DOM and SAX pretty serializing. For usage instructions see Serializer.

If an output stream is used, the encoding is taken from the output format (defaults to UTF-8). If a writer is used, make sure the writer uses the same encoding (if applies) as specified in the output format.

The serializer supports both DOM and SAX. SAX serializing is done by firing SAX events and using the serializer as a document handler. DOM serializing is done by calling XML11Serializer or by using DOM Level 3 org.w3c.dom.ls.DOMSerializer and serializing with org.w3c.dom.ls.DOMSerializer#write, org.w3c.dom.ls.DOMSerializer#writeToString.

If an I/O exception occurs while serializing, the serializer will not throw an exception directly, but only throw it at the end of serializing (either DOM or SAX's org.xml.sax.DocumentHandler#endDocument.

For elements that are not specified as whitespace preserving, the serializer will potentially break long text lines at space boundaries, indent lines, and serialize elements on separate lines. Line terminators will be regarded as spaces, and spaces at beginning of line will be stripped.

Version: $Revision: 1.14 $ $Date: 2005/05/03 11:12:21 $

Author: Assaf Arkin Rahul Srivastava Elena Litani IBM

See Also: Serializer

Field Summary
protected static booleanDEBUG
protected booleanfDOML1
protected NamespaceSupportfLocalNSBinder
stores all namespace bindings on the current element
protected intfNamespaceCounter
protected booleanfNamespaces
Controls whether namespace fixup should be performed during the serialization.
protected NamespaceSupportfNSBinder
stores namespaces in scope
protected SymbolTablefSymbolTable
symbol table for serialization
protected static StringPREFIX
Constructor Summary
XML11Serializer()
Constructs a new serializer.
XML11Serializer(OutputFormat format)
Constructs a new serializer.
XML11Serializer(Writer writer, OutputFormat format)
Constructs a new serializer that writes to the specified writer using the specified output format.
XML11Serializer(OutputStream output, OutputFormat format)
Constructs a new serializer that writes to the specified output stream using the specified output format.
Method Summary
voidcharacters(char[] chars, int start, int length)
protected voidprintCDATAText(String text)
protected voidprintEscaped(String source)
protected voidprintText(String text, boolean preserveSpace, boolean unescaped)
protected voidprintText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped)
protected voidprintXMLChar(int ch)
booleanreset()
protected voidsurrogates(int high, int low)

Field Detail

DEBUG

protected static final boolean DEBUG

fDOML1

protected boolean fDOML1

fLocalNSBinder

protected NamespaceSupport fLocalNSBinder
stores all namespace bindings on the current element

fNamespaceCounter

protected int fNamespaceCounter

fNamespaces

protected boolean fNamespaces
Controls whether namespace fixup should be performed during the serialization. NOTE: if this field is set to true the following fields need to be initialized: fNSBinder, fLocalNSBinder, fSymbolTable, XMLSymbols.EMPTY_STRING, fXmlSymbol, fXmlnsSymbol, fNamespaceCounter.

fNSBinder

protected NamespaceSupport fNSBinder
stores namespaces in scope

fSymbolTable

protected SymbolTable fSymbolTable
symbol table for serialization

PREFIX

protected static final String PREFIX

Constructor Detail

XML11Serializer

public XML11Serializer()
Constructs a new serializer. The serializer cannot be used without calling XML11Serializer or XML11Serializer first.

XML11Serializer

public XML11Serializer(OutputFormat format)
Constructs a new serializer. The serializer cannot be used without calling XML11Serializer or XML11Serializer first.

XML11Serializer

public XML11Serializer(Writer writer, OutputFormat format)
Constructs a new serializer that writes to the specified writer using the specified output format. If format is null, will use a default output format.

Parameters: writer The writer to use format The output format to use, null for the default

XML11Serializer

public XML11Serializer(OutputStream output, OutputFormat format)
Constructs a new serializer that writes to the specified output stream using the specified output format. If format is null, will use a default output format.

Parameters: output The output stream to use format The output format to use, null for the default

Method Detail

characters

public void characters(char[] chars, int start, int length)

printCDATAText

protected final void printCDATAText(String text)

printEscaped

protected void printEscaped(String source)

printText

protected void printText(String text, boolean preserveSpace, boolean unescaped)

printText

protected void printText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped)

printXMLChar

protected final void printXMLChar(int ch)

reset

public boolean reset()

surrogates

protected final void surrogates(int high, int low)
Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.