Version 5

    Marshalling and Object Model Provider

     

    contents

     

    Marshalling is based on the same principle as the unmarshalling is. There is still a user having a Java object graph with data to marshal and there is the framework that knows the XML content structure based on DTD or XML schema and knows how and in which order to marshal the data. But if in case of unmarshalling the framework provided chunks of data to the user through the Object Model Factory for assembling (the framework pushed data), in case of marshalling the user will provide data to the framework through the Object Model Provider (the framework will pull data).

     

    To write an XML content, the framework needs to know its structure at a minimum. The structure is defined in XML schema or DTD. Thus, for marshalling, either XML schema or DTD is required. The idea is simple. The framework parses an XML schema or a DTD and navigates from the top most (root) elements down to its children asking an Object Model Provider for XML elements' content.

     

    Like in case of unmarshalling there are two approches to implement object model providers:

    • by implementing ObjectModelProvider interface

    • by implementing GenericObjectModelProvider interface

     

    Also the framework provides an implementation of the GenericObjectModelProvider which has an API to map Java classes and its fields to XML elements.