|
Java Architecture for XML Binding |
|
|
The general steps to use the JAXB API are:
1. Bind the schema
Bind the schema for the XML document
requires two steps:
Generate classes. An XML schema is used as
input to the JAXB binding compiler to
generate JAXB classes based on that schema.
Compile classes. All of the generated source
files and the application code must be
compiled.
2 Unmarshal
XML documents written according to the
constraints in the source schema are
unmarshalled by the JAXB binding framework
i.e. the XML documents are unmarshalled into
the Java content objects. Unmarshalling is a
wider process, it includes the following steps
to follow:
Generate content tree. The unmarshalling
process generates a content tree of data
objects instantiated from the generated JAXB
classes; this content tree represents the
structure and content of the source XML documents which are now directly available to
the developers program. Now developer can
access and process XML data without having
to know XML or XML processing.
Validate (optional) the unmarshalling
process optionally involves validation of the
source XML documents before generating the
content tree.
Process the content. The client application
can modify the XML data represented by the
Java content tree by means of interfaces
generated by the binding
compiler.
3. Marshal.
The processed content tree is marshalled out
to one or more XML output documents. The
content may be validated before marshalling. |
|
Now its Time to Dig the Things Deeper
I. Bind the Schema
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 requires to bind the
schema for the XML document into a set of Java classes that represents the schema. Where
a schema is an XML specification that governs
the allowable components of an XML document
and the relationships between the components.
Binding: Binding a schema means generating
a set of Java classes that represents the
schema. All JAXB implementations provide a tool
called a binding compiler to bind a schema
(the way the binding compiler is invoked can be
implementation-specific). For example, the JAXB
Reference Implementation provides a binding
compiler that one can invoke through scripts
i.e. you may bind a schema with a binding
compiler provided by the JAXB Reference
Implementation.
The binding compiler generates a set of
interfaces and a set of classes implementing
the interfaces.
Then this binding compiler compiles and
packages the generated interfaces and classes
into a package.
II. Unmarshal the Document
Unmarshalling an XML document means
creating a tree of content objects representing
the content and the organization of the
document. The content tree is not a DOMbased
tree. In fact, content trees produced
through JAXB are more efficient in terms of
memory use than DOM-based trees. |
|
Oct 2007 | Java Jazz Up | 47 |
|
|
|
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70,
71,
72,
73,
74,
75,
76,
77,
78,
Download PDF |
|
|
|
|
|
|
|
|
|