A DOMKey
is a unique
key generated by the DOM implementation to uniquely identify DOM
nodes.
typedef Object DOMKey;
This interface extends the Entity
interface with
additional attributes to provide information on the text
declaration of external parsed entities.
interface Entity3 : Entity { attribute DOMString actualEncoding; attribute DOMString encoding; attribute DOMString version; };
actualEncoding
of type
DOMString
null
otherwise.encoding
of type
DOMString
null
otherwise.version
of type
DOMString
null
otherwise.This interface extends the Document
interface with
additional attributes and methods.
interface Document3 : Document { attribute DOMString actualEncoding; attribute DOMString encoding; attribute boolean standalone; attribute boolean strictErrorChecking; attribute DOMString version; Node adoptNode(in Node source) raises(DOMException); };
actualEncoding
of type
DOMString
null
otherwise.encoding
of type
DOMString
null
when
unspecified.standalone
of type
boolean
strictErrorChecking
of type boolean
false
, the implementation is free to
not test every possible error case normally defined on DOM
operations, and not raise any DOMException
. In case of
error, the behavior is undefined. This attribute is
true
by defaults.version
of type
DOMString
null
when
unspecified.adoptNode
ownerDocument
of a
node, its children, as well as the attached attribute nodes if
there are any. If the node has a parent it is first removed from
its parent child list. This effectively allows moving a subtree
from one document to another. The following list describes the
specifics for each type of node.
ownerElement
attribute is set to
null
and the specified
flag is set to
true
on the adopted Attr
. The descendants
of the source Attr
are recursively adopted.Document
nodes cannot be adopted.DocumentType
nodes cannot be adopted.Attr
nodes. Default
attributes are discarded, though if the document being adopted into
defines default attributes for this element name, those are
assigned. The descendants of the source element are recursively
adopted.Entity
nodes cannot be adopted.EntityReference
node itself is adopted,
the descendants are discarded, since the source and destination
documents might have defined the entity differently. If the
document being imported into provides a definition for this entity
name, its value is assigned.Notation
nodes cannot be adopted.source
of type
Node
|
The adopted node, or |
|
NOT_SUPPORTED_ERR: Raised if the source node is of type
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly. |
This interface extends the Node
interface with
several new methods. One allows to compare a node against another
with regard to document order. Another methode allows to retrieve
the content of a node and its descendants as a single DOMString.
One allows to test whether two nodes are the same. Two methods
provide for searching the namespace URI associated to a given
prefix and to ensure the document is "namespace wellformed".
Finally, it also provides a new attribute to get the base URI of a
node, as defined in the XML Infoset.
interface Node3 { readonly attribute DOMString baseURI; typedef enum _DocumentOrder { DOCUMENT_ORDER_PRECEDING, DOCUMENT_ORDER_FOLLOWING, DOCUMENT_ORDER_SAME, DOCUMENT_ORDER_UNORDERED }; DocumentOrder; DocumentOrder compareDocumentOrder(in Node other) raises(DOMException); typedef enum _TreePosition { TREE_POSITION_PRECEDING, TREE_POSITION_FOLLOWING, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_SAME, TREE_POSITION_UNORDERED }; TreePosition; TreePosition compareTreePosition(in Node other) raises(DOMException); attribute DOMString textContent; boolean isSameNode(in Node other); DOMString lookupNamespacePrefix(in DOMString namespaceURI); DOMString lookupNamespaceURI(in DOMString prefix); void normalizeNS(); readonly attribute DOMKey key; boolean equalsNode(in Node arg, in boolean deep); };
A type to hold the document order of a node relative to another node.
An enumeration of the different orders the node can be in.
Enumerator Values |
DOCUMENT_ORDER_PRECEDING |
The node preceds the reference node in document order. |
DOCUMENT_ORDER_FOLLOWING |
The node follows the reference node in document order. |
DOCUMENT_ORDER_SAME |
The two nodes have the same document order. |
DOCUMENT_ORDER_UNORDERED |
The two nodes are unordered, they do not have any common ancestor. |
A type to hold the relative tree position of a node with respect to another node.
An enumeration of the different orders the node can be in.
Enumerator Values |
TREE_POSITION_PRECEDING |
The node preceds the reference node. |
TREE_POSITION_FOLLOWING |
The node follows the reference node. |
TREE_POSITION_ANCESTOR |
The node is an ancestor of the reference node. |
TREE_POSITION_DESCENDANT |
The node is a descendant of the reference node. |
TREE_POSITION_SAME |
The two nodes have the same position. |
TREE_POSITION_UNORDERED |
The two nodes are unordered, they do not have any common ancestor. |
baseURI
of type
DOMString
, readonlykey
of type DOMKey
, readonlytextContent
of type
DOMString
Text
node containing
the string this attribute is set to. On getting, no serialization
is performed, the returned string does not contain any markup.
Similarly, on setting, no parsing is performed either, the input
string is taken as pure textual content.Node type | Content |
---|---|
ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE | concatenation of the
textContent attribute value of every child node,
excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes |
ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE |
nodeValue |
DOCUMENT_TYPE_NODE, NOTATION_NODE | empty string |
compareDocumentOrder
other
of type
Node
Returns how the given node compares with this node in document order. |
|
WRONG_DOCUMENT_ERR: Raised if the given node does not belong to the same document as this node. |
compareTreePosition
other
of type
Node
Returns how the given node is positioned relatively to this node. |
|
WRONG_DOCUMENT_ERR: Raised if the given node does not belong to the same document as this node. |
equalsNode
Node.isSameNode
. All objects that are the
same will also be equal, though the reverse may not be true.
arg
of type
Node
deep
of type
boolean
true
, recursively compare the subtrees; if
false
, compare only the nodes themselves (and its
attributes, if it is an Element
).
|
If the nodes, and possibly subtrees are equal, |
isSameNode
other
of type
Node
|
Returns |
lookupNamespacePrefix
namespaceURI
of type
DOMString
|
Returns the associated namespace prefix or |
lookupNamespaceURI
prefix
of type
DOMString
|
Returns the associated namespace URI or |
normalizeNS
This interface extends the Text
interface with a
new attribute that allows one to find out whether a
Text
node only contains whitespace in element
content.
interface Text3 : Text { readonly attribute boolean isWhitespaceInElementContent; };
isWhitespaceInElementContent
of type boolean
, readonlyNote: An implementation can only return true
if, one way or another, it has access to the relevant information
(e.g., the DTD or schema).
Because the DOM only defines interfaces, applications have to rely on some "proprietary" API to start from. Typically, a Java application starts with a line of code such as:
DOMImplementation impl = org.apache.xerces.dom.DOMImplementationImpl.getDOMImplementation();
Since there is no language independent way of "bootstrapping" a DOM implementation, this section describes a solution for Java. Hopefully, similar solutions could be defined for other language bindings.
The following defines a Java class called
DOMImplementationFactory
which provides with a static
method to get a reference to a DOMImplementation. The actual class
to be returned by getDOMImplementation
can be
specified by the application or the implementation, depending on
the context, through the Java system property
"org.w3c.dom.DOMImplementation". In addition, an implementation can
provide its own version of this class, with the same class name
and package name, in order to set the default name to the
desired value.
package org.w3c.dom; public abstract class DOMImplementationFactory { // The system property to specify the DOMImplementation class name. private static String property = "org.w3c.dom.DOMImplementation"; // The default DOMImplementation class name to use. private static String defaultImpl = "NO DEFAULT IMPLEMENTATION SET"; /** * Returns a DOMImplementation **/ public static DOMImplementation getDOMImplementation() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ClassCastException { // Retrieve the system property String impl; try { impl = System.getProperty(property, defaultImpl); } catch (SecurityException e) { // fallback on default implementation in case of security pb impl = defaultImpl; } // Attempt to load, instantiate and return the implementation class return (DOMImplementation) Class.forName(impl).newInstance(); } }
With this, the first line of an application typically becomes something like:
DOMImplementation impl = DOMImplementationFactory.getDOMImplementation();