且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JAXB是否在内部使用SAX或DOM?

更新时间:2022-12-04 12:05:13

注意:我是 EclipseLink JAXB(MOXy) 领导和 JAXB 2(JSR-222) 专家组。

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

单个JAXB(JSR-222)实现可以***选择用于不同输入的底层解析技术。我们在MOXy中使用的策略是使用StAX( javax.xml.stream )尽可能多。

Individual JAXB (JSR-222) implementations are free to choose the underlying parsing technologies they use for different inputs. The strategy we use in MOXy is to use StAX (javax.xml.stream) as much as possible.

有多种方法可以控制JAXB impl使用的解析器。下面是我给出的答案的链接,解释了如何让JAXB impl使用特定的SAX解析器:

There are ways to control what parser your JAXB impl uses. Below is a link to an answer I gave explaining how to get a JAXB impl to use a specific SAX parser:

  • How to disable DTD fetching using JAXB2.0

另一个答案解释如何确保使用StAX:

And another answer explaining how to ensure that StAX is used:

  • Make JAXB go faster