This section defines a set of interfaces for loading and saving
document objects as defined in [DOM Level 2 Core] or
newer. The functionality specified in this section (the Load
and Save functionality) is sufficient to allow software
developers and web script authors to load and save XML content
inside conforming products. The DOM Load and Save API also allows filtering of XML content
using only DOM API calls; access and manipulation of the
Document
is defined in [DOM Level 2 Core] or
newer.
The proposal for loading is influenced by the Java APIs for XML Processing [JAXP] and by SAX2 [SAX].
The list of interfaces involved with the Loading and Saving XML documents is:
DOMImplementationLS
-- A new
DOMImplementation
interface that provides the
factory methods for creating the objects required for loading
and saving.
DOMParser
-- A parser interface.
DOMInput
-- Encapsulate information about the XML
document to be loaded.
DOMResourceResolver
-- During loading, provides a
way for applications to redirect references to external
entities.
DOMParserFilter
-- Provide the ability to examine
and optionally remove Element nodes as they are being
processed during the parsing of a document.
DOMSerializer
-- An interface for writing out or
serializing DOM documents.
DOMOutput
-- Encapsulate information about the
XML document to be serialized.
DOMSerializerFilter
-- Provide the ability to
examine and optionally remove nodes as they are being
processed during the serialization of a document.
DocumentLS
-- Provides a client or browser style
interface for loading and saving.
ElementLS
-- Provides a user convenient mechanism
by which the children of an element can be serialized to a
string, or replaced by the result of parsing a provided
string.
To ensure interoperability, this specification specifies the following basic types used in various DOM modules. Even though the DOM uses the basic types in the interfaces, bindings may use different types and normative bindings are only given for Java and ECMAScript in this specification.
DOMInputStream
typeThis type is used to represent a sequence of input bytes.
A DOMInputStream
represents a reference to a
byte stream source of an XML input.
typedef Object DOMInputStream;
Note:
For Java, DOMInputStream
is bound to the
java.io.InputStream
type. For ECMAScript,
DOMInputStream
is bound to Object
.
DOMOutputStream
typeThis type is used to represent a sequence of output bytes.
A DOMOutputStream
represents a byte
stream destination for the XML output.
typedef Object DOMOutputStream;
Note:
For Java, DOMOutputStream
is bound to the
java.io.OutputStream
type. For ECMAScript,
DOMOutputStream
is bound to Object
.
DOMReader
typeThis type is used to represent a sequence of input characters in 16-bit units. The encoding used for the characters is UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646]).
A DOMReader
represents a character
stream for the XML input.
typedef Object DOMReader;
Note:
For Java, DOMReader
is bound to the
java.io.Reader
type. For ECMAScript,
DOMReader
is NOT bound, and
therefore as no recommended meaning in ECMAScript.
DOMWriter
typeThis type is used to represent a sequence of output characters in 16-bit units. The encoding used for the characters is UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646]).
A DOMWriter
represents a character
stream for the XML input.
typedef Object DOMWriter;
Note:
For Java, DOMWriter
is bound to the
java.io.Writer
type. For ECMAScript,
DOMWriter
is NOT bound, and
therefore as no recommended meaning in ECMAScript.
The interface within this section is considered fundamental, and must be fully implemented by all conforming implementations of the DOM Load and Save module.
A DOM application may use the hasFeature(feature,
version)
method of the DOMImplementation
interface with parameter values "LS"
(or
"LS-Async"
) and "3.0"
(respectively)
to determine whether or not these interfaces are supported by
the implementation. In order to fully support them, an
implementation must also support the "Core" feature defined in
[DOM Level 2 Core].
A DOM application may use the hasFeature(feature,
version)
method of the DOMImplementation
interface with parameter values "LS-Async"
and
"3.0"
(respectively) to determine whether or not
the asynchronous mode is supported by the implementation. In
order to fully support the asynchronous mode, an
implementation must also support the "LS"
feature
defined in this section.
For additional information about conformance, please see the DOM Level 3 Core specification [DOM Level 3 Core].
DOMImplementationLS
contains the factory methods for
creating Load and Save objects.
The expectation is that an instance of the
DOMImplementationLS
interface can be obtained by
using binding-specific casting methods on an instance of the
DOMImplementation
interface or, if the
Document
supports the feature "Core"
version "3.0"
defined in [DOM Level 3 Core], by using the method
DOMImplementation.getFeature
with parameter values
"LS"
(or "LS-Async"
) and
"3.0"
(respectively).
interface DOMImplementationLS { // DOMImplementationLSMode const unsigned short MODE_SYNCHRONOUS = 1; const unsigned short MODE_ASYNCHRONOUS = 2; DOMParser createDOMParser(in unsigned short mode, in DOMString schemaType) raises(DOMException); DOMSerializer createDOMSerializer(); DOMInput createDOMInput(); };
Integer parser mode constants.
MODE_ASYNCHRONOUS
DOMParser
.MODE_SYNCHRONOUS
DOMParser
.createDOMInput
The newly created input object. |
createDOMParser
DOMParser
. The newly constructed
parser may then be configured by means of its
DOMConfiguration
object, and used to parse documents by
means of its parse
method. mode
of type
unsigned short
mode
argument is either
MODE_SYNCHRONOUS
or MODE_ASYNCHRONOUS
,
if mode
is MODE_SYNCHRONOUS
then the
DOMParser
that is created will operate in
synchronous mode, if it's MODE_ASYNCHRONOUS
then
the DOMParser
that is created will operate in
asynchronous mode. schemaType
of type
DOMString
Document
using the newly created
DOMParser
. Note that no lexical checking is
done on the absolute URI. In order to create a
DOMParser
for any kind of schema types
(i.e. the DOMParser will be free to use any schema found),
use the value null
.
Note:
For W3C XML Schema [XML Schema Part 1], applications must use the value
"http://www.w3.org/2001/XMLSchema"
. For XML
DTD [XML 1.0], applications
must use the value
"http://www.w3.org/TR/REC-xml"
. Other Schema
languages are outside the scope of the W3C and therefore
should recommend an absolute URI in order to use this
method.
The newly created Note:
By default, the newly created |
|
NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is not supported. |
createDOMSerializer
DOMSerializer
object.
The newly created Note:
By default, the newly created |
An interface to an object that is able to build, or augment, a DOM tree from various input sources.
DOMParser
provides an API for parsing XML and
building the corresponding DOM document structure. A
DOMParser
instance can be obtained by invoking the
DOMImplementationLS.createDOMParser()
method.
As specified in [DOM Level 3 Core], when a document is first made available via the DOMParser:
Text
node for each block of
text. The Text
nodes are in "normal" form: only
structure (e.g. elements, comments, processing instructions,
CDATA sections, and entity references) separates
Text
nodes, i.e., there are neither adjacent
nor empty Text
nodes.
value
and
nodeValue
attributes of an Attr
node
initially return the XML 1.0 normalized
value. However, if the parameters "validate-if-schema"
and "datatype-normalization"
are set to true
, depending on the attribute
normalization used, the attribute values may differ from the
ones obtained by the XML 1.0 attribute normalization. If the parameters
data-type-normalization
is set to
false
, the XML 1.0 attribute normalization is
guaranteed to occur, and if the attributes list does not
contain namespace declarations, the attributes
attribute on Element
node represents the property
[attributes] defined in [XML Information set].
Asynchronous DOMParser
objects are expected to also
implement the events::EventTarget
interface so that
event listeners can be registered on asynchronous
DOMParser
objects.
Events supported by asynchronous DOMParser
objects are:
DOMParser
finishes to load the
document. See also the definition of the
LSLoadEvent
interface.
DOMParser
signals a progress as a document
is parsed. See also the definition of
the LSProgressEvent
interface.
Note:
All events defined in this specification use the namespace URI
"http://www.w3.org/2002/DOMLS"
.
While parsing an input source, errors are reported to the
application through the error handler
(DOMParser.config
's "error-handler"
parameter). This specification does in no way try to define all
possible errors that can occur while parsing XML, or any other
markup, but some common error cases are defined. The types
(DOMError.type
) of errors and warnings defined by
this specification are:
"unsupported-media-type" [fatal]
true
and an unsupported media type
is encountered.
"unsupported-encoding" [fatal]
"doctype-not-allowed" [fatal]
true
and a doctype is encountered.
"unknown-character-denormalization" [fatal]
false
and a character is
encountered for which the processor cannot determine the
normalization properties.
"unbound-namespace-in-entity" [warning]
true
and an unbound namespace
prefix is encounterd in an entity declaration.
"pi-base-uri-not-preserved" [warning]
false
and the following XML file is
parsed:
<!DOCTYPE root [ <!ENTITY e SYSTEM 'subdir/myentity.ent' ]> <root> &e; </root>
subdir/myentity.ent
looks like this:
<one> <two/> </one> <?pi 3.14159?> <more/>
In addition to raising the defined errors and warnings, implementations are expected to raise implementation specific errors and warnings for any other error and warning cases such as IO errors (file not found, permission denied,...), XML well-formedness errors, and so on.
interface DOMParser { readonly attribute DOMConfiguration config; attribute DOMParserFilter filter; readonly attribute boolean async; readonly attribute boolean busy; Document parse(in DOMInput is) raises(DOMException); Document parseURI(in DOMString uri) raises(DOMException); // ACTION_TYPES const unsigned short ACTION_APPEND_AS_CHILDREN = 1; const unsigned short ACTION_REPLACE_CHILDREN = 2; const unsigned short ACTION_INSERT_BEFORE = 3; const unsigned short ACTION_INSERT_AFTER = 4; const unsigned short ACTION_REPLACE = 5; Node parseWithContext(in DOMInput input, in Node context, in unsigned short action) raises(DOMException); void abort(); };
A set of possible actions for the parseWithContext
method.
ACTION_APPEND_AS_CHILDREN
Element
or a
DocumentFragment
.
ACTION_INSERT_AFTER
Element
or a DocumentFragment
.
ACTION_INSERT_BEFORE
Element
or a DocumentFragment
.
ACTION_REPLACE
Element
or a DocumentFragment
.
ACTION_REPLACE_CHILDREN
Element
, a
Document
, or a DocumentFragment
.
async
of type boolean
, readonlytrue
if the DOMParser
is asynchronous,
false
if it is synchronous.
busy
of type boolean
, readonlytrue
if the DOMParser
is currently
busy loading a document, otherwise false
.
config
of type DOMConfiguration
, readonlyDOMConfiguration
object used when parsing an
input source. This DOMConfiguration
is specific to
the parse operation and no parameter values from this
DOMConfiguration
object are passed automatically to
the DOMConfiguration
object on the
Document
that is created, or used, by the parse
operation. The DOM application is responsible for passing any
needed parameter values from this DOMConfiguration
object to the DOMConfiguration
object referenced by
the Document
object.
DOMConfiguration
objects for
DOMParser
adds or modifies the following
parameters:
"charset-overrides-xml-encoding"
true
DOMInput
overrides any encoding from
the protocol.
false
"disallow-doctype"
true
false
"ignore-unknown-character-denormalizations"
true
false
"infoset"
DOMConfiguration
for
a description of this parameter. Unlike in [DOM Level 3 Core], this parameter will default to
true
for DOMParser
.
"namespaces"
true
false
"supported-media-types-only"
true
false
false
.
filter
of type DOMParserFilter
DOMConfiguration
parameters have been applied. For
example, if "validate"
is set to true
, the validation is done before
invoking the filter.
abort
DOMParser
. If the
DOMParser
is currently not busy, a call to this
method does nothing.
parse
DOMInput
.
|
If the |
|
INVALID_STATE_ERR: Raised if the |
parseURI
uri
of type
DOMString
|
If the |
|
INVALID_STATE_ERR: Raised if the |
parseWithContext
DOMInput
and insert the content into an existing
document at the position specified with the
context
and action
arguments. When
parsing the input stream, the context node is used for
resolving unbound namespace prefixes. The context node's
ownerDocument
node (or the node itself if the
node of type DOCUMENT_NODE
) is used to resolve
default attributes and entity references.
Document
node and the
action is ACTION_REPLACE_CHILDREN
, then the
document that is passed as the context node will be changed
such that it's xmlEncoding
,
documentURI
, xmlVersion
,
actualEncoding
, xmlStandalone
, and all
other such attributes are set to what they would be set to if
the input source was parsed using
DOMParser.parse()
.
DOMParser
is asynchronous then the
insertion of the resulting DOM structure is atomic, e.g. the
whole structure is inserted only once the whole input stream
is completely parsed without errors.
ErrorHandler
instance associated with the
"error-handler"
parameter of the DOMConfiguration
.
parseWithContext
, the values of the
following configuration parameters will be ignored and their
default values will always be used instead: "validate",
"validate-if-schema",
and "whitespace-in-element-content".
input
of type
DOMInput
DOMInput
from which the source document
is to be read. The source document must be an XML
fragment, i.e. anything except a complete XML document
(except in the case where the context node of type
DOCUMENT_NODE
, and the action is
ACTION_REPLACE_CHILDREN
), a DOCTYPE (internal
subset), entity declaration(s), notation declaration(s),
or XML or text declaration(s).
context
of type
Node
Document
node, a DocumentFragment
node, or a node of a
type that is allowed as a child of an Element
node, e.g. it cannot be an Attribute
node.
action
of type
unsigned short
ACTION_TYPES
above.
|
Return the node that is the result of the parse operation. If the result is more than one top-level node, the first one is returned. |
|
NOT_SUPPORTED_ERR: Raised if the NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is a read only node.
INVALID_STATE_ERR: Raised if the |
This interface represents an input source for data.
This interface allows an application to encapsulate information about an input source in a single object, which may include a public identifier, a system identifier, a byte stream (possibly with a specified encoding), a base URI, and/or a character stream.
The exact definitions of a byte stream and a character stream are binding dependent.
The application is expected to provide objects that implement
this interface whenever such objects are needed. The application
can either provide its own objects that implement this
interface, or it can use the generic factory method
DOMImplementationLS.createDOMInput()
to create
objects that implement this interface.
The DOMParser
will use the
DOMInput
object to determine how to read
data. The DOMParser
will look at the different
inputs specified in the DOMInput
in the
following order to know which one to read from, the first one
through which data is available will be used:
DOMInput.characterStream
DOMInput.byteStream
DOMInput.stringData
DOMInput.systemId
DOMInput.publicId
DOMInput
objects belong to the application. The DOM
implementation will never modify them (though it may make copies
and modify the copies, if necessary).
interface DOMInput { // Depending on the language binding in use, // this attribute may not be available. attribute DOMReader characterStream; attribute DOMInputStream byteStream; attribute DOMString stringData; attribute DOMString systemId; attribute DOMString encoding; attribute DOMString publicId; attribute DOMString baseURI; attribute boolean certified; };
baseURI
of type DOMString
systemId
to an absolute URI.
byteStream
of type DOMInputStream
certified
of type boolean
characterStream
of type DOMReader
encoding
of type DOMString
publicId
of type DOMString
stringData
of type DOMString
systemId
of type DOMString
DOMParser
will
only attempt to fetch the resource identified by the URI
reference only if there is no other input available in the
input source).
encoding
attribute.
baseURI
as
the base, if that fails, the behavior is implementation
dependent.
DOMResourceResolver
provides a way for applications
to redirect references to external resources.
Applications needing to implement custom handling for external
resources can implement this interface and register their
implementation by setting the resourceResolver
attribute of the DOMParser
.
The DOMParser
will then allow the application to
intercept any external entities (including the external DTD
subset and external parameter entities) before including them.
Many DOM applications will not need to implement this interface, but it will be especially useful for applications that build XML documents from databases or other specialized input sources, or for applications that use URN's.
Note:
DOMResourceResolver
is based on the SAX2 [SAX] EntityResolver
interface.
interface DOMResourceResolver { DOMInput resolveResource(in DOMString publicId, in DOMString systemId, in DOMString baseURI); };
resolveResource
DOMParser
will call this method before
opening any external resource except the top-level document
entity (including the external DTD subset, external entities
referenced within the DTD, and external entities referenced
within the document element); the application may request that
the DOMParser
resolve the resource itself, that
it use an alternative URI, or that it use an entirely
different input source.
DOMParser
must resolve it fully before calling this method.
publicId
of type
DOMString
null
if no public identifier
was supplied or if the resource is not an entity.
systemId
of type
DOMString
baseURI
of type
DOMString
null
if there is no base URI.
DOMParserFilter
s provide applications the ability to
examine nodes as they are being constructed while parsing.
As each node is examined, it may be modified or removed,
or the entire parse may be terminated early.
At the time any of the filter methods are called by the parser,
the owner Document and DOMImplementation objects exist and are
accessible. The document element is never passed to the
DOMParserFilter
methods, i.e. it is not possible to
filter out the document element. The Document
,
DocumentType
, Notation
, and
Entity
nodes are not passed to the
acceptNode
method on the filter.
All validity checking while reading a document occurs on the source document as it appears on the input stream, not on the DOM document as it is built in memory. With filters, the document in memory may be a subset of the document on the stream, and its validity may have been affected by the filtering.
All default content, including default attributes, must be passed to the filter methods.
The DOMParser
ignores any exception raised in the
filter.
interface DOMParserFilter { // Constants returned by startElement and acceptNode const short FILTER_ACCEPT = 1; const short FILTER_REJECT = 2; const short FILTER_SKIP = 3; const short FILTER_INTERRUPT = 4; unsigned short startElement(in Element element); unsigned short acceptNode(in Node node); readonly attribute unsigned long whatToShow; };
Constants returned by startElement
and
acceptNode
.
FILTER_ACCEPT
FILTER_INTERRUPT
FILTER_REJECT
FILTER_SKIP
whatToShow
of type unsigned long
, readonlyDOMParser
what types of nodes to show
to the filter. See NodeFilter
for definition of
the constants. The constants SHOW_ATTRIBUTE
,
SHOW_DOCUMENT
, SHOW_DOCUMENT_TYPE
,
SHOW_NOTATION
, SHOW_ENTITY
, and
SHOW_DOCUMENT_FRAGMENT
are meaningless here,
those nodes will never be passed to a
DOMParserFilter
.
acceptNode
node
of type
Node
|
|
startElement
Element
start tag has been scanned, but before
the remainder of the Element
is processed. The
intent is to allow the element, including any children, to be
efficiently skipped. Note that only element nodes are passed
to the startElement
function.
startElement
for
filtering will include all of the Element's attributes,
but none of the children nodes. The Element may not yet be
in place in the document being constructed (it may not have
a parent node.) startElement
filter function may access or change the
attributes for the Element. Changing Namespace declarations will
have no effect on namespace resolution by the parser.element
of type
Element
|
Returning any other values will result in unspecified behavior. |
This interface represents a progress event object that
notifies the application about progress as a document is
parsed. It extends the Event
interface
defined in [DOM Level 3 Events].
interface LSProgressEvent : events::Event { readonly attribute DOMInput input; readonly attribute unsigned long position; readonly attribute unsigned long totalSize; };
input
of type DOMInput
, readonlyposition
of type unsigned long
, readonlytotalSize
of type unsigned long
, readonlyThis interface represents a load event object that signals the completion of a document load.
interface LSLoadEvent : events::Event { readonly attribute Document newDocument; readonly attribute DOMInput input; };
input
of type DOMInput
, readonlynewDocument
of type Document
, readonly
DOMSerializer
provides an API for serializing
(writing) a DOM document out into XML. The XML data is written to
a string or an output stream.
During serialization of XML data, namespace fixup is done as
defined in [DOM Level 3 Core], Appendix B. [DOM Level 2 Core] allows empty strings as a real namespace
URI. If the namespaceURI
of a Node
is
empty string, the serialization will treat them as
null
, ignoring the prefix if any.
DOMSerializer
accepts any node type for serialization.
For nodes of type Document
or Entity
,
well-formed XML will be created when possible (well-formedness
is guaranteed if the document or entity comes from a parse
operation and is unchanged since it was created). The serialized
output for these node types is either as a XML document or an
External XML Entity, respectively, and is acceptable input for
an XML parser. For all other types of nodes the serialized form
is not specified, but should be something useful to a human for
debugging or diagnostic purposes.
Within a Document
, DocumentFragment
, or
Entity
being serialized, Nodes
are
processed as follows
Document
nodes are written, including the XML
declaration (unless the parameter "xml-declaration"
is set to false
) and a DTD subset, if one exists
in the DOM. Writing a Document
node serializes
the entire document.
Entity
nodes, when written directly by
DOMSerializer.write
, outputs the entity expansion
but no namespace fixup is done. The resulting output will be
valid as an external entity.
EntityReference
nodes are serialized as an entity
reference of the form "&entityName;
" in the
output. Child nodes (the expansion) of the entity reference
are ignored.
true
, CDATA sections
are split, and the unrepresentable characters are serialized
as numeric character references in ordinary content. The
exact position and number of splits is not specified.
false
,
unrepresentable characters in a CDATA section are reported
as "invalid-data-in-cdata-section"
errors. The
error is not recoverable - there is no mechanism for
supplying alternative characters and continuing with the
serialization.
DocumentFragment
nodes are serialized by
serializing the children of the document fragment in the order
they appear in the document fragment.
Note:
The serialization of a Node
does not always
generate a well-formed
XML document, i.e. a DOMParser
might throw fatal
errors when parsing the resulting serialization.
Within the character data of a document (outside of markup), any characters that cannot be represented directly are replaced with character references. Occurrences of '<' and '&' are replaced by the predefined entities < and &. The other predefined entities (>, ', and ") might not be used, except where needed (e.g. using > in cases such as ']]>'). Any characters that cannot be represented directly in the output character encoding are serialized as numeric character references.
To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "'", and the double-quote character (") as """. New line characters and other characters that cannot be represented directly in attribute values in the output character encoding are serialized as a numeric character reference.
Within markup, but outside of attributes, any occurrence of a
character that cannot be represented in the output character
encoding is reported as an error. An example would be serializing
the element <LaCaƱada/> with encoding="us-ascii"
.
When requested by setting the parameter "normalize-characters"
on DOMSerializer
to true, character normalization
is performed according to the rules defined in [CharModel] on all data to be serialized, both markup and
character data. The character normalization process affects only
the data as it is being written; it does not alter the DOM's
view of the document after serialization has completed.
When outputting unicode data, whether or not a byte order mark is serialized, or if the output is big-endian or little-endian, is implementation dependent.
Namespaces are fixed up during serialization, the serialization process will verify that namespace declarations, namespace prefixes and the namespace URI's associated with elements and attributes are consistent. If inconsistencies are found, the serialized form of the document will be altered to remove them. The method used for doing the namespace fixup while serializing a document is the algorithm defined in Appendix B.1, "Namespace normalization", of [DOM Level 3 Core].
Any changes made affect only the namespace prefixes and declarations appearing in the serialized data. The DOM's view of the document is not altered by the serialization operation, and does not reflect any changes made to namespace declarations or prefixes in the serialized output.
While serializing a document, the parameter "discard-default-content" controls whether or not non-specified data is serialized.
While serializing, errors are reported to the application
through the error handler (DOMSerializer.config
's
"error-handler"
parameter). This specification does in no way try to define all
possible errors that can occur while serializing a DOM node, but
some common error cases are defined. The types
(DOMError.type
) of errors and warnings defined by
this specification are:
"invalid-data-in-cdata-section" [fatal]
false
and invalid data is
encountered in a CDATA section.
"unsupported-encoding" [fatal]
"unbound-namespace-in-entity" [warning]
true
and an unbound namespace
prefix is encounterd in a referenced entity.
"no-output-specified" [fatal]
DOMOutput
if no
output is specified in the DOMOutput
.
In addition to raising the defined errors and warnings, implementations are expected to raise implementation specific errors and warnings for any other error and warning cases such as IO errors (file not found, permission denied,...) and so on.
interface DOMSerializer { readonly attribute DOMConfiguration config; attribute DOMString newLine; attribute DOMSerializerFilter filter; boolean write(in Node node, in DOMOutput destination); boolean writeURI(in Node node, in DOMString URI); DOMString writeToString(in Node node) raises(DOMException); };
config
of type DOMConfiguration
, readonlyDOMConfiguration
object used by the
DOMSerializer
when serializing a DOM node.
DOMConfiguration
objects for
DOMSerializer
adds, or modifies, the following
parameters:
"canonical-form"
true
true
will set the parameter "format-pretty-print"
to false
.
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
true
will set the
parameter "canonical-form"
to false
.
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
the rules defined in [CharModel] supplemented
by the definitions of relevant constructs from Section
2.13 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
possibly an encoding
(DOMSerializer.encoding
, or
Document.actualEncoding
or
Document.xmlEncoding
if the document
is a Level 3 document) is 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).
false
.
filter
of type DOMSerializerFilter
DOMConfiguration
parameters have been
applied. For example, CDATA sections are passed to the filter
even if "cdata-sections"
is set to false
.
newLine
of type DOMString
null
null
.write
DOMSerializer
interface. The
output is written to the supplied DOMOutput
.
DOMOutput
, the encoding is found
by looking at the encoding information that is reachable through
the DOMOutput
and the item to be written (or its
owner document) in this order:
DOMOutput.encoding
,
Document.actualEncoding
,
Document.xmlEncoding
.
DOMOutput
, a
"no-output-specified" error is raised.
node
of type
Node
destination
of type
DOMOutput
|
Returns |
writeToString
DOMSerializer
interface. The
output is written to a DOMString
that is returned
to the caller (this method completely ignores all the encoding
information available).
node
of type
Node
|
Returns the serialized data, or |
|
DOMSTRING_SIZE_ERR: Raised if the resulting string is too long to
fit in a |
writeURI
DOMSerializer
interface. The
output is written to the supplied URI.
Document.actualEncoding
,
Document.xmlEncoding
.
node
of type
Node
URI
of type
DOMString
|
Returns |
This interface represents an output destination for data.
This interface allows an application to encapsulate information about an output destination in a single object, which may include a URI, a byte stream (possibly with a specified encoding), a base URI, and/or a character stream.
The exact definitions of a byte stream and a character stream are binding dependent.
The application is expected to provide objects that implement
this interface whenever such objects are needed. The application
can either provide its own objects that implement this
interface, or it can use the generic factory method
DOMImplementationLS.createDOMOutput()
to create
objects that implement this interface.
The DOMSerializer
will use the
DOMOutput
object to determine where to serialize
the output to. The DOMSerializer
will look at the
different outputs specified in the DOMOutput
in the
following order to know which one to output to, the first one
that data can be output to will be used:
DOMOutput
objects belong to the application. The
DOM implementation will never modify them (though it may make
copies and modify the copies, if necessary).
interface DOMOutput { // Depending on the language binding in use, // this attribute may not be available. attribute DOMWriter characterStream; attribute DOMOutputStream byteStream; attribute DOMString systemId; attribute DOMString encoding; };
byteStream
of type DOMOutputStream
characterStream
of type DOMWriter
encoding
of type DOMString
systemId
of type DOMString
encoding
attribute.
DOMSerializerFilter
s provide applications the
ability to examine nodes as they are being serialized and decide
what nodes should be serialized or not. The
DOMSerializerFilter
interface is based on the
NodeFilter
interface defined in [DOM Level 2 Traversal and Range].
The Document
, DocumentType
,
DocumentFragment
, Attr
,
Notation
, and Entity
nodes are not
passed to the filter.
The result of any attempt to modify a node passed to a
DOMSerializerFilter
is implementation dependent.
interface DOMSerializerFilter : traversal::NodeFilter { readonly attribute unsigned long whatToShow; };
whatToShow
of type unsigned long
, readonlyDOMSerializer
what types of nodes to show to
the filter. See NodeFilter
for definition of the
constants. The constants SHOW_ATTRIBUTE
,
SHOW_DOCUMENT
, SHOW_DOCUMENT_TYPE
,
SHOW_NOTATION
, SHOW_ATTRIBUTE
, and
SHOW_DOCUMENT_FRAGMENT
are meaningless here, those
nodes will never be passed to a
DOMSerializerFilter
.
The interfaces defined in this section provide no direct functionality that cannot be achieved with the load and save interfaces defined in the earlier sections of this specification. These interfaces are defined for developer convenience only, and supporting them is optional.
These interfaces are not nearly as flexible as the ones defined earlier in this specification, for example, no configuration parameters are settable when calling these methods, and the values of all configuration parameters are predefined.
The DocumentLS
interface provides a mechanism by
which the content of a document can be serialized, or replaced
with the DOM tree produced when loading a URI, or parsing a
string.
If the DocumentLS
interface is supported, the
expectation is that an instance of the DocumentLS
interface can be obtained by using binding-specific casting
methods on an instance of the Document
interface,
or by using the method Node.getFeature
with
parameter values "DocumentLS"
and "3.0"
(respectively) on an Document
, if the
Document
supports the feature "Core"
version "3.0"
defined in [DOM Level 3 Core]
This interface is optional. If supported, implementations must
support version "3.0"
of the feature
"DocumentLS"
.
interface DocumentLS { attribute boolean async; // raises(DOMException) on setting void abort(); boolean load(in DOMString uri); boolean loadXML(in DOMString source); DOMString saveXML(in Node node) raises(DOMException); };
async
of type boolean
DocumentLS.load()
should be synchronous or asynchronous. When the async
attribute is set to true
the load method returns
control to the caller before the document has completed
loading. The default value of this attribute is
true
.
|
NOT_SUPPORTED_ERR: Raised if the implementation doesn't support the mode the attribute is being set to. |
abort
load
being invoked the loading and parsing
is immediately aborted. The possibly partial result of parsing
the document is discarded and the document is cleared.
load
Event.targetNode
will be the document, not an
element) will be dispatched on the document. If an error
occurs, an implementation dependent "error" event will be
dispatched on the document. If this method is called on a
document that is currently loading, the current load is
interrupted and the new URI load is initiated.
DOMParser
interface are assumed to have their
default values with the exception that the parameters
"entities"
, "normalize-characters"
,
"check-character-normalization"
are set to
"false"
.
DOMParser.parseWithContext
with an
input stream referencing the URI that was passed to this call,
the document as the context node, and the action
ACTION_REPLACE_CHILDREN
.
uri
of type
DOMString
|
If async is set to |
loadXML
DOMParser
interface are
assumed to have their default values when invoking this
method.
DOMParser.parseWithContext
with an
input stream containing the string passed to this call, the
document as the context node, and the action
ACTION_REPLACE_CHILDREN
.
source
of type
DOMString
|
|
saveXML
DOMSerializer
interface are
assumed to have their default values when invoking this
method.
DOMSerializer.writeToString
with the
document as the node to write.
node
of type
Node
null
the
whole document is serialized, if it's non-null the given
node is serialized.
|
The serialized document or |
|
WRONG_DOCUMENT_ERR: Raised if the node passed in as the node parameter is from an other document. |
The ElementLS
interface provides a convenient
mechanism by which the children of an element can be serialized
to a string, or replaced by the result of parsing a provided
string.
If the ElementLS
interface is supported, the
expectation is that an instance of the ElementLS
interface can be obtained by using binding-specific casting
methods on an instance of the Element
interface, or
by using the method Node.getFeature
with
parameter values "ElementLS"
and "3.0"
(respectively) on an Element
, if the
Element
supports the feature "Core"
version "3.0"
defined in [DOM Level 3 Core].
This interface is optional. If supported, implementations must
support version "3.0"
of the feature
"ElementLS"
.
interface ElementLS { attribute DOMString markupContent; };
markupContent
of type DOMString
DOMSerializer.writeToString()
on all children in
document order and appending the result of the individual
results to a single string that is then returned as the value
of this attribute.
DOMParser.parseWithContext()
passing in the
provided string (through the input source argument), the
Element
, and the action
ACTION_REPLACE_CHILDREN
. If an error occurs
while parsing the provided string, the Element
's
owner document's error handler will be called, and the
Element
is left with no children.
DOMConfiguration
object
have their default values.