[Doc-SIG] How to traverse a document object

Tony J Ibbs (Tibs) tony@lsl.co.uk
Wed, 24 Oct 2001 09:40:19 +0100


David Goodger wrote:
> If you insert methods from outside the module, yes, you *would* be
> presumptuous.

Ah, but the advantage we have with the DPS nodes tree is that one *can*
be presumptuous - it doesn't get one very far with "classic" DOM!

For clarification, my (quick and dirty) HTML output mode works with a
dictionary that links tag name to method name [1]_, with a special case
for "#text" ('cos it's special). Thus it doesn't actually assume much
about what includes what (although things will go strange if the
structure is *not* what one would expect from the spec).

Since I rather want a Writer class that can be customised easily, this
dictionary approach seems simplest for the initial development - it's
easy to subclass the Writer and just amend the dictionary entries.

.. [1] Actually, the tag name keys a method name and some
   optional arguments, but that's enough detail for this
   discussion.

I'm sure some visitor model would be nice at some stage, though - once
one has understood the thing (!) it works very nicely (cf. the
``compiler`` package).

Tibs

--
Tony J Ibbs (Tibs)      http://www.tibsnjoan.co.uk/
"Bounce with the bunny. Strut with the duck.
 Spin with the chickens now - CLUCK CLUCK CLUCK!"
BARNYARD DANCE! by Sandra Boynton
My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.)