Elliotte Rusty Harold wrote:
At 12:56 PM +1000 3/4/04, Peter B. West wrote:

            SAXParserFactory factory = SAXParserFactory.newInstance();
            return factory.newSAXParser().getXMLReader();


What I ask on reading this code is why you're using SAXParserFactory at all? SAXParserFactory is a Sun class they invented to fill a hole in SAX 1.0. It's unnecessary in SAX 2.0. SAX2 apps should use XMLReaderFactory instead, which has the correct defaults you want in the first place. It would look something like this:

   protected static XMLReader createParser() throws FOPException {
        try {
            XMLReader parser = XMLReaderFactory.createXMLReader();
            return parser;
        } catch (SAXException se) {
            throw new FOPException("Could not find a parser. Make sure the"
            + "???? system property is set");

That's off the top of my head so it may not compile, and there are ways to look for alternative parsers if you don't find one immediately (See http://www.cafeconleche.org/books/xmljava/chapters/ch07.html#d0e9994 ) but you get the idea.


I think this might be because the HEAD developers were moving to a JAXP implementation, and SAXParserFactory is still in the 1.4 javax.xml.parsers package, which, AIUI, is what one is supposed to use for JAXP-compatible applications. I don't know much about JAXP, so this could be wrong.

Peter B. West <http://www.powerup.com.au/~pbwest/resume.html>

Reply via email to