public class Root{
private
java.util.ArrayList _messageList; // holds Message objects with appropriate
getters/setters
}
public abstract class Message;
public class Message1 extends Message;
public class Message2
extends Message;
An XML instance can look like ...
<Root>
<Message1 IDA="1"/>
<Message2 IDB="2"/>
</Root>
In the RootDescriptor, I can add an XMLFieldDescriptorImpl for each of the concrete Messages (i.e. Message1 & Message2) that details their XML name and base class. I then can add an XMLFieldHandler to each that creates the correct object and gets/sets it into the messageList. As expected, this works fine for unmarshalling.
When I marshall the class (to XML), it appears that each FieldDescriptor is invoked so that I get the following XML out.
<Root>
<Message1 IDA="1"/>
<Message1 IDB="2" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xsi:type="java:message2"/>
<Message2 IDA="1" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xsi:type="java:message1"/>
<Message2 IDB="2"/>
</Root>
I tried creating my own FieldDescriptor, etc.. but didn't have any luck. Is there a way to map one attribute to many xml field names and objects for both marshalling and unmarshalling?
Thanks in
advance,
Jody Terrill
Hewlett-Packard
