The JAXP APIs
The main JAXP APIs are defined in the
javax.xml.parsers
package. That package contains vendor-neutral factory classes--SAXParserFactory
,DocumentBuilderFactory, and TransformerFactory
--which give you aSAXParser
, aDocumentBuilder
, and an XSLT transformer, respectively.DocumentBuilder
, in turn, creates a DOM-compliantDocument
object.The factory APIs let you plug in an XML implementation offered by another vendor without changing your source code. The implementation you get depends on the setting of the
javax.xml.parsers.SAXParserFactory
,javax.xml.parsers.DocumentBuilderFactory
, andjavax.xml.transform.TransformerFactory
system properties, usingSystem.setProperties()
in the code,<sysproperty key="..." value="..."/>
in an Ant build script, or -DpropertyName="..."
on the command line. The default values (unless overridden at runtime on the command line or in the code) point to Sun's implementation.
Note: When you're using J2SE platform version 1.4, it is also necessary to use the endorsed standards mechanism, rather than the classpath, to make the implementation classes available to the application. This procedure is described in detail in Compiling and Running the Program.
Now let's look at how the various JAXP APIs work when you write an application.