XmlIDREF is not working

我怕爱的太早我们不能终老 提交于 2020-01-16 00:51:13

问题


using JAXB 2.2.5b, and having

@XmlSeeAlso({BeanView.class, ViewField.class, ViewPanel.class, ViewTab.class, ElementRef.class})
@XmlRootElement
public abstract class ViewElement {
   @XmlID
   @XmlAttribute
   public String getId() {      
        return id;
   }
}
@XmlRootElement(name="ref")
public class ElementRef extends ViewElement{        
    private ViewElement target;
    @XmlElement
    @XmlIDREF
    public ViewElement getTarget() {
        return target;
    }   
    public void setTarget(ViewElement target) {
        this.target = target;
    }
}

Many class extends the abstract ViewElement

@XmlRootElement
public class ViewField extends ViewElement{
}
@XmlRootElement
public class ViewPanel extends ViewElement{
}

in the XML the ElementRef target element is repeated instead of keeping only the id ref

<ref id="mvmCredit" >
    <target xsi:type="viewField" valueExpr="" row="0" ... all ViewField attributes >
    </target>
</ref>

and during the unmarchaling of the XML model the target is null (the restoration failed)


回答1:


An upgrade to JAXB 2.2.7 fix the problem



来源:https://stackoverflow.com/questions/24823594/xmlidref-is-not-working

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