Is there an “XML Schema type to Java data type” binding for java.lang.Object in JAXB?
Simple Example
<Channels>
<EChannel>
<Number>1</Number>
<Format>0</Format>
<VarNumber>11</VarNumber>
<Name>First Channel</Name>
<ChannelHandler></ChannelHandler>
</EChannel>
<EChannel>
<Number>2</Number>
<Format>0</Format>
<VarNumber>22</VarNumber>
<Name>Second Channel</Name>
<ChannelHandler></ChannelHandler>
</EChannel>
</Channels>
Basically I’ll first unmarshall the xml tree into an arraylist of Pojos (List)
And then in runtime I want to attach a java object to the ChannelHandler property.
I dont want to do anything manually inside the EChannel POJO, since I want these to be generated automatically using xjc
Thanks
Using
@XmlAnyElement(lax=true)on a property of typeObjectshould give you the behavior you are looking for.When starting from an XML schema, a schema structure like the following will result in this annotation.
Full XML Schema
For More Information