如何在扩展类中使用JAXB @XmlValue?

时间:2015-10-04 07:48:40

标签: java xml inheritance jaxb

我有这样的XML:

*<link:label xlink:type="resource" 
 xlink:label="label" 
 xlink:role="http://www.xbrl.org/2003/role/label" 
 xlink:title="title" xml:lang="en" id="label_id">
 Firm's symbol</link:label>*

我的域名中有三个班级:

1:标签

@XmlRootElement(name = "label",namespace = "http://www.xbrl.org/2003/linkbase")

public class Label extends Resource {

@Column(name = "value")
private String value;

public Label() {
}

@XmlValue
public String getValue() {
    return value;
}

2:资源

@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Resource extends ExtendedLinkElement {


private String id_resource;
private String label;
private String role;
private String title;
private String type;
public Resource() {
}
}
@XmlAttribute( name = "label",namespace = "http://www.w3.org/1999/xlink")
public String getLabel() {
    return label;
}
@XmlAttribute( name = "role",namespace = "http://www.w3.org/1999/xlink")
public String getRole() {
    return role;
}

@XmlAttribute( name = "title",namespace = "http://www.w3.org/1999/xlink")
public String getTitle() {
    return title;
}
@XmlAttribute( name = "type",namespace = "http://www.w3.org/1999/xlink")
public String getType() {
    return type;
}

3:ExtendedLinkElement

@Inheritance(strategy = InheritanceType.JOINED)
public abstract class ExtendedLinkElement  {

@Id
@Column(name = "ID")
private Long id;

public ExtendedLinkElement() {

}

但是在xml文件的解组中我得到了这个错误: 属性或字段值无法使用XmlValue进行注释,因为它是另一个XML绑定类的子类

我使用moxy for jaxb RI,当我使用@xmlMixed时,在我的属性中返回null。

0 个答案:

没有答案