0% found this document useful (0 votes)
2 views

JAXB

Uploaded by

zozo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JAXB

Uploaded by

zozo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

JAXB

1
Objectives
2

• Introduction JAXB
• JAXB example
Introduction JAXB
3

 JAXB stand for Java Architecture for XML Binding

 The javax.xml.bind.JAXB class defines convenience

methods for common, simple use of JAXB.Following are the


important points about JAXB −
 This class consists of marshal and unmarshal methods.

 All the methods on this class require non-null arguments to

all parameters.
Features of JAXB 2.0
4

1) Annotation support: JAXB 2.0 provides support to annotation so less coding is


required to develop JAXB application. The javax.xml.bind.annotation package
provides classes and interfaces for JAXB 2.0.

2) Support for all W3C XML Schema features: it supports all the W3C schema
unlike JAXB 1.0.

3) Additional Validation Capabilities: it provides additional validation support by


JAXP 1.3 validation API.

4) Small Runtime Library: it required small runtime library that JAXB 1.0.

5) Reduction of generated schema-derived classes: it reduces a lot of generated


schema-derived classes.
Data Binding
5

• Data binding is a process that parses the document, extracts the


data, and allows the data to be processed and produces usable
Java classes.

• With data binding, there are three distinct processes that can
occur one after another, in differing order, or in completely
unrelated processes.
– Class generation
– Unmarshaling
– Marshaling
Data Binding
6

• Class generation provides a means to convert an XML document to


Java class.

• Unmarshaling is the technique of converting an XML document


into an instance of a Java class using an appropriate data binding
framework or set of APIs.

• The process of generating XML documents from the Java objects


with a data binding framework or set of APIs and is called
marshaling.
Data Binding – Process
7

Schema or DTD
definition
Schema comiler Generated
(eg.XJC) Classes(.java file)

JAXB Binding
schema

Resultant class
(.java file)
Data Binding – Step by Step
8

General steps to use the JAXB Runtime Binding Framework:

– Develop the database schema or structure.


– Construct the XML document. (optional).
– Define schema for the XML document or the DTD.
– Compile the schema with the XJC binding compiler.
– Develop the JAXB client application using the Java content classes
generated by the XJC binding compiler along with the javax.xml.bind JAXB
interfaces.
– Set your CLASSPATH to include all of the JAR files.
– Compile all of your Java sources with the javac Java compiler.
– Execute.
Q&A
9

You might also like