SAXReader read() 方法在从 dom4j 1.6.1 更新到 2.0.3 时抛出 org.dom4j.DocumentException

问题描述 投票:0回答:0

我们将 dom4j 从 1.6.1 更新到 2.0.3,现在我们在解析 xml 文件时遇到以下异常

我们的代码是

SAXParser parser = factory.newSAXParser();
final SAXReader reader = new SAXReader(parser.getXMLReader());
reader.setValidation(false);
final InputSource source = new InputSource(new ByteArrayInputStream(xmlData));
final Document document = reader.read(source);

错误是

Error parsing xml data; nested exception is org.dom4j.DocumentException: Error on line 3 of document  : cvc-elt.1: Cannot find the declaration of element 'users'. org.springframework.dao.DataIntegrityViolationException: Error parsing xml data; nested exception is org.dom4j.DocumentException: Error on line 3 of document  : cvc-elt.1: Cannot find the declaration of element 'users'.
    
Caused by: org.dom4j.DocumentException: Error on line 3 of document  : cvc-elt.1: Cannot find the declaration of element 'users'.
    at org.dom4j.io.SAXReader.read(SAXReader.java:511)
    

我们推荐 文字 并按组尝试 saxParserFactory.setFeature("http://xml.org/sax/features/external-general-entities", true); saxParserFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", true);

我们还尝试显式设置所有依赖项,如 Jaxen、xsdlib 但没有任何帮助,

dom4j
© www.soinside.com 2019 - 2024. All rights reserved.