JAXB doesn't support a 'code-to-interfaces' approach when it comes to id
references (i.e. @XmlIDREF), because a property on a class annotated with
@XmlIDREF and @XmlAttribute can only refer to a class, but not an interface.
The following does not work:
@XmlIDREF
@XmlAttribute
public MyInterface getMyInterface() { //this is an interface
return myInterface;
}
What's needed is an equivalent to @XmlElementRef (e.g. @XmlAttributeRef) for
attributes, that lets you specify the allowable classes of the interface of the
property.
Perhaps some kind of autodetection could be possible, by looking up the single
element in the XML file with an ID specified by the above property, and seeing
if it's assignable to a type of 'MyInterface'.
JAXB doesn't support a 'code-to-interfaces' approach when it comes to id references (i.e. @XmlIDREF), because a property on a class annotated with @XmlIDREF and @XmlAttribute can only refer to a class, but not an interface. The following does not work:
@XmlIDREF @XmlAttribute public MyInterface getMyInterface() { //this is an interface return myInterface; }
What's needed is an equivalent to @XmlElementRef (e.g. @XmlAttributeRef) for attributes, that lets you specify the allowable classes of the interface of the property.
Perhaps some kind of autodetection could be possible, by looking up the single element in the XML file with an ID specified by the above property, and seeing if it's assignable to a type of 'MyInterface'.
Environment
Operating System: All Platform: All URL: http://forums.java.net/jive/thread.jspa?threadID=33511&tstart=0
Affected Versions
[2.1.4]