Friday, September 4, 2009

What is JAXB

JAXB is important in binding XML to Java classes. JAXB allows java programmers to process XML and XML data without having to know XML processing. The developer does not have to create or use SAX parser. JAXB makes use of the given XML schema and generates the required JAVA classes corresponding to the schema.


 

Why do we need XML representation of data?

One of the fundamental concerns in Webservices based systems is to be able to transmit data in an interoperable manner. XML has emerged as the standard for exchanging data across disparate system.


 

How is JAXB different and more preferable in comparison to using XML parsers like SAX and DOM?

Parsers like SAX and DOM are commonly used to access XML documents in a Java programming language. Programmers invoke DOM and SAX parsers to parse through the XML document and logically break it up into discrete pieces.

SAX parsers: In the SAX approach, the parser starts at the beginning of the document and passes each piece of the document to the application in the sequence it finds it. Nothing is saved in memory. The application can take action on the data as it gets it from the parser, but it can't do any in-memory manipulation of the data. For example, it can't update the data in memory and return the updated data to the XML file.

DOM parsers: In the DOM approach, the parser creates a tree of objects that represents the content and organization of data in the document. In this case, the tree exists in memory. The application can then navigate through the tree to access the data it needs, and if appropriate, manipulate it.

With JAXB programmers can get access to data without having to know XML or XML processing.

No comments: