【问题标题】:@XmlAnyElement and @XmlElementRefs@XmlAnyElement 和 @XmlElementRefs
【发布时间】:2013-03-25 15:36:32
【问题描述】:

我使用以下带注释的类来解组 MOXy 2.4.0。解组到这个对象就可以了

@XmlElementRefs({
        @XmlElementRef(name = "a", namespace = "http://mynamespace", type = JAXBElement.class),
        @XmlElementRef(name = "b", namespace = "http://mynamespace", type = JAXBElement.class)
})
protected List<JAXBElement<?>> elements;

我现在想在这个列表中允许任意元素,所以我附上了@XmlAnyElement

@XmlAnyElement(lax=true)
@XmlElementRefs({
        @XmlElementRef(name = "a", namespace = "http://mynamespace", type = JAXBElement.class),
        @XmlElementRef(name = "b", namespace = "http://mynamespace", type = JAXBElement.class)
})
protected List<Object> elements;

现在整个列表只包含 com.sun.org.apache.xerces.internal.dom.ElementNSImpl 类型的类,但在这种情况下,lax=true 不应该启用 DOM-Elements 和 JAXBElements 的异构列表吗?

【问题讨论】:

    标签: java xml jaxb eclipselink moxy


    【解决方案1】:

    这是EclipseLink JAXB (MOXy) 中的一个已知问题。您可以使用以下错误来跟踪我们在此问题上的进展:

    【讨论】:

    • 以防万一,如果有同样问题的人偶然发现了这个答案:我目前解决这个问题的方法是将已知和未知元素分成两个属性,所以我根本没有上面提到的问题.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多