Quantcast
Channel: JAXB 2.x: How to unmarshal an XML without knowing the target class? - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by basZero for JAXB 2.x: How to unmarshal an XML without knowing the target class?

$
0
0

There is a similar question here.

Is it possible, to just unmarshall by providing Person.class and the unmarshaller finds out itself, whether it has to unmarshall to ReceiverPerson.class or SenderPerson.class?

@XmlRootElement(name="person")
public class ReceiverPerson extends Person {
  // receiver specific code
}

@XmlRootElement(name="person")
public class SenderPerson extends Person {
  // sender specific code (if any)
}

// note: no @XmlRootElement here
public class Person {
  // data model + jaxb annotations here
}

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>