- From: David Brownell <firstname.lastname@example.org>
- To: email@example.com
- Date: Tue, 22 Sep 1998 10:21:05 -0700
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.