By the way, if you're curious you can look at the code for SAXParserFactory (and its default concrete subclass in Java 1.4) in the Apache Crimson CVS (which is ungodly slow today, not sure why). It's easy to see that it never returns any parser other than Crimson, regardless of what features you ask for. Of course, other implementations like Xerces will return different defaults. But the SAXParserFactory will not iterate through all installed parsers looking for one that satisfies all the requested features. I suppose you can imagine one that does that, but I've never seen one like that, and the one in Java 1.4 certainly doesn't do that.

What's really strange though is that when you try to set a feature on the factory, then the factory actually creates an XMLReader to see if an exception is thrown, and then throws the reader away! In other words. SAXParserFactory.setFeature() invokes XMLReader.setFeature()! The SAXParserFactory doesn't even know what features it can support until the XMLReader tells it! Talk about a hack. Check it out for yourself:

http://cvs.apache.org/viewcvs.cgi/xml-crimson/src/org/apache/crimson/jaxp/


--


Elliotte Rusty Harold
[EMAIL PROTECTED]
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA

Reply via email to