List wrappers in JAXB MOXy

安稳与你 提交于 2019-12-22 17:08:34

问题


I am declaring a List object property with:

@XmlRootElement(namespace = "...")
@XmlType
public class Test {
    private List<String> myList;

    @XmlElementWrapper(name = "myListWrapper")
    @XmlElement(name = "myList")
    public List<String> getMyList() {
        return myList;
    }
}

When an instance of this class with an empty list myList is marshalled, MOXy is not generating an empty wrapper MyListWrapper. However, JAXB RI would do it. The generated XML looks like this when using the RI:

<ns2:test xmlns:ns2="...">
    <myListWrapper/>
</ns2:intensionalSet>

Is there a way to obtain the same result with MOXy?


回答1:


Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.

This is a bug in the MOXy implementation of JAXB. You can use the following link to track this issue:

  • https://bugs.eclipse.org/bugs/show_bug.cgi?id=363197


来源:https://stackoverflow.com/questions/8022266/list-wrappers-in-jaxb-moxy

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