SAX Overview

SAX stands for Simple API for XML. SAX is a callback implementation. As it iterates over each fundamental unit of XML, is that as it reads each unit of XML, it creates an event that the host program can use. This allows the application to ignore the bits it doesn't care about, and just keep or use what is needed. SAX is often used in certain high-performance applications or areas where the size of the XML might exceed the memory available to the running program.

SAX History

The design inspiration and subsequent coodination was done by Dave Megginson, who continues to maintain the SAX Project website. The SAX standard currently is at version 2.0.

SAX Inside of Stylus Studio®

SAX is used everywhere in Stylus Studio®. It is used for building certain representations of XML structure for the XSLT and XQuery Mappers, and also used extensively within the deployment adapters.

SAX Implementations

There have been many implementations of SAX parsers. The Apache project has sponsored some, including Crimson and its successor, Xerces (available in both C++ and Java.) The author of Saxon, Dr. Michael Kay, himself wrote Ælfred — another SAX parser. Oracle has one, there is one called Piccolo, a SAX wrapper is available for James Clark's xp processor.

SAX Interface

SAX is defined in three packages:

The org.sax.xml Package

SAX 2 Interfaces include:

  • AttributeListDeprecated. This interface has been replaced by the SAX2 Attributes interface, which includes Namespace support.
  • Attributes — Interface for a list of XML attributes.
  • ContentHandler — Receive notification of the logical content of a document.
  • DocumentHandlerDeprecated. This interface has been replaced by the SAX2 ContentHandler interface, which includes Namespace support.
  • DTDHandler — Receive notification of basic DTD-related events.
  • EntityResolver — Basic interface for resolving entities.
  • ErrorHandler — Basic interface for SAX error handlers.
  • Locator — Interface for associating a SAX event with a document location.
  • ParserDeprecated. This interface has been replaced by the SAX2 XMLReader interface, which includes Namespace support.
  • XMLFilter — Interface for an XML filter.
  • XMLReader — Interface for reading an XML document using callbacks.

SAX 2 Classes include:

SAX 2 Exceptions include:

The org.sax.xml.ext Package

SAX 2 Extension Interfaces include:

  • Attributes2 — SAX2 extension to augment the per-attribute information provided though Attributes.
  • DeclHandler — SAX2 extension handler for DTD declaration events.
  • EntityResolver2 — Extended interface for mapping external entity references to input sources, or providing a missing external subset.
  • LexicalHandler — SAX2 extension handler for lexical events.
  • Locator2 — SAX2 extension to augment the entity information provided though a Locator.

SAX 2 Extension Classes include:

The org.sax.xml.helpers Package

SAX 2 Helper Classes include:

Wither SAX?

Some tools like SAX better, others like DOM. Some like still other models. Which is best? Well, it depends. One of the advantages in using a tool such as Stylus Studio® is that we've worked hard to determine the best model for different use cases, and the code we use interally or we generate for you uses the most appropriate model. Take a look for yourself by downloading the XML Tool of Tools for a free evaluation copy.


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

Buy Stylus Studio Now

Try Stylus SAX Tools

Only Stylus Studio leverages the Simple API for XML in our tools and processing components - Download a free trial today!

What's New for Stylus Studio® X16?

New XQuery & Web Services Tools, Support for MySQL, PostgreSQL, HL7 EDI, Microsoft .NET Code Generation and much more!

Ask Someone You Know

Does your company use Stylus Studio? Do your competitors? Engineers from over 100,000 leading companies use Stylus Studio, and now you can ask someone from your own organization about their experiences using Stylus Studio.

Free Stylus Studio XML Training:
W3C Member