提问人:Steve 提问时间:2/22/2022 更新时间:2/22/2022 访问量:44
找不到元素 -SOAP 的声明
Cannot find the declaration of element -SOAP
问:
文档文档 = null; DocumentBuilder 解析器 = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 文档 = parser.paser(xmlFilePath);
ParseException 萨克斯例外 IOException
无一例外地返回文档。
使用 xmllist “schema” xml 验证
SchemaFactory 架构 = SchemaFactory.newInstance(XMLConstanst.W3C_XML_SCHEMA_NS_URI);
架构架构 = schemaFactory.newSchema(new Source []{new StreamSource(xsd1), new StreamSource(xsd2), new StreamSource(xsd3), newStreamSource(xsd4)})
验证者 validator = schema.newValidator(); validator.setErrorHandler(新 CustomHandler);
validator.validate(新 DOMSource(document);
SAXParseException cvc-elt.1 找不到元素“ElementinQuestion”的声明
字符串节点 = document.getNodeName();
节点 = #document
添加以下内容时,节点将返回与上述相同的异常
字符串节点 = document.getFirstChildNode().getNodeName();
节点 = “ElementinQuestion”
XSD的
<s: 元素名称 = “ElementinQuestion” type = elementinquestion:ElementinQuestion”
我还能检查什么?
答:
Added this line and the exception was resolved prior to creating the document
(Found this scrolling down to the bottom
https://stackoverflow.com/questions/39738095/cvc-elt-1-cannot-find-the-declaration-of-element-soapenvelope)
Document document = null;
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
DocumentBuilder parser = DocumentBuilderFactory.newInstance();
document = parser.paser(xmlFilePath);
评论