[Doc-SIG] How to traverse a document object
Tony J Ibbs (Tibs)
Thu, 25 Oct 2001 09:45:12 +0100
David Goodger and Paul Moore were discussing various things:
> DOM *is* useful though. The reason DOM *is* used is because
> it *is* generic.
I rather like DOM - it's a bit clunky, but it is generic, and it
provides a useful (to me) hook for thinking about (some properties of)
XML [the fun, of course, is when you're thinking of XML as tree and
"list" at the same time!]. But it is deliberately made so that one does
*not* subclass its elements - when constructing a DOM tree you have
(well, that's the theory) to ask the document instance to give you new
nodes, and so one is restricted to the classes that are already defined
_. This means that, as David says, you have to use attribution to
discriminate between elements, which is not very convenient for
..  there are attempts (sorry, don't have a reference to hand)
to automatically "mirror" a DOM tree by Python classes which
have "nicer" names, I believe, but that has its own problems.
> The reStructuredText parser is *building* a document
> tree piecemeal, and it's easier and more powerful to
> say ``node = nodes.list()`` than it is to say
> ``node = minidom.Element("list")``,
As I'm currently working on code to build a DPS tree, I can vouch that
it is easier *with* the DPS tree than it would be with DOM - not least
because if I can abstract useful building concepts out of what I'm
doing, I can submit a patch to David which will make it easier for
everyone to do such stuff.
Also, as I understand it, in a proper DOM you aren't meant to ask the
package to construct an object for you - it is meant to be the document
instance that knows how to do this. But I can't be bothered to look up
the "correct manner".
Then we move on to blockquotes:
Paul (and then David) wrote:
> > I view blockquotes as basically a way of displaying a
> > quotation, or something similar, without the "..."
> > around it.
> > As such, it would be a pretty rare thing.
Depends entirely on one's application area! I still have plans to start
a Wiki next year, using reST as its text format, following on from an
apazine/fanzine I used to produce, which discusses matters relating to
reading/books/etc. In *that* context, block quotes are quite likely to
occur - both quoting external sources, and also quoting other people
*However*, notwithstanding the HTML "standard"s descrption, I've yet to
see a browser that distinguishes the first two uses of block quotes -
that is, quotation versus inset text - by using emphasis. It's another
instance, I think, of browser writers following each other rather than
the HTML text.
Meanwhile, I happily use blockquotes a lot to inset text for
"commentary" purposes - something that is difficult to convey otherwise
(of course, I also use parentheses and em-dashes a lot in writing text,
so perhaps I'm not a perfect examplar).
> I may not be a typical user, but then again I have an "in" with the
> wrote the spec. ;-)
> I'm starting to write a document defining the roles of each
> of the DPS doc tree elements, independently of the markup syntax.
> I've just barely begun.
> It's available at http://docstring.sourceforge.net/spec/doctree.txt.
By the way, this is a wonderful thing to have started, even if it is in
its early days yet.
Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/
Give a pedant an inch and they'll take 25.4mm
(once they've established you're talking a post-1959 inch, of course)
My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.)