XmlIDREF无法正常工作 [英] XmlIDREF is not working

查看:80
本文介绍了XmlIDREF无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JAXB 2.2.5b,并且

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;
    }
}

许多类扩展了抽象ViewElement

Many class extends the abstract ViewElement

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

在XML中重复ElementRef目标元素而不是仅保留id ref

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>

在取消XML模型时,目标为空(恢复失败)

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

推荐答案

升级到JAXB 2.2.7修复问题

An upgrade to JAXB 2.2.7 fix the problem

这篇关于XmlIDREF无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆