Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In this chapter, we move from creating Java source files to creating Java objects. In Chapter 3, you built a framework of objects (compiled source files) that represented your constraints. However, this framework isn't particularly useful on its own. Just as a DTD isn't of much use without XML, generated classes aren't any good without instance data. We take the next logical step in this chapter and work on taking an XML document and generating instance data.
I start out by walking you through the process flow for unmarshalling, which is the technical term for converting an XML document into Java object instances. This will give you the same background as the class generation process flow section did and prepare you to work through the rest of the chapter. From there on, it's all working code. First, I discuss creating instance documents, XML documents that conform to your constraint set. Once you've got your data represented in that format, you're ready to convert the XML into Java; the result is instances of the classes you generated in the last chapter. Finally, I cover how to take this data, in Java format, and use it within your application. You'll want to have your XML editor and Java IDE fired up because there is a lot of code in this chapter; let's get to it.