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.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.
DEBUG
protected static final boolean DEBUG
- false
PREFIX
protected static final String PREFIX
fDOML1
protected boolean fDOML1
fLocalNSBinder
protected org.apache.xerces.util.NamespaceSupport fLocalNSBinder
stores all namespace bindings on the current element
fNSBinder
protected org.apache.xerces.util.NamespaceSupport fNSBinder
stores namespaces in scope
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.
fSymbolTable
protected org.apache.xerces.util.SymbolTable fSymbolTable
symbol table for serialization
characters
public void characters(char[] chars,
int start,
int length)
throws org.xml.sax.SAXException
- characters in interface BaseMarkupSerializer
printCDATAText
protected final void printCDATAText(String text)
throws IOException
- printCDATAText in interface BaseMarkupSerializer
printEscaped
protected void printEscaped(String source)
throws IOException
- printEscaped in interface XMLSerializer
printText
protected void printText(String text,
boolean preserveSpace,
boolean unescaped)
throws IOException
- printText in interface XMLSerializer
printText
protected void printText(char[] chars,
int start,
int length,
boolean preserveSpace,
boolean unescaped)
throws IOException
- printText in interface XMLSerializer
printXMLChar
protected final void printXMLChar(int ch)
throws IOException
print text data
- printXMLChar in interface XMLSerializer
surrogates
protected final void surrogates(int high,
int low)
throws IOException
- surrogates in interface BaseMarkupSerializer