Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JAXB uses SAX or DOM internally?

Tags:

xml

jaxb

I could not find answer for this question , could anybody please let me know

Since JAXB is an higher level API , does JAXB uses SAX or DOM internally ?

like image 435
Pawan Avatar asked Mar 29 '12 10:03

Pawan


People also ask

Does JAXB use DOM or SAX?

JAXB allows applications to access the data in the XML from the object rather than using the DOM or SAX to retrieve the data from a direct representation of the XML itself. It is most often used alongside Java API for XML Web Services (JAX-WS) and makes objects creation and mapping easy.

Is JAXB DOM parser?

JAXB is not directly comparable to DOM and SAX. The Java DOM and SAX parsing APIs are lower-level APIs to parse XML documents, while JAXB (Java API for XML Binding) is a higher-level API for converting XML elements and attributes to a Java object hierarchy (and vice versa).

How does JAXB work in Java?

JAXB simplifies access to an XML document from a Java program by presenting the XML document to the program in a Java format. The first step in this process is to bind the schema for the XML document into a set of Java classes that represents the schema.


1 Answers

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

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.

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

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

  • Make JAXB go faster
like image 132
bdoughan Avatar answered Sep 19 '22 05:09

bdoughan