Chapter 2. Introducing SAX2

SAX gets its power from the unifying notion that sequences of event callbacks are powerful and lightweight ways to represent the information in XML documents. Building on that notion, you can create many powerful tools. Most of the essential SAX calls use interfaces, so the interesting behavior comes from how you combine implementations of those interfaces to assemble tools and what those implementations do.

This chapter shows the basic structure of SAX and of several classic SAX applications using an XML parser, the “simple” core of SAX. It starts by showing the essential components and the framework through which they relate. Then it shows how to customize the most important features and concepts in that framework and how to work with the core XML data model of elements, attributes, and text. You’ll also see how to handle errors and learn how SAX exposes XML namespaces.

This chapter focuses on the parts of SAX that essentially every application needs to know. It doesn’t provide full information about every interface. Later chapters elaborate on these structures and concepts, showing additional parts of these APIs, ways to combine SAX components, and how to work with additional parts of the XML data model. Depending on what your application needs to do, you may not need to know much more of SAX than is explained in this chapter.

Producers and Consumers

The first thing to learn is that there are really two kinds of roles in this API—or three, if ...

Get SAX2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.