[jdom-interest] JAXPAdapter and JAXP

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun Apr 7 15:01:01 PDT 2002

I'm going through the adapter classes right now to clean up the 
exceptions and I noticed that the createDocument() method in JAXPAdapter 
uses reflection instead of directly calling JAXP. e.g.:

    public Document getDocument(InputStream in, boolean validate)
        throws ClassNotFoundException, NoSuchMethodException,
               IllegalAccessException, InvocationTargetException {

        // Try using JAXP...
        // Note we need DOM Level 2 and thus JAXP 1.1.

        // Try JAXP 1.1 calls to build the document
        Class factoryClass =

        // factory = DocumentBuilderFactory.newInstance();
        Method newParserInstance =
            factoryClass.getMethod("newInstance", null);

This makes the code more complex and makes it potentially throw a lot 
more exceptions. Is there any particular reason for this? Do we relaly 
need the code to compile or this class to run in environments where JAXP 
1.1 is not available? We do ship Xerces with JDOM, and it does support 
JAXP. I suggest that most of this method could be easily rewritten not 
to use reflection.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|           The XML Bible, 2nd Edition (IDG Books, 2001)             |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     | 
|  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |

More information about the jdom-interest mailing list