XML data binding. Yes, it’s yet another Java and XML API. Haven’t we seen enough of this by now? If you don’t like SAX or DOM, you can use JDOM or dom4j. If they don’t suit you, SOAP and WSDL provide some neat features. But then there is JAXP, JAXR, and XML-RPC. If you just can’t get the swing of those, perhaps RSS, portlets, Cocoon, Barracuda, XMLC, or JSP with XML-based tag libraries is the way to go.
The point of that ridiculous opening is that you, as a developer, should expect some justification for buying yet another XML book, on yet another XML API. The market seems flooded with books like this, and the torrent has yet to slow down. And while I realize that I use circular reasoning when insisting that this API is important (I did write this book on it), that’s just what I’m going to do.
XML data binding has taken the XML world by storm. Thousands of programmers simply threw up their hands trying to track SAX, DOM, JDOM, dom4J, JAXP, and the rest. It’s become increasingly difficult to parse a silly little XML document, rather than increasingly simple. If it’s not namespaces that get you, it’s whitespace. Is that carriage return after my element name significant? Well, it depends on whether you specify a DTD; oh, you used an XML Schema? Well, we don’t support that yet. I’m sure you know exactly what I’m talking about.
The reason why XML data binding is important, and so remarkably different from other approaches, is because it gets you from XML to business data with no stops in between. You don’t have to deal with angle brackets, entity references, or namespaces. A data binding framework converts from XML to data, without your messing around under the hood. For most developers who try to get into XML without spending months doing it, data binding is just the answer you are looking for.
This book covers data binding from front to back, giving you the ins and outs of what may turn out to be the API that makes XML accessible to even the newest programmers. You’ll learn how to perform basic conversions from Java to XML, all the way to using various frameworks for advanced transformations and mappings. It’s all in this (nicely compact) book, without lots of wasted words and frilly examples. If you want to use data binding, this book is for you. If you don’t, well, put it down and go pick up about ten other books so you can manipulate XML some other way. I think the choice is obvious; so get started!
I begin this book with a brief explanation of what data binding is and what other APIs are in the XML field. From there, I provide an extensive look at Sun’s JAXB, that company’s data binding framework. You’ll learn every option and every switch to use this package. Then, to round out your data binding skills, I examine three other popular open source data binding frameworks, each with its strengths and weaknesses.
This chapter is a basic introduction to XML data binding and to the general Java and XML landscape that currently exists. It details the basic Java and XML APIs available and organizes them by the general usage situations to which they are applied. It also details setting up for the rest of the book.
This chapter is the (only) theoretical chapter in the book. It details the difference between data-driven and business-driven APIs and explains when one model is preferable over the other. It then explains how constraint modeling fits into the data binding picture and how data binding makes XML invisible to the application developer.
This chapter is the first detailed introduction to data binding. It explains the process of taking a set of XML constraints and converting those constraints into a set of Java source files. It details how this is accomplished using the JAXB API and then explains how the resultant source files can be compiled and used in a Java application.
This chapter continues the nuts-and-bolts approach to teaching data binding. It covers the process of converting XML documents to Java objects and how the data should be modeled for correct conversion. It also details the use of resultant Java objects.
This chapter details the conversion from Java objects to XML documents. It explains the overall process flow, as well as the implementation-level steps involved in marshalling. It also covers creating data binding process loops, ensuring that data binding can occur repeatedly in applications.
This chapter focuses on binding schemas and how they can customize transformation from XML to Java. Every option in binding schemas is examined and discussed both technically and practically.
This chapter begins an exploration of alternate data binding packages with Zeus. The coverage is based on the explored JAXB concepts and compares Zeus operation to the techniques already discussed in previous chapters. Particular attention is paid to Zeus enhancements that are not in the JAXB API.
This chapter continues exploration of alternate data binding implementations by looking at Castor. This open source alternative was the first major data binding implementation available and offers many features not present in JAXB. These features, as well as process variations, are all covered in this chapter.
Quick is another open source data binding API, and this chapter details its ins and outs. You’ll see that Quick offers ideas and processes that are entirely different from most data binding frameworks and you’ll learn how those differences can be put to work in your applications.
This chapter looks at the future of data binding. It covers the final version of JAXB, as well as expectations for the next JAXB release. It also covers how alternate data binding implementations are likely to change with a JAXB 1.0 release and looks at JAXB in light of the J2EE platform.
This appendix details all the options for the tools provided by various data binding APIs. It can be used as a quick reference for each chapter and for your own programming projects.
This appendix details several source files used by the examples in the Quick chapter.