[ Resend, now that I can post again ]
--------------D8B0C4287D89CD6DB719475E
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-ID: <3607DC81.9DCEE7F5@eng.sun.com>
Date: Tue, 22 Sep 1998 10:21:05 -0700
From: David Brownell <db@eng.sun.com>
X-Mailer: Mozilla 4.03 [en] (WinNT; U)
MIME-Version: 1.0
To: xml-dev@ic.ac.uk
Subject: Re: Switching between DOM and SAX
References: <199809201557.LAA24630@locke.ccil.org>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
John Cowan wrote:
>
> Sure, but in SAX (event stream) to DOM conversion, you need to capture
> *all* the SAX events if you are to be able to satisfy the guarantees
> that the DOM model makes.
Well, sort of ... the "capture" can be as weak as "accept the callback
to see if you want to save that bit of content". DOM doesn't guarantee
much, and since converting from text/URI/... to a DOM Document object is
out of scope for level 1, ANY games you play that provide a DOM node at
the end of the process are legal. (On the other hand, SAX assumes that
you parse entire documents ... reasonable, that's how XML is defined.)
For example, it's well within the DOM spec to have an element which
is part of a document but has no parent. (Take a document that has
only a root element; remove that child element, voila!) You could build
one like that while you parse, and return it ... having discarded any
parent nodes you weren't interested in.
Similarly, you can take XML document text and turn it into a DOM tree
that's not isomorphic with the input text because it's been transformed.
Algorithmic transformations are possible, so are XSL-driven ones.
- Dave
--------------D8B0C4287D89CD6DB719475E--