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. See the Xerces documentation for more information.
The serializer must be initialized with the proper writer and
output format before it can be used by calling setOutputCharStream
or setOutputByteStream for the writer and setOutputFormat
for the output format.
The serializer can be reused any number of times, but cannot be used concurrently by two threads.
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. DOM serializing is done
by calling serialize(Document) and SAX serializing is done by firing
SAX events and using the serializer as a document handler.
This also applies to derived class.
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..
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.
When indenting, the serializer is capable of detecting seemingly element content, and serializing these elements indented on separate lines. An element is serialized indented when it is the first or last child of an element, or immediate following or preceding another element.
Serializer, org.w3c.dom.ls.LSSerializer
| Modifier and Type | Field and Description |
|---|---|
| protected String | _docTypePublicId
The system identifier of the document type, if known. |
| protected String | _docTypeSystemId
The system identifier of the document type, if known. |
| private int | _elementStateCount
The index of the next state to place in the array, or one plus the index of the current state. |
| private ElementState[] | _elementStates
Holds array of all element states that have been entered. |
| protected EncodingInfo | _encodingInfo
Deprecated
as a consequence of
EncodingInfo being deprecated.
|
| protected OutputFormat | _format
The output format associated with this serializer. |
| protected boolean | _indenting
True if indenting printer. |
| private OutputStream | _output
The output stream. |
| protected Hashtable | _prefixes
Association between namespace URIs (keys) and prefixes (values). |
| private boolean | _prepared
True if the serializer has been prepared. |
| private Vector | _preRoot
Vector holding comments and PIs that come before the root
element (even after it), see |
| protected Printer | _printer
The printer used for printing text parts. |
| protected boolean | _started
If the document has been started (header serialized), this flag is set to true so it's not started twice. |
| private Writer | _writer
The underlying writer. |
| protected Node | fCurrentNode
Current node that is being processed |
| protected final DOMErrorImpl | |
| protected DOMErrorHandler | |
| protected LSSerializerFilter | |
| protected short | |
| protected final StringBuffer | fStrBuffer
Temporary buffer to store character data |
| Access | Constructor and Description |
|---|---|
| protected | BaseMarkupSerializer(OutputFormat format)
Deprecated
as a consequence of
Protected constructor can only be used by derived class.
OutputFormat being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public ContentHandler | asContentHandler()
Implements org. ContentHandler interface into this serializer.
|
| public DocumentHandler | asDocumentHandler()
Implements org.
Deprecated
as a consequence of
Return a DocumentHandler being deprecated.
DocumentHandler interface into this serializer.
|
| public DOMSerializer | asDOMSerializer()
Implements org.
Deprecated
as a consequence of
Return a DOMSerializer being deprecated.
DOMSerializer interface into this serializer.
|
| public void | attributeDecl(String
The name of the associated element. eName, String The name of the attribute. aName, String A string representing the attribute type. type, String A string representing the attribute defaulting mode
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these applies. valueDefault, String A string representing the attribute's default value,
or null if there is none. value)Implements org. |
| public void | characters(char[]
the characters from the XML document chars, int the start position in the array start, int the number of characters to read from the array length)Implements org. |
| protected void | characters(String
The text to print text)Called to print the text contents in the prevailing element format. |
| protected void | checkUnboundNamespacePrefixedNode(Node
The node to check for unbound namespace prefices node)DOM level 3: Check a node to determine if it contains unbound namespace prefixes. |
| protected void | |
| pack-priv final void | |
| public void | comment(char[]
An array holding the characters in the comment. chars, int The starting position in the array. start, int The number of characters to use from the array. length)Implements org. |
| public void | |
| protected ElementState | Returns: The current element state
Deprecated
as a consequence of
Must be called by a method about to print any type of content.
ElementState being deprecated.
|
| public void | elementDecl(String
The element type name. name, String The content model as a normalized string. model)Implements org. |
| public void | |
| public void | endDocument()
Implements org. |
| public void | |
| public void | endEntity(String
The name of the entity that is ending. name)Implements org. |
| public void | |
| public void | endPrefixMapping(String
the prefix that was being mapped.
This is the empty string when a default mapping scope ends. prefix)Implements org. |
| public void | |
| protected ElementState | Returns: Current element state, or null
Deprecated
as a consequence of
Enter a new element state for the specified element.
ElementState being deprecated.
|
| public void | externalEntityDecl(String
The name of the entity. If it is a parameter
entity, the name will begin with '%'. name, String The entity's public identifier, or null if none
was given. publicId, String The entity's system identifier. systemId)Implements org. |
| protected void | |
| protected ElementState | Returns: Current element state
Deprecated
as a consequence of
Return the state of the current element.
ElementState being deprecated.
|
| protected abstract String | Returns: Character entity name, or nullCharacter value ch)Returns the suitable entity reference for this character value, or null if no such entity exists. |
| protected String | |
| public void | ignorableWhitespace(char[]
the characters from the XML document chars, int the start position in the array start, int the number of characters to read from the array length)Implements org. |
| public void | internalEntityDecl(String
The name of the entity. If it is a parameter
entity, the name will begin with '%'. name, String The replacement text of the entity. value)Implements org. |
| protected boolean | Returns: True if in the state of the documentReturns true if in the state of the document. |
| protected ElementState | Returns: Previous element state
Deprecated
as a consequence of
Leave the current element state and return to the
state of the parent element.
ElementState being deprecated.
|
| protected DOMError | Returns: a DOMErrorThe method modifies global DOM error object |
| public void | notationDecl(String
The notation name. name, String The notation's public identifier, or null if
none was given. publicId, String The notation's system identifier, or null if
none was given. systemId)Implements org. |
| protected void | |
| protected void | |
| protected void | printDoctypeURL(String
The document type url to print url)Print a document type public or system identifier URL. |
| protected void | |
| protected void | printEscaped(String
The string to escape source)Escapes a string so it may be printed as text content or attribute value. |
| pack-priv final void | |
| protected void | printText(char[]
The text to print chars, int The start offset start, int The number of characters length, boolean Space preserving flag preserveSpace, boolean Print unescaped unescaped)Called to print additional text with whitespace handling. |
| protected void | |
| public final void | processingInstruction(String
the processing instruction target target, String the processing instruction data, or null if
none was supplied. The data does not include any
whitespace separating it from the target code)Implements org. |
| public void | |
| public boolean | |
| public void | serialize(Element
The element to serialize elem)Implements org. |
| public void | serialize(DocumentFragment
The document fragment to serialize frag)Implements org. |
| public void | serialize(Document
The document to serialize doc)Implements org. |
| protected abstract void | |
| protected void | |
| protected void | serializePreRoot()
Comments and PIs cannot be serialized before the root element, because the root element serializes the document type, which generally comes first. |
| public void | setDocumentLocator(Locator
an object that can return the location of
any SAX document event locator)Implements org. |
| public void | setOutputByteStream(OutputStream output)
Implements org. |
| public void | setOutputCharStream(Writer writer)
Implements org. |
| public void | setOutputFormat(OutputFormat
The output format to use format)Implements org.
Deprecated
as a consequence of
Specifies an output format for this serializer.
OutputFormat being deprecated.
|
| public void | skippedEntity(String
the name of the skipped entity. If it is a
parameter entity, the name will begin with '%', and if
it is the external DTD subset, it will be the string
"[dtd]" name)Implements org. |
| public void | startCDATA()
Implements org. |
| public void | startDocument()
Implements org. |
| public final void | startDTD(String
The document type name. name, String The declared public identifier for the
external DTD subset, or null if none was declared. publicId, String The declared system identifier for the
external DTD subset, or null if none was declared.
(Note that this is not resolved against the document
base URI.) systemId)Implements org. |
| public void | startEntity(String
The name of the entity. If it is a parameter
entity, the name will begin with '%', and if it is the
external DTD subset, it will be "[dtd]". name)Implements org. |
| public void | |
| public void | startPrefixMapping(String
the Namespace prefix being declared.
An empty string is used for the default element namespace,
which has no prefix. prefix, String the Namespace URI the prefix is mapped to uri)Implements org. |
| public void | |
| protected void | |
| public void | unparsedEntityDecl(String
The unparsed entity's name. name, String The entity's public identifier, or null if none
was given. publicId, String The entity's system identifier. systemId, String The name of the associated notation. notationName)Implements org. |