Is there a way to set up XML serialization in JAXB, just as it is possible with IXmlSerializable in .NET? (i.e. the ability to directly control the serialization of an object using the equivalent of XmlReader / Writer).
I took a look at the XmlAdapter and @XmlJavaTypeAdapter, but they are just used to convert types to and from serializable forms, which is not exactly what I want.
Update. In particular, I would like to configure the deserialization of the root object, which programmatically determines how to deserialize the internal XML (for example, create an unmarshaller jaxb with a specific set of known types).
Update: I found a way to solve the problem, but it is such an unpleasant hack, I will probably go with one of the solutions suggested by the other posters.
source
share