Java - XML Binding - Pattern to be used

Hi All,

I have a obj (obj1,obj2,obj3) etc.. is the internal structure of the Object.I am passing the object to the XMLBeans classes created to populate data from the object and create the xml.

Now the implementation is done in a single file where the document instance is created and the respective interface types created by the bean and finally populate the beans with the respective values from the object.

I feel this is a clumsy way of doing it , can anybody suggest how do we bifurcate the responsibility of reading the Object as one task and then get the appropriate interface bean type and then glue them together with the value.

[662 byte] By [sane_techiea] at [2007-10-2 10:56:35]
# 1

Assuming you can enforce your own naming conventions on the XSL schema that will create the XMLBeans, then reflection seems an obvious choice. Serializing via this route should be straightforward, the names in the target object should match the method names in the XMLBean (with perhaps a case translation to map Java method versus field naming conventions). Deserialization is a little tricker, but not too much. You just need to create a default object (empty constructor) and then call setAccessible(true) on each Field you want to bind to the XML input.

Or, you can skip the above and use JAXB. :^)

- Saish

Saisha at 2007-7-13 3:21:48 > top of Java-index,Other Topics,Patterns & OO Design...