Skip to Content
Java and XML, 3rd Edition
book

Java and XML, 3rd Edition

by Brett McLaughlin, Justin Edelson
December 2006
Intermediate to advanced content levelIntermediate to advanced
479 pages
13h 52m
English
O'Reilly Media, Inc.
Content preview from Java and XML, 3rd Edition

Chapter 11. Data Binding with JAXB

As I mentioned at the end of the last chapter, data binding is an XML processing technique that eliminates references to XML nodes from your code. Instead of working with elements and attributes, your code uses classes named Customer and PurchaseOrder. This first means that you have to define the structure of your XML documents using a schema, typically either an XML Schema or a DTD. To bind this schema to specific Java classes, which could include generating those classes from the schema, you’ll use a data binding framework. These are generally composed of code-generation tools to build Java classes from a schema and a runtime library that converts an XML document into a tree of Java objects (and vice versa). There are many data binding frameworks available for Java. In this chapter, we’ll look specifically at one: the Java Architecture for XML Binding ( JAXB).

Data Binding Basics

Before getting into the specifics of JAXB, it will be helpful to take a look at the concepts that underlie data binding in general. Fundamentally, data binding is similar to the document object model APIs we’ve discussed—DOM, JDOM, and dom4j—in that it defines an association, referred to as a binding, between an XML document and a tree of Java objects. A tree of Java objects can be created from an XML document and vice versa. The difference is that when data binding, the Java objects mapped to the document are instances not of generic interfaces representing elements ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java & XML Data Binding

Java & XML Data Binding

Brett McLaughlin
Mastering Java 11 - Second Edition

Mastering Java 11 - Second Edition

Dr. Edward Lavieri Jr., Mandar Jog
XML in a Nutshell, 3rd Edition

XML in a Nutshell, 3rd Edition

Elliotte Rusty Harold, W. Scott Means

Publisher Resources

ISBN: 059610149XSupplemental ContentErrata Page