1. Document Object Model (Core) Level 2

Arnaud Le Hors, W3C

Table of contents

1.1. Overview of the DOM Level 2 Core Interfaces

This section defines a set of extensions to the interfaces defined in the Core section of the DOM Level 1 Recommendation to provide functionalities which are found to be essential but were not addressed in DOM Level 1.

These functionalitites include:

(ED: Although new methods and attributes are introduced in this draft through the definition of a set of new interfaces, they are really meant to be added to the DOM Level 1 interfaces. The next version of this document will make this clear.)

1.2. The Core Interfaces

Interface DocumentType2

Two new attributes are added to the DocumentType interface to provide a way for retrieving the public and system identifiers

IDL Definition

interface DocumentType2 : DocumentType {
  readonly attribute DOMString        publicID;
  readonly attribute DOMString        systemID;

The public identifier of the document type.
The system identifier of the document type.
Interface DOMImplementation2

The DOMImplementation interface is extended with methods for creating an XML document instance.

IDL Definition

interface DOMImplementation2 : DOMImplementation {
  DocumentType       createDocumentType(in DOMString name, 
                                        in DOMString publicID, 
                                        in DOMString systemID)
  Document           createDocument(in DOMString name, 
                                    in DocumentType doctype)

Creates an empty DocumentType node.

The document type name.


The document type public identifier.


The document type system identifier.

Return Value
A new DocumentType node with Node.ownerDocument set to null.

NOT_SUPPORTED_ERR: Raised if the requested document type is not supported.

Creates an XML Document object of the specified type with its document element.
(ED: Depending on how namespaces are supported this method may need one more parameter to hold the namespace name.)

The name of document element to be created.


The type of document to be created or null.

When doctype is not null, its Node.ownerDocument attribute is set to the document being created.

Return Value
A new Document object.

WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document.

NOT_SUPPORTED_ERR: Raised if the requested document type is not supported.

Interface Document2

The Document interface is extended with a method for importing nodes from another document.

IDL Definition

interface Document2 : Document {
  Node               importNode(in Node importedNode, 
                                in boolean deep);

Imports a node from another document to this document. The returned node has no parent (parentNode is null.).

For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix and namespaces URI). As in the Node.cloneNode() operation, the source node is not altered.

Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for every type of node.

Specified attributes nodes of the source element are imported, and the generated Attr nodes are attached to the generated Element. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If importNode's "deep" option was set True, the descendents of the the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree.
The specified flag is set false on the generated Attr. The descendents of the the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree.Note that the deep parameter does not apply to Attr nodes, they always carry their children with them when imported.
These three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node.
Only the EntityReference itself is copied, even if a deep import was requested, 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.
Entity nodes cannot be imported.
The imported node copies its target and data values from those of the source node.
Document nodes cannot be imported.
DocumentType nodes cannot be imported.
If the deep option was set true, the descendents of the the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment.
Notation nodes cannot be imported.

The node to import.


If true, recursively import the subtree under the specified node; if false, import only the node itself, as explained above. This does not apply to Attr and EntityReference nodes.

Return Value
The imported node that belongs to this Document.

This method raises no exceptions.
Interface Node2

The Node interface is extended with an additional method to test if it supports a specific feature.

IDL Definition

interface Node2 : Node {
  boolean            supports(in DOMString feature, 
                              in DOMString version);

Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

The package name of the feature to test. This is the same name as what can be passed to the method hasFeature on DOMImplementation.


This is the version number of the package name to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true.

Return Value
Returns true if this node defines a subtree within which the specified feature is supported, false otherwise.

This method raises no exceptions.
Interface Attr2

The Attr interface provides an additional method for accessing the Element node the attribute is attached to.

IDL Definition

interface Attr2 : Attr {
  readonly attribute Element          ownerElement;

The Element node this attribute is attached to or null if this attribute is not in use.

1.3. The HTML Interfaces

(ED: This interface is not actually part of the DOM Core. It is part of HTML DOM Level 2. The next version of this document will make this clear.)
Interface HTMLDOMImplementation

The HTMLDOMImplementation interface extends the DOMImplementation interface with a method for creating an HTML document instance.

IDL Definition

interface HTMLDOMImplementation : DOMImplementation {
  HTMLDocument       createHTMLDocument(in DOMString title);

Creates an HTMLDocument object with the minimal tree made of the following elements: HTML, HEAD, TITLE, and BODY.

The title of the document to be set as the content of the TITLE element, through a child Text node.

Return Value
A new HTMLDocument object.

This method raises no exceptions.

1.4. Open Issues

  1. Should import of an ENTITY_NODE be supported?
  2. Should import of an DOCUMENT_NODE be supported?
  3. Should import of an DOCUMENT_TYPE_NODE be supported?
  4. Should import of an NOTATION_NODE be supported?
  5. Should we add a flag to importNode to request for removal of the source node? This would potentially allow implementations to optimize the operation by doing an actual move underneath when possible.