1
在MOXy中使用Binder實現時遇到問題。
下面是輸入XML文檔(input.xml中)使用@XmlAnyElement註釋時JAXB MOXy Binder問題
<?xml version="1.0" encoding="utf-8"?>
<root>
<unmapped />
</root>
而現在,這裏是用來解組XML到活頁夾的實例,然後更新從相應的Java對象的XML的源代碼:
JAXBContext context = JAXBContext.newInstance(Input.class);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
Document document = builder.parse(new File("input.xml"));
Binder<Node> binder = context.createBinder(Node.class);
Input input = (Input) binder.unmarshal(document);
binder.updateXML(input);
在結束時,將非常簡單的輸入類文件:
@XmlRootElement(name = "root")
public class Input {
@XmlAnyElement
protected Object[] elements;
}
當調用updateXML()
方法,下面的拋出異常:
java.lang.NullPointerException
at org.eclipse.persistence.internal.jaxb.DomHandlerConverter.convertObjectValueToDataValue(DomHandlerConverter.java:97)
感謝您的支持。 – mathiaslebout
該修復程序工作正常(用2.5.0流測試)。非常感謝。 – mathiaslebout