Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference of JAXP, JDOM, DOM4J,and XERCES?

Tags:

java

xml

jaxp

jdom

What is the difference of them? It is said that JAXP is only a API Specification, JDOM and DOM4J realized it, is it right? And all of them need a XML parser, just like XERCES, is it right? thanks in advance!

like image 1000
Y.L. Avatar asked Sep 18 '12 15:09

Y.L.


2 Answers

JAXP (JSR-206)

Is a set of standard APIs for Java XML parsers. It covers the following areas:

  • DOM (org.w3c.dom package)
  • SAX (org.xml.sax package)
  • StAX/JSR-173 (java.xml.stream)
  • XSLT (javax.xml.transform)
  • XPath (javax.xml.xpath)
  • Validation (javax.xml.validation)
  • Datatypes (javax.xml.datatype)

This standard was created by an expert group with representatives from many companies and individuals. As a standard this means there are multiple implementations (Xerces implements JAXP), and it can be included in the JDK.

Xerces

Is an open source Java XML parser that provides DOM and SAX implementations that are compliant with the JAXP standard.

JDOM and DOM4J

Are open source Java XML parsers.

like image 116
bdoughan Avatar answered Sep 17 '22 23:09

bdoughan


You're comparing apples and automobiles.

  • JAXP is an API that is now bundled with the JDK
  • JDOM is a different API, but also a library
  • DOM4J is also a different API and library

  • XERCES is a XML parser implemented in Java. A version of XERCES is also bundled in the JDK.

Which API you use is largely a question of personal preference. I like JDOM in part because I'm used to working with it. There are, similarly, several implementations of XML parsers. If you're programming in Java using a recent JDK, you will be able to use JAXP without having to add external libraries.

like image 22
theglauber Avatar answered Sep 21 '22 23:09

theglauber