我有一个例外:unexpected element (uri:"", local:"Fid1Instruments"). Expected elements are <{http://proba.org/proba}Fid1Instruments>
我有package-info.java文件:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://proba.org/proba")
package com.enum1.instruments;在主修课上,我这样做:
JAXBContext jx = JAXBContext.newInstance(Fid1Instruments.class);
Unmarshaller u = jx.createUnmarshaller();
JAXBElement<?> ue= (JAXBElement<?>) u.unmarshal(new File("ex1.xml"));在生成的java文件中:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"fid1Bond"
})
@XmlRootElement(name = "Fid1Instruments", namespace="http://proba.org/proba")我读过同样的问题的答案,但它们不起作用。
发布于 2013-11-19 14:00:32
基于映射,JAXB期望您的文档如下所示,其中元素Fid1Instruments由命名空间http://proba.org/proba限定。
<ns:Fid1Instruments xmlns:ns="http://proba.org/proba">
...
</ns:Fid1Instruments>你现在正在传递它:
<Fid1Instruments>
...
</Fid1Instruments>获取更多信息
https://stackoverflow.com/questions/20073125
复制相似问题