9.4.2. Features on Factories, Properties on Parsers
One common mistake is to mix up factories and properties in the JAXP
world. The best way to remember the correct application is to
memorize the phrase "features on factories, properties on
parsers." You would be amazed at the number of mails I get
insisting that the sender has a "corrupt" version of
JAXP, because the following code won't compile:
SAXParserFactory factory = SAXParserFactory.newInstance( );
factory.setProperty(
"http://apache.org/xml/properties/dom/document-class-name",
"org.apache.xerces.dom.DocumentImpl");
Of course, this is a property, and therefore must be set on a
SAXParser instance, not a
SAXParserFactory instance. The reverse, of course,
holds true for setting features on parsers:
SAXParser parser = factory.newSAXParser( );
parser.setFeature("http://xml.org/sax/features/namespaces", true);
In either case, it is user error, not a strange download problem
where all but a few methods came across OK (I generally refer these
people to some good books on I/O). This is also a good case of the
Javadocs not being used when they should. I'm a firm believer
in the value of Javadoc.