Abstract
In 2000, the W3C Document Object Model Working Group released DOM Level 2 specifications as W3C Recommendations. Those specifications addressed XML, User Interface Events, or CSS. The DOM Level 3 specifications will complete the DOM work by providing several new features.
The Core module has been extended to fully support XML 1.0 and to address the XML Information Set specification, which is the basic data models for XML applications. It also includes support for the XML Base specification, solves the "bootstrapping" problem, and allows the user to pick a DOM implementation based on the features implemented. Several methods were added to make using the DOM easier.
The Events module is extended to include text events (previously known as keyboard events) and event groups.
The Load and Save module provides the ability to load an XML document into a DOM tree and to save a DOM tree into an XML Document. A filtering system is provided for both load and save, to enable the user to select various options, such as validation, turning CDATA sections into text, or choosing the canonical form of XML.
The XPath module provides simple methods to query a DOM tree using XPath 1.0 expressions. It defines a clear mapping between the XPath data model and the DOM, a full support of all XPath 1.0 result types (boolean, number, string, node sets), a full support of XPath nodes (including XPath namespace nodes), and a single node type. XPath Node sets are exposed as iterators or snapshots (direct access).
The Validation module gives the guidance necessary so that valid documents can be modified and still remain valid. The module allows the user to ask questions such as: - can the insertion of a removal of a node make the document invalid? - what is the set of valid children for a specified element?
DOM Level 3 is expected to be released as a set of W3C Recommendations in February 2003. Each specification will come with a Test Suite, worked on jointly with NIST and the public community.
Keywords
Table of Contents
W3C's Document Object Model [Document Object Model] is a standard API (Application Programming Interface) to the document structure and aims to make it easy for programmers to access components and delete, add or edit their content, attributes and style. In essence, the DOM makes it possible for programmers to write applications which work properly on all browsers and servers, and on all platforms. While programmers may need to use different programming languages, they do not need to change their programming model.
Markup languages such as HTML or SVG provide different ways to include or link programming scriptings to the document. In order to use scripting capabilities on the Web, it is recommended to read the Web Content Accessibility Guidelines [WCAG] before using scripts in your documents, in particular the guideline 6.
Specifications of existing scripting languages such as ECMAScript [ECMAScript] (an industry-standard scripting language based on JavaScript and JScript) only give the syntax, the grammar and the basic types' functionalities (String, Object, Number, ...). These specifications don't give the user access to the user agent functionalities (menus, scrollbars, user events, ...) or to the document (text contents, markup structure, style sheets, ...). This is where the Document Object Model stands in the context of scripting.
In November 1996, the W3C released the first Working Draft of the Extensible Markup Language (XML) specification. Many applications of XML were done since then: editors, repositories, databases, B2B systems, Web content, network protocols, etc.
The XML specification only provides the syntax and the grammar for XML. Being able to access the XML content in an application requires more than that: it requires an Application Programming Interface (API).
Generic APIs for XML can be mostly classified in two categories: event-based or tree-based. The DOM is a generic tree-based API for XML. For more information about event-based APIs and a comparison with tree-based APIs, read the [SAX] documentation "[What is an Event-Based Interface?]" or the DOM Frequently asked question (FAQ) "[What is the relationship between the DOM and SAX?]".
// get the HTML body element from the document
var childs = doc.getElementsByTagName("body");
// there is one HTML body element for each HTML 4.0 document
var body = childs.item(0);
// change the value of the CSS2 color property
body.style.color = "black";For a more advanced example, check the DOM Level 2 demo used in the main DOM page [Document Object Model].
The DOM Architecture is divided in various modules. Each module addresses or specializes an existing module for a particular domain. Domains covered by the current DOM API are XML, HTML, CSS, and events. Future domains can be the rendered content (such as the content displayed on the screen which might differ from your document), user agent interface (menus, ...), etc.
The Core platform relies on an internal tree-like representation of the document, and enables you to traverse the hierarchy accordingly. The standard model of viewing a document is as a hierarchy of elements, with the computer building up an internal model of the document based on a kind of tree structure.
The DOM Range and Traversal modules can be used on the Core platform for tree manipulations and navigations.
The XML module extends the Core platform for specific XML 1.0 needs such as processing instructions, CDATA, and entities.
The DOM module provides a set of convenient easy-to-use ways to manipulate HTML documents. The initial HTML DOM merely describes methods, for example, for accessing an identifier by name, or a particular link. The HTML DOM is sometimes referred to as DOM Level 0 but has been imported into DOM Level 1.
This module includes XML-tree manipulation oriented events with tree mutation or user-oriented (such as mouse or HTML-specific) events.
DOM Level 3 completes the DOM Architecture with more fundamentals modules:
Following the publication as a W3C Recommendation of the XML Information Set, the Core module is being aligned with this model. Node.baseURI now returns the XML Base as defined in the infoset. Facilities to manipulate the tree as an infoset have been added as well.
DOM Level 1 introduced a normalize method to merge adjacent text nodes. The Level 3 extension bring the ability to normalize a document given a set of parameters: "entities" (expand all entity references), "cdata-sections" (remove all CDATAsection nodes), "infoset" (transform the tree to match the XML Information Set model), "validate", etc.
Other user convenient methods have been introduced as well: Node.textContent, Text.wholeText, Node.lookupPrefix, Node.setUserData, etc.
A bootstrapping mechanism is now available when writing Java or ECMAScript code. The DOMImplementationRegistry contains the DOM implementations and can be query using a set of features. "XML Load-Save 3.0" will return the implementation that can support the XML module (any level) and the Load and Save Level 3 module.
The Level 3 Events module includes accessibility improvements, keyboard events, or event grouping. Namespaces are now used to refer to event types.
This module includes parameters to control the load and the save operations of a DOM tree: "entities", "comments", "namespaces", "infoset", "normalize-character". The set of parameters is shared by the extended normalization methods introduced in the Core Level 3 module. It also provides extended filtering mechanisms. As for SAX, the source of the document is defined by the user using an input source, the DOMInputSource.
This module provides user convenient methods for schema-driven manipulation of the tree. Methods such as canSetAttribute, canInsertBefore, etc. are available.
The DOM Activity, started in August 1997 in the User Interface Domain, contains only one Working Group: the DOM Working Group. The Activity was moved to the Architecture Domain in November 2000.
The DOM Working Group is a member of the HyperText Coordination Group and has a liaison with the XML Coordination Group.
The DOM Working Group is working with phases or . Two Levels (1 and 2) are already Recommendations. The Working Group is still working on Level 3.
The DOM requirements http://www.w3.org/TR/2001/WD-DOM-Requirements-20010419/ contains all requirements for the Levels of DOM. It is regularly updated to reflect the requirements of the latest Level.
Functionality equivalent to that exposed in Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0 is referred to as "Level 0". There is no W3C specification for this Level.
The first Level of the DOM specifications, DOM Level 1, was completed in October 1998. Level 1 provides support for XML 1.0 and HTML.
The second Level of the DOM specifications, DOM Level 2, was completed in November 2000. Level 2 extends Level 1 with support for XML 1.0 with namespaces and adds supports for Cascading Style Sheets (CSS), events (user interface events and tree manipulation events), and enhances tree manipulations (tree ranges and traversal mechanisms).
The third Level of the DOM specifications, DOM Level 3, is under development. The Events, XPath, and Validation modules are in Last Call (as of October 15). Core and Load and Save are closed to move to Last Call as well.
In terms of implementations, early implementations are available in Xerces http://xml.apache.org/ and Mozilla http://www.mozilla.org/. Oracle and X-Hive are also implementing DOM Level 3 in their end-users softwares.
[WCAG] Web Content Accessibility Guidelines 1.0, Wendy Chisholm, Greeg Vanderheiden, Ian Jacobs, 5 May 1999. Available at http://www.w3.org/TR/WAI-WEBCONTENT
[ECMAScript] ISO (International Organization for Standardization). ISO/IEC 16262:1998. ECMAScript Language Specification. Available from ECMA (European Computer Manufacturers Association) at http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM
[What is an Event-Based Interface?] What is an Event-Based Interface?, David Megginson. Available at http://www.megginson.com/SAX/events.html
![]() ![]() |
Design & Development by deepX Ltd. 2002 |