[jdom-interest] JAXPAdapter and JAXP
Jason Hunter
jhunter at acm.org
Sun Apr 7 19:16:59 PDT 2002
I don't want a JDOM compile or execution to require JAXP, at least not
when it's so easy to avoid that requirement by just using reflection.
JAXP has yet to be licensed such as to officially allow open source
implementations. It doesn't make sense for an open source project to
depend on non-open source code when it can be avoided.
Nevermind that Xerces provides JAXP; that was very close to being
jettisoned for license reasons, and still could be if Sun doesn't fully
follow through on the agreement reached with Apache recently.
-jh-
Elliotte Rusty Harold wrote:
>
> 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.
> Class.forName("javax.xml.transform.Transformer");
>
> // Try JAXP 1.1 calls to build the document
> Class factoryClass =
> Class.forName("javax.xml.parsers.DocumentBuilderFactory");
>
> // 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/ |
> +----------------------------------+---------------------------------+
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list