Introduction to DOM – Part I

What is DOM?

The Document Object Model is an API that provides a standardized way for

accessing and manipulating XML and HTML documents. In DOM, the

XML/HTML document is defined as a tree structure of objects that resides in

whole in the computer’s memory. This tree can be traversed through its node

points.

A fundamental characteristic of DOM is that it only defines object interfaces,

not the actual implementation. This makes the API very language-neutral. It’s

up to third-party software makers to implement the API in the environment of

their choice.

DOM is more a tool for data manipulation than a data structure in itself. You

could for example present a database’s contents as a DOM tree, even if the

database itself is not DOM-like.

How is DOM being developed ?

DOM is developed at W3C by the Document Object Model Working Group.

The DOM WG releases its work in several specifications, which are currently

The Requirements (for DOM), DOM Level 0, DOM Level 1, DOM Level 2 and

DOM Level 3. Currently under development are DOM Level 2 HTML and

DOM Level 3.

DOM and other standards

DOM vs. SAX

DOM and SAX (Simple API for XML) are the two most popular API’s for XML

manipulation, but they differ from each other very much. SAX is an eventdriven

API where the parser generates events as it traverses through the

XML document. The events notify of things such as element start, element

end and character data. SAX doesn’t create an explicit data structure, so it’s

useful in applications that don’t need that information.

DOM vs. COM and CORBA

DOM is not an object model in the same way as COM and CORBA. Where

COM and CORBA are language-independent definitions to specify interfaces

and objects, DOM is a specified set of interfaces and objects designed for

managing HTML and XML documents.

DOM vs. DHTML

Dynamic HML (DHTML) provides scripting interfaces for accessing and

manipulating HTML elements. Because there’s a considerable overlap

between HTML DOM and DHTML, compatibility with DHTML was one of the

driving motivations in the development of DOM. DOM, however, is a much

broader specification than DHTML.

DOM and parsers

The component that reads a text-formatted XML file or stream and convers it

to a Document is called a parser. There is quite a number of parsers available

that all implement the DOM interface. Some of the parsers are commercial

software, some are free. The parsers also differ in the level of XML validation.

There are non-validating parsers as well as parsers that require well-formed

XML with a DTD.

 

 

DOM Levels

Introduction to DOM Levels

Just as HTML specifications has version numbering, so does DOM. The DOM

Levels define layers of functionality to the DOM interfaces. For example, the

new Netscape 6 browser supports DOM0, DOM1, the DOM2 CSS Interface

and DOM2 Events.

“DOM Level 0”

The HTML DOM is sometimes referred to as DOM Level 0 but has been

imported into DOM Level 1. DOM Level 0 is a mix of Netscape Navigator 3.0

and MS Internet Explorer 3.0 document functionalities.

DOM Level 1

DOM Level 1 concentrates on the actual core, HTML and XML document

modes. It contains functionality for document navigation and manipulation.

DOM Level 1 Core

The DOM Level 1 Core is the heart of DOM. The core is a set of the most

basic functions, i.e. functions for creating, deleting and changing elements

and their attributes. The methods of the DOM Level 1 Core work for both XML

and HTML.

DOM Level 1 HTML

DOM Level 1 HTML is a set of DOM convenience features that are specific to

HTML. The difference between the Core DOM and the HTML DOM is that the

HTML DOM introduces a number of features that are consistent with the

existing models and are more appropriate for script writers. In many cases,

these enhancements are not acclicable to general DOM because they rely on

the presence of a predefined DTDs (the transitional and frameset DTDs for

HTML 4.0).


DOM Level 2

DOM Level 2 includes a style sheet object model and defines functionality for

manipulating the style information attached to a document. It also enables

traversal on the document, defines an event model and provides support for

XML namespaces. DOM2 is now a W3C recommendation, with the exception

of DOM2 HTML, which is still at working draft stage.

DOM Level 2 Core

The DOM2 Core builds on the DOM1 Core, adding a few new methods and

attributes to the core interfaces.

DOM Level 2 HTML

The DOM2 HTML builds on the DOM1 HTML specification, adding some new

attributes to the interfaces and addressing DOM0 backwards-compatibility

issues.

DOM Level 2 Views

A View that’s associated with a document can be e.g. a computed view on a

document after applying a CSS stylesheet, or multiple presentations (e.g. a

frame vs. frameless version) of the same document in a client. A view can be

static, representing the state of a document when the view was created; or

dynamic, where the changes that are made to the document can be seen in

the view as well. The DOM2 Views specification doesn’t make a statement

regarding this nature of the views, it just defines View interfaces that can be

used with DOM Documents.

DOM Level 2 Style

DOM2 Style contains definitions for DOM Level 2 Style Sheets and DOM

Level 2 CSS. The interfaces defined in DOM2 Style Sheet are base interfaces

that can be used to represent any type of style sheet. The DOM2 CSS

interfaces can be used to access and modify the style and presentation

control of CSS level 2.

DOM Level 2 Events

In the DOM2 Event model a generic system is described that allows the

registration of event handlers, describes event flow through a DOM tree

structure, and provides basic contextual information for each event. The event

model contains the functionality of the event systems in DOM0 level browsers.

DOM Level 2 Traversal and Range

Traversal and Range are interfaces that allow applications to dynamically

traverse and identify a range of content in a document. Defining a Range of

content is analogous to selecting a section of a document in a word

processor, using the mouse or keyboard. The Traversal feature provides

interfaces for navigating through a range of nodes.

DOM Level 3

DOM Level 3 will address document loading and saving as well as content

models (such as DTD’s and schemas) with document validation support. In

addition, it will also address document views and formatting, key events and

event groups. First public working drafts are available on the W3C website.


DOM Level 3 Core

The DOM3 Core expands the DOM2 core but shouldn’t add new interfaces.

 

DOM Level 3 Events

The DOM3 Events specification expands the DOM2 specification by

introducing new complimentary interfaces and adding new event sets to those

already defined.

DOM Level 3 Content Models and Load and Save

This is an interface that allows programs and scripts to dynamically access

and update the content, structure and style of documents. It builds on the

Level 3 Core. The Content Models and Validation module provides a

representation for XML content models, e.g. DTD’s and XML Schemas.

Advertisements

About Jaggi
love technology, always updated on the latest and current happenings, seminars, tech.Ed, virtual days! Be Yourself!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: