Advantages and Disadvantages of SAX


Being event based, SAX offers several benefits to its user. At the same time, it also comes with certain disadvantages. Both sides of this coin are presented in this section.

SAX presents four particularly compelling advantages, each of which is presented here:

  • q SAX generates the events continually while processing a document. The document analysis can begin immediately, and you need not wait to do the analysis until the entire document is processed. This is equivalent to streaming media, where the media contents are rendered immediately and you need not wait until the entire media is read.

  • q SAX examines the document contents as it reads the document and immediately generates events on the processing application. Thus, it need not store the data that it has already processed. This puts fewer constraints on the application memory requirements.

  • q Because the document's contents are not stored in memory, it is easier to process very large documents as compared to other processing techniques such as DOM. Other techniques that require the entire document to be read into memory before processing can sometimes place severe constraints on system resources.

  • q The application need not process the entire document if it is interested in a certain criterion.

After that criterion is met, further processing can be abandoned. Other techniques require the document to be parsed fully before any processing can be done.

SAX does come with certain disadvantages:

  • q SAX is similar to a one-pass compiler. After it reads part of the document, it cannot navigate backward to reread the data it has processed, unless you start all over again.

  • q Because SAX does not store the data that it has processed, you cannot modify this data and store it back in the original document.

  • q Because SAX does not create an in-memory document structure, you cannot build an XML document by using a SAX parser.




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net