[XML-SIG] Reconsidering the DOM AP

Paul Prescod paul@prescod.net
Mon, 03 Jul 2000 16:41:15 -0500


[I dont' think that this went out before]
Sean McGrath wrote:
> 
> For the event handling stuff, the principle difference is just
> down to the convenience of event handlers named after element
> type names. If it were just the event-oriented stuff, then
> Pyxie would not offer enough to drag even me away from
> the industry APIs:-)

The only reason we didn't add this to Python SAX is because it falls
down when you try to use namespaces.

> 1)Pyxie uses a "cursor" location metaphor and a
> cut/paste approach which is very different from the
> DOM. I find the Pyxie approach more natural than
> the DOM approach.

But why couldn't a Pyxie cursor move around a DOM? It seems that
cursor.down is just syntactic sugar for 

cursor.current_node=cursor.current_node.childNode[0]

If the former is more natural for you, then you can just write a small
object that implements it.

> 2)Pyxie blends the ease of use of tree-oriented processing
> with the memory efficiency of event-oriented processing
> using a sparse-tree facility. This is no such facility
> in industry APIs (that I know of).

No, but it can be added to industry APIs. My new pulldom (inspired in
large part by Pyxie) has only three methods:

parse()
getNode()
expandNode() (builds a tree)

I believe that those functions are essentially analogous to Pyxie's
equivalent but after I build the tree I can apply one of the two Python
XPath implementations and other DOM packages.

> 3)Pyxie allows you to mix logical navigation with
> parsing and content insertion in a way I find
> very useful in my day to day work. This sort of thing:-

These strike me as still being features of a cursor object which could
work on any tree data structure.

> 4) Pyxie is unashamedly focused on the logical
> model of XML documents. It does not concern itself
> with general entity references, DTD info etc. etc.

Many DOM implementations also restrict themselves in this way.

-- 
 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