Opinion
DOM Perignon
The Champagne of Object Models
By
David Weinberger
This
essay originally appeared in the November 5, 1998 issue of David Weinberger's
Journal of the Hyperlinked Organization (JOHO), online at www.hyperorg.com.
Take documents, objects and
models. Mix 'em together, and what do you have?
A daring centerspread for the merger of Office Systems Magazine
and the Frederick's of Hollywood catalog? Or a really important standard
for the Web?
Unfortunately, all you have is a new standard.
The DOM makes all of the structures and parts of a Web page available
to any application that knows how to talk to a browser (well,
to a new browser that implements the DOM, such as MSIE 5 and Netscape
5).
What is a document object model? It's a representation of the structure
of a document. At its simplest, a document is a list of parts:
a title, subtitle, paragraph, etc. But just about every document with
which we deal in real life is not a simple sequence of bits but a hierarchy
of nested bits.
For example, this sentence not only follows the preceding one, but
is also part of an article called "DOM Perignon" which is
part of an online publication which is part of a family of online publications.
And, of course, documents can easily be far more complex than that.
The DOM captures the structure of any XML document.
The main aim of the DOM is to enable computer applications to find
everything on a page. An application needs to be able to walk through
a document and identify every element so that the app can decide whether
it is supposed to operate on that piece. For example, an application
might want to find every hyperlink in a document in order to redirect
them depending on whether the user has pressed a button marked "Beginner"
or one marked "Expert." Alternatively, an application might
need to find every item in a list that carries the XML tag <Tool_List>.
A standard DOM makes this type of thing a snap (so long as you can
rub your stomach and pat your head while reallocating memory arrays
in C). The article "Introducing
the Browser Object Model" gives additional background on the
object model built into v4 browsers.
Therefore, it is very good news that the two squabbling brats
of the Web have agreed, pretty much, on a common DOM specification because
otherwise the Java application that worked with one browser would crap
out in the other. As things stand it's pretty remarkable that pages
work roughly the same in both browsers. (Ok, fine, send me your examples
of pages that only work in one browser .... TBTF
-- one of my favorite 'zines -- maintains a current list of 'em [talk
about your fun hobbies!]).
All hail, DOM!