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

查看:36
本文介绍了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>

添加一个额外的 Input 包装器,是否有某种 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天全站免登陆