JAXB添加额外的静态根元素 [英] JAXB add additional static root element

查看:194
本文介绍了JAXB添加额外的静态根元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下POJO:

@XmlRootElement(name="SessionStartInput")
public class SessionStartInput {

    @XmlElement(name = "Header", required = true, nillable = true)
    protected SessionStartInputHeader header;
    @XmlElement(name = "Parameters", required = true, nillable = true)
    protected SessionStartInputParameters parameters;
  ...
}

生成:

<SessionStartInput>
<Header></Header>
<Parameters></Parameters>
</SessionStartInput>

我要生成:

  <SessionStartInput>
    <Input>
      <Header></Header>
      <Parameters></Parameters>
    <Input>
</SessionStartInput>

添加一个额外的输入包装,是有某种形式的XML注释可以做到这一点?我检查 @XmlElements 但这将意味着改变POJO的结构。有什么解决方法呢?

Adding an additional Input wrapper, is there some sort XML annotation that can do this? I've checked @XmlElements but this would mean altering the structure of the POJO. is there any workaround for this?

推荐答案

最终改变的POJO以适应XML数据的变化

Ended up changing the POJO to accommodate the change in xml data

这篇关于JAXB添加额外的静态根元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆