The first step in getting ready for class generation, as you can see from Figure 3-1, is getting a set of constraints ready to generate classes from. As this isn’t a book on writing XML (and there are plenty of good ones on the subject already), I’m not going to spend time describing how to formulate constraints.
I’ll assume that you’re capable of figuring out how you want your data represented and then using DTDs or schemas or your constraint model of choice to describe that data. I do want to touch on a few points relevant to data binding, and JAXB specifically, though, and then provide several DTDs for working through the examples.
First, as I’ve mentioned several times, JAXB currently supports only DTDs. From what I can gather from the specification, newsgroups, and mailing lists, this is the plan all the way through the 1.0 final version of the specification and framework. There is a lot of momentum to follow up this release with a “version.next” that does support XML Schema, though. JAXB does support all the features of DTDs, so you should be able to use any DTDs you’ve already developed for your data binding needs.
Example 3-1. Movie database DTD
<!ELEMENT movies (movie+)> <!ATTLIST movies version CDATA #REQUIRED > <!ELEMENT movie (title, cast, ...