OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Switching between DOM and SAX

[ Lists Home | Date Index | Thread Index ]
  • From: David Brownell <db@Eng.Sun.COM>
  • To: xml-dev@ic.ac.uk
  • Date: Thu, 01 Oct 1998 06:45:12 -0700

[ Resend, now that I can post again ]

  • From: David Brownell <db@eng.sun.com>
  • To: xml-dev@ic.ac.uk
  • 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.

- Dave


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS