public class DOMSerializerImpl
extends java.lang.Object
implements org.w3c.dom.ls.LSSerializer, org.w3c.dom.DOMConfiguration
XMLSerializer
.
LSSerializer provides an API for serializing (writing) a DOM document out in an
XML document. The XML data is written to an output stream.
During serialization of XML data, namespace fixup is done when possible as
defined in DOM Level 3 Core, Appendix B.Modifier and Type | Field and Description |
---|---|
protected static short |
CDATA
Deprecated.
|
protected static short |
COMMENTS
Deprecated.
|
protected static short |
DISCARDDEFAULT
Deprecated.
|
protected static short |
DOM_ELEMENT_CONTENT_WHITESPACE
Deprecated.
|
protected static short |
ENTITIES
Deprecated.
|
protected short |
features
Deprecated.
REVISIT: Currently we handle 3 different configurations, would be nice just have one configuration
that has different recognized parameters depending if it is used in Core/LS.
|
protected static short |
INFOSET
Deprecated.
|
protected static short |
NAMESPACES
Deprecated.
|
protected static short |
NSDECL
Deprecated.
|
protected static short |
PRETTY_PRINT
Deprecated.
|
protected static short |
SPLITCDATA
Deprecated.
|
protected static short |
WELLFORMED
Deprecated.
|
protected static short |
XMLDECL
Deprecated.
|
Constructor and Description |
---|
DOMSerializerImpl()
Deprecated.
Constructs a new LSSerializer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canSetParameter(java.lang.String name,
java.lang.Object state)
Deprecated.
DOM L3-EXPERIMENTAL:
Check if parameter can be set
|
org.w3c.dom.DOMConfiguration |
getDomConfig()
Deprecated.
The
DOMConfiguration object used by the
LSSerializer when serializing a DOM node. |
org.w3c.dom.ls.LSSerializerFilter |
getFilter()
Deprecated.
When the application provides a filter, the serializer will call out
to the filter before serializing each Node.
|
java.lang.String |
getNewLine()
Deprecated.
DOM L3 EXPERIMENTAL:
The end-of-line sequence of characters to be used in the XML being
written out.
|
java.lang.Object |
getParameter(java.lang.String name)
Deprecated.
DOM L3-EXPERIMENTAL:
Getter for boolean and object parameters
|
org.w3c.dom.DOMStringList |
getParameterNames()
Deprecated.
DOM Level 3 Core CR - Experimental.
|
void |
setFilter(org.w3c.dom.ls.LSSerializerFilter filter)
Deprecated.
When the application provides a filter, the serializer will call out
to the filter before serializing each Node.
|
void |
setNewLine(java.lang.String newLine)
Deprecated.
DOM L3 EXPERIMENTAL:
The end-of-line sequence of characters to be used in the XML being
written out.
|
void |
setParameter(java.lang.String name,
java.lang.Object value)
Deprecated.
DOM L3-EXPERIMENTAL:
Setter for boolean and object parameters
|
boolean |
write(org.w3c.dom.Node node,
org.w3c.dom.ls.LSOutput destination)
Deprecated.
Serialize the specified node as described above in the general
description of the
LSSerializer interface. |
java.lang.String |
writeToString(org.w3c.dom.Node wnode)
Deprecated.
DOM L3 EXPERIMENTAL:
Serialize the specified node as described above in the description of
LSSerializer . |
boolean |
writeToURI(org.w3c.dom.Node node,
java.lang.String URI)
Deprecated.
Serialize the specified node as described above in the general
description of the
LSSerializer interface. |
protected short features
protected static final short NAMESPACES
protected static final short WELLFORMED
protected static final short ENTITIES
protected static final short CDATA
protected static final short SPLITCDATA
protected static final short COMMENTS
protected static final short DISCARDDEFAULT
protected static final short INFOSET
protected static final short XMLDECL
protected static final short NSDECL
protected static final short DOM_ELEMENT_CONTENT_WHITESPACE
protected static final short PRETTY_PRINT
public DOMSerializerImpl()
XMLSerializer
and
initializes the following fields: fNSBinder, fLocalNSBinder, fSymbolTable,
fEmptySymbol, fXmlSymbol, fXmlnsSymbol, fNamespaceCounter, fFeatures.public org.w3c.dom.DOMConfiguration getDomConfig()
org.w3c.dom.ls.LSSerializer
DOMConfiguration
object used by the
LSSerializer
when serializing a DOM node.
DOMConfiguration
objects for
LSSerializer
adds, or modifies, the following
parameters:
"canonical-form"
true
true
will set the parameters
"format-pretty-print", "discard-default-content", and "xml-declaration
", to false
. Setting one of those parameters to
true
will set this parameter to false
.
Serializing an XML 1.1 document when "canonical-form" is
true
will generate a fatal error. false
"discard-default-content"
true
Attr.specified
attribute to decide what attributes
should be discarded. Note that some implementations might use
whatever information available to the implementation (i.e. XML
schema, DTD, the Attr.specified
attribute, and so on) to
determine what attributes and content to discard if this parameter is
set to true
. false
"format-pretty-print"
true
false
"ignore-unknown-character-denormalizations"
true
"unknown-character-denormalization"
warning (instead of
raising an error, if this parameter is not set) and ignore any
possible denormalizations caused by these characters. false
"normalize-characters"
DOMConfiguration
in [DOM Level 3 Core]
. Unlike in the Core, the default value for this parameter is
true
. While DOM implementations are not required to
support fully
normalizing the characters in the document according to appendix E of [XML 1.1], this
parameter must be activated by default if supported. "xml-declaration"
true
Document
, Element
, or Entity
node is serialized, the XML declaration, or text declaration, should
be included. The version (Document.xmlVersion
if the
document is a Level 3 document and the version is non-null, otherwise
use the value "1.0"), and the output encoding (see
LSSerializer.write
for details on how to find the output
encoding) are specified in the serialized XML declaration. false
"xml-declaration-needed"
warning if this will cause
problems (i.e. the serialized data is of an XML version other than [XML 1.0], or an
encoding would be needed to be able to re-parse the serialized data). getDomConfig
in interface org.w3c.dom.ls.LSSerializer
public void setParameter(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
setParameter
in interface org.w3c.dom.DOMConfiguration
name
- The name of the parameter to set.value
- The new value or null
if the user wishes to
unset the parameter. While the type of the value parameter is
defined as DOMUserData
, the object type must match the
type defined by the definition of the parameter. For example, if
the parameter is "error-handler", the value must be of type
DOMErrorHandler
.org.w3c.dom.DOMException
- NOT_FOUND_ERR: Raised when the parameter name is not recognized.
public boolean canSetParameter(java.lang.String name, java.lang.Object state)
canSetParameter
in interface org.w3c.dom.DOMConfiguration
name
- The name of the parameter to check.state
- An object. if null
, the returned value is
true
.true
if the parameter could be successfully set
to the specified value, or false
if the parameter is
not recognized or the requested value is not supported. This does
not change the current value of the parameter itself.public org.w3c.dom.DOMStringList getParameterNames()
DOMConfiguration
object and for which at least one value
can be set by the application. Note that this list can also contain
parameter names defined outside this specification.getParameterNames
in interface org.w3c.dom.DOMConfiguration
public java.lang.Object getParameter(java.lang.String name) throws org.w3c.dom.DOMException
getParameter
in interface org.w3c.dom.DOMConfiguration
name
- The name of the parameter.null
if no object has been associated or if the
parameter is not supported.org.w3c.dom.DOMException
- NOT_FOUND_ERR: Raised when the parameter name is not recognized.public java.lang.String writeToString(org.w3c.dom.Node wnode) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
LSSerializer
. The result of serializing the node is
returned as a string. Writing a Document or Entity node produces a
serialized form that is well formed XML. Writing other node types
produces a fragment of text in a form that is not fully defined by
this document, but that should be useful to a human for debugging or
diagnostic purposes.writeToString
in interface org.w3c.dom.ls.LSSerializer
wnode
- The node to be written.org.w3c.dom.DOMException
- DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a
DOMString
.org.w3c.dom.ls.LSException
- SERIALIZE_ERR: Unable to serialize the node. DOM applications should
attach a DOMErrorHandler
using the parameter
"error-handler" to get details on error.public void setNewLine(java.lang.String newLine)
null
null
.setNewLine
in interface org.w3c.dom.ls.LSSerializer
public java.lang.String getNewLine()
null
null
.getNewLine
in interface org.w3c.dom.ls.LSSerializer
public org.w3c.dom.ls.LSSerializerFilter getFilter()
getFilter
in interface org.w3c.dom.ls.LSSerializer
public void setFilter(org.w3c.dom.ls.LSSerializerFilter filter)
setFilter
in interface org.w3c.dom.ls.LSSerializer
public boolean write(org.w3c.dom.Node node, org.w3c.dom.ls.LSOutput destination) throws org.w3c.dom.ls.LSException
LSSerializer
interface. The output
is written to the supplied LSOutput
.
LSOutput
, the encoding is found by
looking at the encoding information that is reachable through the
LSOutput
and the item to be written (or its owner
document) in this order:
LSOutput.encoding
,
Document.actualEncoding
,
Document.xmlEncoding
.
LSOutput
, a
"no-output-specified" error is raised.write
in interface org.w3c.dom.ls.LSSerializer
node
- The node to serialize.destination
- The destination for the serialized DOM.true
if node
was
successfully serialized and false
in case the node
couldn't be serialized.org.w3c.dom.ls.LSException
- SERIALIZE_ERR: Raised if the LSSerializer
was unable to
serialize the node. DOM applications should attach a
DOMErrorHandler
using the parameter "
error-handler" if they wish to get details on the error.public boolean writeToURI(org.w3c.dom.Node node, java.lang.String URI) throws org.w3c.dom.ls.LSException
LSSerializer
interface. The output
is written to the supplied URI.
Document.inputEncoding
,
Document.xmlEncoding
.
writeToURI
in interface org.w3c.dom.ls.LSSerializer
node
- The node to serialize.URI
- The URI to write to.true
if node
was
successfully serialized and false
in case the node
couldn't be serialized.org.w3c.dom.ls.LSException
- SERIALIZE_ERR: Raised if the LSSerializer
was unable to
serialize the node. DOM applications should attach a
DOMErrorHandler
using the parameter "
error-handler" if they wish to get details on the error.Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.