Marshalling Your Data

One important topic to discuss is the concept of marshaling, and its twin, unmarshalling These terms describe the change from an in-memory structure of objects to an XML data stream, and back, as shown here:


Figure 4: Marshalling and unmarshalling XML data

When the in-memory data structure is written out as XML, that process is known as marshaling It's like lining up the troops for review. You dress up the troops (data) in their medals (XML markup) and put them out on the parade ground (the file system) for review by others (editing, browsing). When they come off the parade ground (into memory), you put away the medals (tags) and have only the data. That's known as unmarshalling.

When the schema is compiled, all the code required to marshal and unmarshal the data is generated. To create the data structure, then, the programmer need only invoke the static "unmarshal" command defined in the class. Similarly, to write out the whole data structure, or part of it, the programmer needs only point to the output file and tell the object to marshal itself.