java JAXP、JDOM、DOM4J 和 XERCES 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12480046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 09:04:36  来源:igfitidea点击:

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

javaxmljdomjaxp

提问by Y.L.

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!

它们的区别是什么?据说JAXP只是一个API规范,JDOM和DOM4J实现了,对吗?而且它们都需要一个 XML 解析器,就像 XERCES 一样,对吗?提前致谢!

回答by bdoughan

JAXP (JSR-206)

JAXP (JSR-206)

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

是一组用于 Java XML 解析器的标准 API。它涵盖以下领域:

  • DOM (org.w3c.dompackage)
  • SAX (org.xml.saxpackage)
  • StAX/JSR-173 (java.xml.stream)
  • XSLT (javax.xml.transform)
  • XPath (javax.xml.xpath)
  • Validation (javax.xml.validation)
  • Datatypes (javax.xml.datatype)
  • DOM(org.w3c.dom包)
  • SAX(org.xml.sax包)
  • StAX/JSR-173 ( java.xml.stream)
  • XSLT ( javax.xml.transform)
  • XPath ( javax.xml.xpath)
  • 验证 ( javax.xml.validation)
  • 数据类型 ( 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 实现 JAXP),并且可以包含在 JDK 中。

Xerces

塞尔西斯

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

是一个开源 Java XML 解析器,提供符合 JAXP 标准的 DOM 和 SAX 实现。

JDOM and DOM4J

JDOM 和 DOM4J

Are open source Java XML parsers.

是开源 Java XML 解析器。

回答by theglauber

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.

  • JAXP 是现在与 JDK 捆绑在一起的 API
  • JDOM 是一个不同的 API,也是一个库
  • DOM4J 也是不同的 API 和库

  • XERCES 是一个用 Java 实现的 XML 解析器。JDK 中还捆绑了一个 XERCES 版本。

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.

您使用哪种 API 在很大程度上取决于个人喜好。我喜欢 JDOM 部分是因为我习惯使用它。类似地,有几种 XML 解析器的实现。如果您使用最新的 JDK 在 Java 中编程,您将能够使用 JAXP 而无需添加外部库。