如何将 JAXB 类实例编组为其超类
是否可以将 JAXB 带注释的类实例编组为其超类(这也是一个 JAXB 带注释的类)?
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BenamningTYPE", propOrder = {"benamningId"})
@XmlSeeAlso({MoreDetailedBenamningTYPE.class})
public class BenamningTYPE {
...
@XmlElement(name = "BenamningId", required = true)
protected IdentifierTYPE benamningId;
...
}
和扩展类型:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MoreDetailedBenamningTYPE", propOrder = {"modifyDetails"})
public class MoreDetailedBenamningTYPE extends BenamningTYPE {
...
@XmlElement(name = "ModifyDetails", required = true)
protected ModifyDetailsTYPE modifyDetails;
...
}
因此,如果这种情况:
BenamningTYPE b = new MoreDetailedBenamningTYPE();
...
那么我想将实例b编组为BenmaningTYPE以获取
<BenmaningTYPE>
...
</BenmaningTYPE>
And NOT< /strong>:
<MoreDetailedBenamningTYPE>
...
</MoreDetailedBenamningTYPE>
如果可能的话,这个元帅调用会是什么样子?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有检查过,但我会先尝试一下:
如果您要从 XML 模式生成类,请同时检查 可复制插件。您可以将数据从
MoreDetailedBenamningTYPE
实例复制到实例BenmaningTYPE
并对其进行封送。还有更多的可能性,但它们有点复杂。
I haven't checked it, but I'd try first:
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 instanceBenmaningTYPE
and marshal that.There are more possibilities, but they're a bit more complex.