SAX1 Support

This section provides a brief overview of the SAX1 classes and migration support and of differences between SAX1 and SAX2. SAX1 is a subset of SAX2, so SAX2 is backward compatible. The only reason you might not want to have the SAX2 classes and interfaces in your class path is to avoid compiler warnings telling you when you’re using now-deprecated APIs.

You shouldn’t be using SAX1 APIs to write new code, but you may need to maintain or migrate older code written using these classes. As soon as possible, plan a maintenance step that involves switching to the new SAX2 versions of the APIs. This may include getting rid of some “home-brew” solutions for namespace support. (Some applications have found previously unsuspected bugs when they’ve made such changes; be alert!) This section has been written to highlight those changes.

If your parser supplier hasn’t provided SAX2 support by now, it’s probably also time to switch suppliers; however, you can use the ParserAdapter class to make these changes without changing parsers. In fact, if you’re using ParserFactory to get the system default parser and haven’t set a SAX2 XMLReader default, the reference XMLReaderFactory distribution will automatically wrap the SAX1 parser you’ve probably already identified using the org.xml.sax.parser system property. That is, just putting the SAX2 classes in your class path normally lets you start using SAX2 without needing to change your application configuration. (You can go the other ...

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.