[XML-SIG] Reconsidering the DOM API

Paul Prescod paul@prescod.net
Wed, 28 Jun 2000 10:41:17 -0700


Benjamin Saller wrote:
> 
> ...
>
> Perhaps I am being too pessimistic, but in my experience if
> a[0][1][0]['foo'] makes sense at the time you are building the code and
> its half the length of the attribute names option people will take the
> shortcut. 

I can't speak for all people, but the real problem with that code, and
the real reason to use element type names rather than numbers, is that
ordinal-based code is very fragile. It's so fragile that it hardly ever
works. It's so fragile that it seldom even works for your *test
document*. It's so fragile that hardly anyone would do it that way. I'm
sorry I brought up the example!!!!

> Its also somewhat more complex than the common case seems to
> need, but I could be wrong.

Full DOM 2+? Maybe. 

Core DOM? How is it complex? You have parents, children, elements,
attributes, siblings, etc. Usability enhancements are important (I
typically combine XPath with the DOM whenever I need to do DOM work) but
they are extensions. The DOM itself is not that complicated.

I mean the DOM was designed for knuckle-dragging JavaScript
"programmers" (term used lightly). The core concepts can be taught in
five minutes (see the XML Howto). I don't see the complexity. I would
say rather that it isn't complex enough in that it is lacking query
facilities (i.e. XPath).

-- 
 Paul Prescod - Not encumbered by corporate consensus
The calculus and the rich body of mathematical analysis to which it 
gave rise made modern science possible, but it was the algorithm that 
made the modern world possible.
	- The Advent of the Algorithm (pending), by David Berlinski