How to marshal a JAXB class instance as its superclass

后端 未结 1 719
既然无缘
既然无缘 2021-01-15 12:56

Is it possible to marshal a JAXB annotated class instance as its superclass (which is also a JAXB annotated class)?

@XmlAccessorType(XmlAcce         


        
相关标签:
1条回答
  • 2021-01-15 13:33

    I haven't checked it, but I'd try first:

    new JAXBElement(new QName("BenmaningType"),
        BenManingTYPE.class, moreDetailedBenmaningTYPEInstance)
    

    If you're generating classes from an XML Schema, check also the copyable plugin. You could the copy data from an instance of MoreDetailedBenamningTYPE to the instance BenmaningTYPE and marshal that.

    There are more possibilities, but they're a bit more complex.

    0 讨论(0)
提交回复
热议问题