JAXB Unmarshalling X,X *

时间:2016-04-16 11:04:15

标签: jaxb unmarshalling jaxb2

我遇到了从XML解组此类的问题。

问题是由名为' propertyset"的两个元素引起的。实际发生的是第一个属性集正确解组然后立即被第二个属性集覆盖,如果它存在...

是否有可用于成功解组此XML的注释/配置?

/**
 * <p>Java class for a element declaration.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * <element name="a">
 *   <complexType>
 *     <complexContent>
 *       <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *         <sequence>
 *           <element ref="propertyset"/>
 *           <element ref="propertyset" minOccurs="0"/>
 *         </sequence>
 *         <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
 *         <attribute name="description" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       </restriction>
 *     </complexContent>
 *   </complexType>
 * </element>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "propertyset",
    "systempropertyset"
}, factoryMethod = "createAEx", factoryClass = ObjectFactoryEx.class)
@XmlRootElement(name = "a")
public class A
{
    @XmlElement(required = true, type = B.class)
    protected B propertyset;
    @XmlElement(name = "propertyset", type = B.class)
    protected B systempropertyset;
...
}

1 个答案:

答案 0 :(得分:0)

我现在已经开始使用Moxy了。有了这个,我可以使用@XmlPath(&#34; propertyset [1]&#34;)和@XmlPath(&#34; propertyset [2]&#34;)

这就像宣传的一样!