O'Reilly logo

Java & XML Data Binding by Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Binding Schemas

Up to this point, I’ve focused on the simplest cases in data binding. That doesn’t necessarily mean that the DTDs and XML documents we’ve dealt with are simple, but that the transformation and class generation processes are. In other words, the name of an element becomes the name of the Java class, the Java types are defaults (String variables), and no interfaces, inheritance, or other advanced options are used. Discussion of marshalling, unmarshalling, and class generation was easy without these complex options.

Now that you have those basics in place, it’s time to introduce these more complex options into the equation. Usually, the simple transformations will not serve your purposes; the names used and the simple string types are not sufficient for effective Java programming. In this chapter, I introduce the numerous options that binding schemas provide and explain how each option affects the classes generated from your DTDs using JAXB.

Tip

The format of this chapter differs from what you have seen so far. Many of the first several examples used the generated classes from JAXB. Trying to write even a trivial example for each variation of a binding schema would be impossible and waste a lot of your time. This chapter provides details about binding schema options and showing the resulting changes in your generated classes. I leave it to you to use these modified classes in your programs or in the examples from the previous chapters. Use this chapter as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required