开发者

JAXB Customizations and List<Object>

开发者 https://www.devze.com 2022-12-19 14:28 出处:网络
I used JAXB to create some classes开发者_StackOverflow社区 from an XSD. The result was not quite what I expected

I used JAXB to create some classes开发者_StackOverflow社区 from an XSD. The result was not quite what I expected and most probably it can be customized.

It created a generic list instead of 3 different lists. Can this be corrected somehow?

@XmlElements({
    @XmlElement(name = "M1", type = M1_Type.class),
    @XmlElement(name = "M2", type = M2_Type.class),
    @XmlElement(name = "M3", type = M3_Type.class)
})

protected List<Object> m1Orm2OrM3;

Is there a customization to fix this?


You probably have a repeatable choice, something like

<choice maxOccurs="unbounded">
  <element name="M1" .../>
  <element name="M2" .../>
  <element name="M3" .../>
</choice>

The answer is negative, there's no such customization. "Three list" is actually a very different data structure.

0

精彩评论

暂无评论...
验证码 换一张
取 消