[Doc-SIG] Producing output

Tony J Ibbs (Tibs) tony@lsl.co.uk
Tue, 11 Sep 2001 11:47:39 +0100


With respect to XML style sheets and other gumph, Paul Moore wrote:
> Um. It wasn't obvious to me. And it still isn't. What are we
> talking about here? I know very little about XML, and I didn't
> see XML as of particular relevance for writing an output formatter.

Ah, there's history in here.

At one stage, I envisaged that a DOM tree (and thus, XML) would be used
as the "glue" between different phases of things - so the parser would
emit a DOM tree, and the formatter would eat it.

Guido (and others) pointed out that DOM trees can be a bit awkward to
use, and that Python has a perfectly good object model, so why transform
the "internal" tree (for you *would* have to be mad to be constructing
the internal tree in DOM - I know, I tried it) into something else
rather than using it directly.

So that's the route being taken (whether David was ever listening to
what I was saying, and would have gone the XML/DOM route, I don't know.
He's quite sensible, you know...)

*However*, the DPS nodes tree (for such I am talking about) is clearly
heavily influenced by XML/DOM - this gives the significant advantage
that it is trivial to transform it *into* a DOM tree, and thence into
XML (which is itself a useful output format, so we're actually up one
format already).

And in an XML world, DTDs or other schema describing pedagogies are a
useful thing to have around - it's another angle on the documentation of
things.

(indeed, having that similarity also gives one good leverage in
*understanding* what the DPS nodes tree is about - simple things like
the use of tagnames, children, attributes, etc. - terminology, I guess -
what it *misleads* me about I haven't yet found!)

Furthermore, I still think that output of DOM/XML will be useful *some*
of the time - for instance the PyPaSax people may be able to make direct
use of at least the DPS stuff (they have their own equivalent of my
compiler->Python stuff, using the basic AST and SAX - scary stuff!).

> I'm expecting to just be tree-walking a data structure

Exactly.

> (which may be a DOM, but who cares?).

Well, if it were DOM your life would be more complex, but that's about
it.

> Style sheets, namespaces and the like don't fit into my
> picture at all.
>
> Have I missed something fundamental?

No, but I have a tendency to borrow (often inaccurately, I'm afraid)
terminology - and if I were writing an XML schema for our stuff, I would
want to use namespaces to localise stuff, 'cos that's what they're for.
But it's not something to worry about.

(personally, I *like* XML, but not entirely for its <tag>...</tag>
stuff - more for the way it and the related standards give interesting
ways of thinking about a document - both as a tree structure and as a
linear structure, both at the same time. That's why I liked SGML as
well, but I've never *used* SGML, and XML is much simpler, and more
accessible (hmm - can I really claim to have *used* XML?). After all,
XML per-se is just one serialisation of the infoset [1]_)

.. [1] yes, please picture a tongue-in-cheek there.
   Pretty please.

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