在做了GIT rebase之后,我开始收到这个例外:
by:org.xml.sax.SAXParseException:“元素的内容必须包含格式良好的字符数据或标记”
Java代码只是尝试将xml文件解组为jaxb对象。像这样:
...
FGIXmlValidationEventCollector collector = new FGIXmlValidationEventCollector();
Unmarshaller unmarshaller = null;
try {
unmarshaller = context.createUnmarshaller();
unmarshaller.setSchema(getSchema());
unmarshaller.setEventHandler(collector);
} catch (JAXBException e) {
throw new FGIXmlException(e);
} catch (SAXException e) {
throw new FGIXmlException(e);
}
public Schema getSchema() throws SAXException {
SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
URL schemaLocation = getClass().getResource("/config/xsd/fgi.xsd");
**return schemaFactory.newSchema(schemaLocation); // exception is thrown here!!!**
}
我很无能为力。没有代码更改可以证明这一点。这段代码已经工作了很多年。我不知道为什么在经历了一些微不足道的git pull / rebase之后,我最终得到了这种行为。顺便说一下,我想要解组的XML文件没有任何明显的问题。这是一个UFT-8 xml文件。我甚至尝试过更改编码但无济于事。
有什么想法吗?
谢谢