Abstract
The abstract was not available at the time the proceedings were created. Please check an updated version of the paper abstracts at the conference proceedings web site.
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 recommend 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";Figure 1. Example of DOM Usage
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.
The DOM XML extends the Core platform for specific XML 1.0 needs such as processing instructions, CDATA, and entities.
The HTML DOM 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 part includes XML-tree manipulation oriented events with tree mutation or user-oriented (such as mouse, keyboard, or HTML-specific) events.
The DOM CSS provides a set of convenient easy-to-use ways to manipulate CSS style sheets or styled documents.
Loading an XML document into a DOM tree or saving a DOM tree into an XML document is a fundamental need for the DOM user. This module includes lots of options to control the load/save operations.
Ever try to access the Document Type Information (DTD) from your DOM application? What is the datatype of an attribute or an element? This module lets the user access an abstract representation of the schema. The schema could be a DTD, an XML Schema, or whatever your DOM implementation support.
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 Levels. Two Levels (1 and 2) are already Recommendations. The Working Group is now working on Level 3.
The DOM requirements 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. Level 3 will extend Level 2 by finishing support for XML 1.0 with namespaces (alignment with the XML Infoset and support for XML Base) and will extend the user interface events (keyboard). It will also add abstract schemas support (for DTDs, XML Schema, ...), the ability to load and save a document or an abstract schema, explore further mixed markup vocabularies and the implications on the DOM API ("Embedded DOM"), and will support XPath.
DOM Level 3 adds additional functionalities on two existing DOM Level 2 modules, Core and Event, and provide three new modules: Load and Save, Validation, and XPath.
XML applications, such as WSDL 1.2, are defined using the [XML Information Set] (Infoset). Since Infoset is considered as the data model for XML applications, appendix C of [DOM Level 3 Core] provides the mappings from an Infoset to a DOM tree and from a DOM tree to an Infoset.
| Property | Value |
|---|---|
| [namespace name] | Node.namespaceURI |
| [local name] | Node.localName |
| [namespace attributes] | The nodes contained in Node.attributes, whose Node.namespaceURI value is "http://www.w3.org/2000/xmlns/" |
Table 1. Examples of Infoset properties obtained from a DOM Element node
In order to improve the data model alignment, DOM Level 3 Core adds support for:
[XML Base], with the attributes Node.baseURI and Document.documentURI;
XML versioning and encoding, with the attributes Document.xmlVersion and Document.inputEncoding. XML 1.1 and Namespace in XML 1.1 can now be handled;
XML standalone, with the attribute Document.xmlStandalone;
type information, with the attributes Element.schemaTypeInfo and Attr.schemaTypeInfo. Those attributes are aligned to the Infoset when dealing with XML DTD, and aligned to the XQuery 1.0 and XPath 2.0 Data Model when dealing with XML Schema.
user defined identifiers, with methods such as Element.setIdAttribute(). The attribute Element.isId is also introduced, following the definition from the XPointer specification. Note that the definition is compatible with the work being done on xml:id in the W3C XML Core Working Group since it allows extensibility.
Unlike the previous versions of DOM, Level 3 not only introduces new interfaces but one class is now defined: DOMImplementationRegistry. This class has a corresponding object in ECMAScript, and a corresponding class in Java with a static method in order to get an instance of it. The following example shows how to obtain a DOM implementation with XML and Traversal module support and the Events 2.0 module support:
Since the introduction of [XML Path Language 1.0], qnames (namespace prefix + local name) have been used outside their initial usage in Namespaces in XML. Qnames are used in XPath, XML Schema, WSDL, etc. DOM Level 2 was designed to do namespace handling as introduced by Namespaces in XML. DOM Level 3 goes beyond that and introduces user convenient lookup mechanisms: Node.lookupPrefix(namespaceURI), Node.isDefaultNamespace(namespaceURI), and Node.lookupNamespaceURI(prefix). Those methods retrieves a namespace name using a namespace prefix and vice versa.
DOM Level 3 Core adds more user convenience functionalities:
Tree normalization and validation: Document.normalizeDocument will perform general operations on a DOM tree, following the configuration parameters provided its attached DOMConfiguration object. Configuration parameters include: "cdata-sections", to convert all CDATASection nodes into Text nodes; "entities", to replace all entity references with their corresponding subtree; "namespaces", to normalize the namespace declarations attributes; "infoset", to apply a set of transformation in order to put the tree in an Infoset-like state (without CDATA sections, entity references, etc.); or "validate", to validate the tree according the schema type and schema attached to the document. Configuration parameters are also used to attach resource resolvers (if the Load and Save module is supported) or an error handler;
Accessing and manipulating text contents in elements has been simplyfied. Node.textContent will return the text content of a Node and its descendants. On setting, the content of the Node will be replaced with a Text node containing the new text;
Attaching applications specific objects to a Node, using Node.setUserData and Node.getUserData;
Comparing two nodes with regards to their document position, using Node.compareDocumentPosition;
Equality between two nodes, using Node.isEqualNode;
Passing a node from one Document to an other, using Document.adoptNode;
Renaming a node, using Document.renameNode
DOM Level 1 and DOM Level 2 did not addressed a fundamental piece in XML applications: how to load an XML Document into a DOM tree and how to save a DOM tree into an XML Document. [DOM Level 3 Load and Save] gives you those abilities and more.
Nodes can be filtered during the parsing and the serialization using the attributes LSParser.filter and LSSerializer.filter. Configuration parameters provided by the respective DOMConfiguration objects are also in use and give a simple filtering mechanism. Configuration parameters for Load and Save are extending or modifying the existing set provided by [DOM Level 3 Core], with parameters such as "supported-media-types-only" or "format-pretty-print".
LSParserFilter includes methods to accept an element before the completion of its descendants: LSParserFilter.startElement. A node can also be rejected after being fully parsed LSParserFilter.acceptNode.
LSSerializer reuses the concept of NodeFilter introduces in the DOM Level 2 Traversal module.
A LSParser will load a document from a DOMInput object. This object can handle several types of sources: character stream, byte stream, string, URI, or XML public identifier. DOMInput.certifiedText will indicated if the document is certified, according the character normalization rules defined by the Character of the Web. The method LSParser.parseWithContext gives the ability to parse a string and insert the resulting subtree into a specified place in the DOM tree.
A LSSerializer will save a document using a DOMOutput object. The destination can be a character stream, a byte stream, or a URI. LSSerializer.writeToString will generate a string given a Node.
This DOM module was designed to provide simple functionalities to query a DOM tree using [XML Path Language 1.0]. A mapping between the data model of XPath and DOM is provided.
The XPathEvaluator interface will evaluate a given XPath expression in the context of a a Node and namespace resolver. The namespace resolver is used to resolve the namespace prefixes used in the XPath expression. Note that a Node can be used as a namespace resolver using XPathEvaluator.createNSResolver. Result objects could be reused. All XPath 1.0 types are supported: number, boolean, string, and node sets. The evaluation can retrieve a snapshot for node sets (modifications to the tree will not affect the resulting snapshot) or an iterator (modifications to the tree can result in invalidating the iterator). XPath expressions can be pre-compiled into an XPathExpression object. Finally, the API introduced the concept of XPathNamespace node, for results involving XPath namespace nodes.
The DOM Events model was introduced in the DOM Level 2 Events module. It has been reused since then in other context, such as XML Events. DOM Level 3 Events module provides a clear separation between the DOM Events model, and the DOM interfaces used to manipulate the events and their listeners.
An event listener is now always part of a "group". This provides the ability to separate different set of events if concurrent applications or libraries are accessing and using the event system. This separation prevents a listener from one group to interfere (by stopping the event propagation for example) with listeners from other groups. This implies that a listener can never really stop the event propagation entirely but only for the listeners of its own group.
A triggering order has also been introduced within groups. If an event listener A is registered before the event listener B, A is guarantee to be triggered before B if they are registered in the same group.
Keyboard events are finally back in the specification. Keys are now identified using a string identifier ("Alt", "CapsLock", "F1", ...) to allow extensibility. Note that, while keyboard events are part of the specification, it is recommended to rely on Text events when dealing with character input.
Text events represent any kind of character(s) input sent to a DOM tree. The input can be from a keyboard, a voice command, etc. Any input processing is already done: independently of the key combination used, the character will be the same.
This module is oriented for guided manipulation using a schema. The document can then be maintain fully or partially validated at any given time:
if (node.canRemoveChild(secondChild))
node.removeChild(secondChild);
Figure 3. Guided manipulation of a DOM tree
The validation state of a Node can be tested using NodeEditVal.nodeValidity. Default or enumerated values for a given node can be obtained using NodeEditVal.defaultValue and NodeEditVal.enumeratedValues. The list of possible elements in a document or a given element can also be obtained using DocumentEditVal.getDefinedElements(namespaceURI) or ElementEditVal.allowedChildren.
The previous sections are not exhaustive and readers are encouraged to refer to the DOM Level 3 specifications for a full list of functionalities, or more details information on the ones listed here.
DOM Level 3 brings the necessary bits to make the life of DOM developers easier, by providing missing functionalities in DOM Level 2 or adding more user convenient functions.
[WCAG] Web Content Accessibility Guidelines 1.0, W. Chisholm, G. Vanderheiden, I. Jacobs, 5 May 1999. Available at http://www.w3.org/TR/WAI-WEBCONTENT
[ECMAScript] ECMAScript Language Specification, Third Edition. European Computer Manufacturers Association, Standard ECMA-262, December 1999.
[What is an Event-Based Interface?] What is an Event-Based Interface?, D. Megginson. Available at http://www.megginson.com/SAX/events.html
[Document Object Model] W3C Document Object Model, maintained by the W3C DOM Working Group. Available at http://www.w3.org/DOM
[DOM Level 3 Core] Document Object Model (DOM) Level 3 Core Specification, A. Le Hors, P. Le Hégaret, Editors. World Wide Web Consortium, June 2003. Available at http://www.w3.org/TR/DOM-Level-3-Core
[DOM Level 3 Load and Save] Document Object Model (DOM) Level 3 Load and Save Specification, J. Stenback, A. Heninger, Editors. World Wide Web Consortium, June 2003. Available at http://www.w3.org/TR/DOM-Level-3-LS
[What is the relationship between the DOM and SAX?] What is the relationship between the DOM and SAX?, D. Megginson. Available at http://www.w3.org/DOM/faq#SAXandDOM
[XML Base] XML Base, J. Marsh, Editor. World Wide Web Consortium, June 2001. Available at http://www.w3.org/TR/xmlbase
![]() ![]() |
Design & Development by deepX Ltd. |