Diego Macario
Diego Macario

Reputation: 1230

Is possible to make inheritance in this xml using jaxb?

I want to know if is possible to create a abstract class adress to using with job and home tags?

Like in this code

<person>
  <home>
    <adress>
      <street>marte</street>
      <number>200</number>
    </adress>
  </home>
  <job>
    <adress>
      <street>saint loius</street>
      <number>100</number>
    </adress>
  </job>
</person>

If is possible, can someome show me a example code...

Upvotes: 1

Views: 75

Answers (2)

Diego Macario
Diego Macario

Reputation: 1230

My problem was in the interface class...

I didn´t put annotation to map the fields

Upvotes: 0

bdoughan
bdoughan

Reputation: 149047

This can be done by leveraging the @XmlElementRef annotation on a property in which the type is the common super class. Then annotate each subclass with the @XmlRootElement annotation.

Upvotes: 1

Related Questions