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 ...

Get Java & XML Data Binding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.