[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Does SAX make sense?


how does a saxophone work
On Sat, Apr 19, 2003 at 05:38:42PM +1000, Rick Jelliffe wrote:
> I am idly wondering whether unpooled steaming Java APIs of XML documents (e.g. SAX)
> really make as much sense as we might like them to.

  Personally I think SAX makes a terribly bad API for programmers,
forcing then to work with callback, i.e. loosing the thread of control
dusing parsing, and making hard to actually gather data from just
an event stream. SAX is too low level for most use, through it certainly
has its use as a lower API to implement the lower level services. But
those layers are not where the typical programmer should meet the XML data.

> It strikes me that there are two factors that undermine the benefits of streaming processing:
> 
> * XML documents are rarely smaller than memory

  That doesn't reflect the use cases I see. Most of the XML documents on
my machine are less than a megabyte, maybe you meant "larger than memory",
right ?

> * Java implementations typically only garbage collect when they get "near" 
>   to filling their heaps.

  One more point to the Python camp and reference counting ...

> That being the case, it seems that simple streaming such as SAX provides
> don't make sense.  They would be better to either
> 
> * have the SAX stream kept cached for the lifetime of the document
> (or have some kind of weak reference perhaps) since they are in memory 
> anyway (though unreachable), allowing backward-looking XPaths; or
> 
> * requiring SAX clients return events to a pool (which would reduce 
> memory use).
> 
> Does that sound right to anyone?

  No the event model is just too complex anyway. If you stream you
must have a good reason for it (usually memory requirement), if you
don't need it, use a more convenient model, if you need to stream
there are better interfaces like the XmlReader interface from
C# or others. Low memory requirement should not imply having to
work in callback mode. Streaming should not imply having to work
with very low level API [1].

Daniel

[1] shameless plug http://xmlsoft.org/xmlreader.html#Mixing about mixing
    DOM/XPath and streaming in the upcoming libxml2 releases.

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@r...  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.