Results 1 to 1 of 1
  1. #1
    kmera is offline Member
    Join Date
    Aug 2014
    Rep Power

    Default Jaxb inheritance

    I am trying to marshal / unmarshal xml and json using jaxb and jackson.
    I am having issues with parent / child inheritance with my xml annotations.
    Basically I want the parent class to wrap the child class, and then the child class will have the "type" decleration.
    "testResult" is the parent class, "testResultQuantitative" is one of the children.

    My Json object is marshaled appropriately: (sorry if format is incorrect)
    Java Code:
    The Xml object does not have the parent wrapper:
    Java Code:
    Here are the associated classes:
    TestResult class
    Java Code:
        @JsonSubTypes.Type(value=TestResultQualitative.class, name="testResultQualitative"),
        @JsonSubTypes.Type(value=TestResultQuantitative.class, name="testResultQuantitative")
    @XmlSeeAlso({TestResultQualitative.class, TestResultQuantitative.class})
    public abstract class TestResult {
    TestResultQuantitative class
    Java Code:
    public class TestResultQuantitative extends TestResult {
    To be more clear on the formatting I am looking for:
    Java Code:
    <testResult xsi:type="testResultQuantitative">
    Last edited by kmera; 08-25-2014 at 07:24 PM.

Similar Threads

  1. Jaxb
    By unknownuser in forum Advanced Java
    Replies: 2
    Last Post: 08-14-2013, 11:55 AM
  2. JAXB type help!!!
    By mafyou in forum XML
    Replies: 1
    Last Post: 04-23-2012, 11:53 AM
  3. JAXB Unmarshalling
    By milan.nosal in forum XML
    Replies: 0
    Last Post: 09-01-2010, 03:15 PM
  4. Jaxb
    By Paul Richards in forum XML
    Replies: 1
    Last Post: 08-03-2009, 10:56 PM
  5. JAXB Unmarshalling
    By prateek in forum XML
    Replies: 0
    Last Post: 07-10-2008, 07:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts