Using type information to select the unmarshalling is more within the standard approaches. I'm committed to adding support for xsi:type to select extensions of a base class, and your type information will fit within the same flow.
- Dennis
[EMAIL PROTECTED] wrote:
We are evaluating using JiBX extensively to map existing Java classes/interfaces to/from XML. We have a few questions that our research has not quite clarified. Maybe answers to these would help others as well. Trying to break our experiments out is a little tough...we tried to research multiple problems at once, so bear with me.
3. If we defined a mapping to a general form of an object and want to extend it without having to write an entirely new unmarshaller, for example, can we "borrow" or extend the functionality of the basic object?
For example.
We understand that we need to write a custom unmarshaller to allow for a call such as Person.addAddress(AddressType, Address)...since it has a two argument setter.
The XML may require things to look this way:
<Person> <Address type="current"> etc. </Address> <Address type="former"> etc. </Address> </Person>
Given that we'd like to treat our objects the way we have them, with type being an attribute of the association between Person and Address, the type attribute in the XML is not really part of the mapping for address. Is there a way to write a mapping in the binding file for Address that ignores the type and then create a structure within the <Person> mapping for <Address> in this particular context and write a custom unmarshaller for the structure that does something like: get the marshaller we'd use for Address that ignores the type and unmarshal...then, look at the type attribute and take the result and using it in our addAddress call on Person.
On a related note, what about having two mappings, one for current addresses and one for former (or maybe US address vs international) and use the type attribute in the XML to determine which mapping (marshaller/unmarshaller) to use?
I realize we are asking long questions as newbies. It's hard to know what approaches to take at such an early stage, but we need to mitigate risk, knowing what we are facing and whether it will fit with what we've already got.
- Christian
------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users
