Deprecated
As of JDK 9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation
is replaced by that of Xalan. Main class
com. is replaced
by com..
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
References Deprecated
Holds array of all element states that have been entered.
ElementState is deprecated or references (maybe indirectly) at least one deprecated element.
|
| protected EncodingInfo | _encodingInfo
References Deprecated
EncodingInfo is deprecated or references (maybe indirectly) at least one deprecated element.
|
| protected OutputFormat | _format
References Deprecated
The output format associated with this serializer.
OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.
|
| protected boolean | _indenting
True if indenting printer. |
| private OutputStream | _output
The output stream. |
| protected Map | _prefixes
Association between namespace URIs (keys) and prefixes (values). |
| private boolean | _prepared
True if the serializer has been prepared. |
| private List | _preRoot
List holding comments and PIs that come before the root
element (even after it), see |
| protected Printer | |
| 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)
References Deprecated
OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.
Protected constructor can only be used by derived class. |
| Modifier and Type | Method and Description |
|---|---|
| public ContentHandler | asContentHandler()
Implements com. Return a |
| public DocumentHandler | asDocumentHandler()
Implements com.
References Deprecated
DocumentHandler is deprecated or references (maybe indirectly) at least one deprecated element.
Return a |
| public DOMSerializer | asDOMSerializer()
Implements com.
References Deprecated
DOMSerializer is deprecated or references (maybe indirectly) at least one deprecated element.
Return a |
| public void | attributeDecl(String eName, String aName, String type, String valueDefault, String value)
Implements org. Report an attribute type declaration. |
| public void | characters(char[] chars, int start, int length)
Implements org. Receive notification of character data. |
| 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[] chars, int start, int length)
Implements org. Report an XML comment anywhere in the document. |
| public void | |
| protected ElementState | Returns: The current element state
References Deprecated
ElementState is deprecated or references (maybe indirectly) at least one deprecated element.
Must be called by a method about to print any type of content. |
| public void | elementDecl(String name, String model)
Implements org. Report an element type declaration. |
| public void | |
| public void | endDocument()
Implements org. Called at the end of the document to wrap it up. |
| public void | |
| public void | endEntity(String name)
Implements org. Report the end of an entity. |
| public void | |
| public void | endPrefixMapping(String prefix)
Implements org. End the scope of a prefix-URI mapping. |
| public void | |
| protected ElementState | Returns: Current element state, or null
References Deprecated
ElementState is deprecated or references (maybe indirectly) at least one deprecated element.
Enter a new element state for the specified element. |
| public void | externalEntityDecl(String name, String publicId, String systemId)
Implements org. Report a parsed external entity declaration. |
| protected void | |
| protected ElementState | Returns: Current element state
References Deprecated
ElementState is deprecated or references (maybe indirectly) at least one deprecated element.
Return the state of the current element. |
| 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[] chars, int start, int length)
Implements org. Receive notification of ignorable whitespace in element content. |
| public void | internalEntityDecl(String name, String value)
Implements org. Report an internal entity declaration. |
| 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
References Deprecated
ElementState is deprecated or references (maybe indirectly) at least one deprecated element.
Leave the current element state and return to the state of the parent element. |
| protected DOMError | Returns: a DOMErrorThe method modifies global DOM error object |
| public void | notationDecl(String name, String publicId, String systemId)
Implements org. Receive notification of a notation declaration event. |
| 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 target, String code)
Implements org. Receive notification of a processing instruction. |
| public void | |
| public boolean | |
| public void | serialize(Element
The element to serialize elem)Implements com. Serializes the DOM element using the previously specified writer and output format. |
| public void | |
| public void | serialize(DocumentFragment
The document fragment to serialize frag)Implements com. Serializes the DOM document fragmnt using the previously specified writer and output format. |
| public void | serialize(Document
The document to serialize doc)Implements com. Serializes the DOM document using the previously specified writer and output format. |
| protected void | |
| protected void | |
| 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 locator)
Implements org. Receive an object for locating the origin of SAX document events. |
| public void | setOutputByteStream(OutputStream output)
Implements com. Specifies an output stream to which the document should be serialized. |
| public void | setOutputCharStream(Writer writer)
Implements com. Specifies a writer to which the document should be serialized. |
| public void | setOutputFormat(OutputFormat format)
Implements com.
References Deprecated
OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.
Specifies an output format for this serializer. |
| public void | skippedEntity(String name)
Implements org. Receive notification of a skipped entity. |
| public void | startCDATA()
Implements org. Report the start of a CDATA section. |
| public void | startDocument()
Implements org. Receive notification of the beginning of a document. |
| public final void | startDTD(String name, String publicId, String systemId)
Implements org. Report the start of DTD declarations, if any. |
| public void | startEntity(String name)
Implements org. Report the beginning of some internal and external XML entities. |
| public void | |
| public void | startPrefixMapping(String prefix, String uri)
Implements org. Begin the scope of a prefix-URI Namespace mapping. |
| public void | |
| protected void | |
| public void | unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
Implements org. Receive notification of an unparsed entity declaration event. |