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

2

7

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!

Sulfonate answered 18/9, 2012 at 15:21 Comment(0)
Z
10

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.

Zaid answered 18/9, 2012 at 15:32 Comment(1)
To be fair, I also like JDOM because it has a Java, object-oriented design feel to it, unlike other APIs, which tend to be more XML-centric and language-agnostic.Zaid
C
13

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.

Crumhorn answered 18/9, 2012 at 17:8 Comment(2)
so, JDOM and DOM4J only supprt DOM? That is the difference of JDOM&DOM4J and XERCES?Sulfonate
JDOM and DOM4J support an object representation of XML. I do not believe that they support the W3C concept of a DOM: w3.org/DOMCrumhorn
Z
10

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.

Zaid answered 18/9, 2012 at 15:32 Comment(1)
To be fair, I also like JDOM because it has a Java, object-oriented design feel to it, unlike other APIs, which tend to be more XML-centric and language-agnostic.Zaid

© 2022 - 2024 — McMap. All rights reserved.