私は次のクラスを持っています
@XmlRootElement(name = "entity")
public class Entity {
@XmlElementRef
protected AtomLink first;
@XmlElementRef
protected AtomLink second;
public Entity() {
}
public Entity(AtomLink first, AtomLink second) {
this.first = first;
this.second = second;
}
}
これは私のテストコードです:
Entity entity = new Entity(new AtomLink("first", "http://test/first"), new AtomLink("second", "http://test/second"));
JAXBContext context;
try {
context = JAXBContextFactory.createContext(new Class[] { Entity.class } , null);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(entity, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
最初のリンクが欠落しているため、MOXyの出力は正しくありません。
<entity xmlns:atom="http://www.w3.org/2005/Atom">
<atom:link rel="second" href="http://test/second"/>
</entity>
JavaJAXBRIでの出力は正しいです。
<entity xmlns:atom="http://www.w3.org/2005/Atom">
<atom:link rel="first" href="http://test/first"/>
<atom:link rel="second" href="http://test/second"/>
</entity>
MOXyのバグですか?