JAXB add additional static root element

…衆ロ難τιáo~ 提交于 2020-01-06 09:36:26

问题


I have the following 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;
  ...
}

Which generates:

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

I want to generate:

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

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?


回答1:


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



来源:https://stackoverflow.com/questions/29469194/jaxb-add-additional-static-root-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!