gpt4 book ai didi

java - @XmlAnyElement 和 @XmlElementRefs

转载 作者:行者123 更新时间:2023-12-01 04:47:16 25 4
gpt4 key购买 nike

我使用以下带注释的类通过 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 元素和 JAXBElement 的异构列表?

最佳答案

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

关于java - @XmlAnyElement 和 @XmlElementRefs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15618820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com