Example SAX Applications

It may be hard to believe, but you just learned enough about SAX to create and understand simple SAX applications!

Simple Template Processing

Many applications of XML involve generating HTML (or XHTML) content. There are many schemes for generating such output, not limited to the use of the powerful XSL Transformations facility with its style sheets, as presented in Chapter 10, "Understanding the eXtensible Style Language (XSL)," and Chapter 11, "Creating XSL Style Sheets." This example presents a much simpler tool that just performs some text substitutions in templates.

The document handler shown in Listing 16.4 can be given to a SAX parser. When that parser is used to process an XML file, all of its elements and text ...

Get XML Unleashed 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.