September 2003
Intermediate to advanced
336 pages
7h 20m
English
SAX enables you to write code that is completely independent of the underlying parser. The major issue is that you use the XMLReaderFactory.createXMLReader() method to construct new instances of the XMLReader interface rather than calling the constructor directly. For example, here is the correct way to load a SAX2 parser.
XMLReader parser = XMLReaderFactory.createXMLReader();
Below is the wrong way to load a SAX parser.
XMLReader parser = new org.apache.xerces.parsers.SAXParser();
The first statement loads the parser named by the org.xml.sax.driver system property. This is easy to adjust at runtime. The second statement always loads Xerces and can't be changed without recompiling. Both statements may actually create the same object, ...
Read now
Unlock full access