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

public Class XML11Serializer

extends XMLSerializer
Class Inheritance
Annotations
@Deprecated
Imports
java.io.IOException, .OutputStream, .Writer, com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter, com.sun.org.apache.xerces.internal.util.NamespaceSupport, .SymbolTable, .XML11Char, .XMLChar, org.w3c.dom.DOMError, .Document, org.xml.sax.SAXException

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.

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 serialize(Document) or by using DOM Level 3 org.w3c.dom.ls.LSSerializer and serializing with org.w3c.dom.ls.LSSerializer#write, org.w3c.dom.ls.LSSerializer#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.

Authors
Assaf Arkin, Rahul Srivastava, Elena Litani IBM
See Also
Serializer

Field Summary

Modifier and TypeField and Description
protected static final boolean
protected boolean
protected NamespaceSupport
fLocalNSBinder

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.fLocalNSBinder.

stores all namespace bindings on the current element
protected int
protected boolean
fNamespaces

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.fNamespaces.

Controls whether namespace fixup should be performed during the serialization.
protected NamespaceSupport
protected SymbolTable
protected static final String
Inherited from com.sun.org.apache.xml.internal.serialize.XMLSerializer:
fNamespacePrefixes

Constructor Summary

AccessConstructor and Description
public
XML11Serializer()

Constructs a new serializer.

public
XML11Serializer(OutputFormat format)
References Deprecated OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

Constructs a new serializer.

public
XML11Serializer(Writer
The writer to use
writer
,
OutputFormat
The output format to use, null for the default
format
)
References Deprecated OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

Constructs a new serializer that writes to the specified writer using the specified output format.

public
XML11Serializer(OutputStream
The output stream to use
output
,
OutputFormat
The output format to use, null for the default
format
)
References Deprecated OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

Constructs a new serializer that writes to the specified output stream using the specified output format.

Method Summary

Modifier and TypeMethod and Description
public void
protected final void
protected void
printEscaped(String source)

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printEscaped.

Escapes a string so it may be printed as text content or attribute value.

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

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printText.

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

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printText.

Called to print additional text with whitespace handling.

protected final void
public boolean
protected final void
Inherited from com.sun.org.apache.xml.internal.serialize.XMLSerializer:
checkUnboundNamespacePrefixedNodeendElementendElementendElementIOgetEntityRefserializeElementsetNamespacessetOutputFormatstartDocumentstartElementstartElement

Field Detail

DEBUGback to summary
protected static final boolean DEBUG

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.DEBUG.

fDOML1back to summary
protected boolean fDOML1
fLocalNSBinderback to summary
protected NamespaceSupport fLocalNSBinder

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.fLocalNSBinder.

stores all namespace bindings on the current element

fNamespaceCounterback to summary
protected int fNamespaceCounter
fNamespacesback to summary
protected boolean fNamespaces

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.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.

fNSBinderback to summary
protected NamespaceSupport fNSBinder

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.fNSBinder.

stores namespaces in scope

fSymbolTableback to summary
protected SymbolTable fSymbolTable

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.fSymbolTable.

symbol table for serialization

PREFIXback to summary
protected static final String PREFIX

Hides com.sun.org.apache.xml.internal.serialize.XMLSerializer.PREFIX.

Constructor Detail

XML11Serializerback to summary
public XML11Serializer()

Constructs a new serializer. The serializer cannot be used without calling setOutputCharStream or setOutputByteStream first.

XML11Serializerback to summary
public XML11Serializer(OutputFormat format)

References Deprecated

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

See corresponding docs for further information.

Constructs a new serializer. The serializer cannot be used without calling setOutputCharStream or setOutputByteStream first.

XML11Serializerback to summary
public XML11Serializer(Writer writer, OutputFormat format)

References Deprecated

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

See corresponding docs for further information.

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:Writer

The writer to use

format:OutputFormat

The output format to use, null for the default

XML11Serializerback to summary
public XML11Serializer(OutputStream output, OutputFormat format)

References Deprecated

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

See corresponding docs for further information.

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:OutputStream

The output stream to use

format:OutputFormat

The output format to use, null for the default

Method Detail

charactersback to summary
public void characters(char[] chars, int start, int length) throws SAXException

Overrides com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.characters.

Implements org.xml.sax.ContentHandler.characters, org.xml.sax.DocumentHandler.characters.

Doc from org.xml.sax.ContentHandler.characters.

Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Individual characters may consist of more than one Java char value. There are two important cases where this happens, because characters can't be represented in just sixteen bits. In one case, characters are represented in a Surrogate Pair, using two special Unicode values. Such characters are in the so-called "Astral Planes", with a code point above U+FFFF. A second case involves composite characters, such as a base character combining with one or more accent characters.

Your code should not assume that algorithms using char-at-a-time idioms will be working in character units; in some cases they will split characters. This is relevant wherever XML permits arbitrary characters, such as attribute values, processing instruction data, and comments as well as in data reported from this method. It's also generally relevant whenever Java code manipulates internationalized text; the issue isn't unique to XML.

Note that some parsers will report whitespace in element content using the ignorableWhitespace method rather than this one (validating parsers must do so).

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
printCDATATextback to summary
protected final void printCDATAText(String text) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.printCDATAText.

printEscapedback to summary
protected void printEscaped(String source) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printEscaped.

Doc from com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.printEscaped.

Escapes a string so it may be printed as text content or attribute value. Non printable characters are escaped using character references. Where the format specifies a deault entity reference, that reference is used (e.g. <).

printTextback to summary
protected void printText(String text, boolean preserveSpace, boolean unescaped) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printText.

printTextback to summary
protected void printText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printText.

Doc from com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.printText.

Called to print additional text with whitespace handling. If spaces are preserved, the text is printed as if by calling printText(String, boolean, boolean) with a call to Printer#breakLine for each new line. If spaces are not preserved, the text is broken at space boundaries if longer than the line width; Multiple spaces are printed as such, but spaces at beginning of line are removed.

printXMLCharback to summary
protected final void printXMLChar(int ch) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.printXMLChar.

Doc from com.sun.org.apache.xml.internal.serialize.XMLSerializer.printXMLChar.

print text data

resetback to summary
public boolean reset()

Overrides com.sun.org.apache.xml.internal.serialize.XMLSerializer.reset.

surrogatesback to summary
protected final void surrogates(int high, int low, boolean inContent) throws IOException

Overrides com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.surrogates.