'Cannot find the declaration of element -SOAP
Document document = null; DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); document = parser.paser(xmlFilePath);
ParseException SaxException IOException
returned document without exception.
Using xmllist "schema" xml validated
SchemaFactory schema = SchemaFactory.newInstance(XMLConstanst.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(new Source []{new StreamSource(xsd1), new StreamSource(xsd2), new StreamSource(xsd3), newStreamSource(xsd4)})
Validator validator = schema.newValidator(); validator.setErrorHandler(new CustomHandler);
validator.validate(new DOMSource(document);
SAXParseException cvc-elt.1 Cannot find the declaration of element "ElementinQuestion"
String node = document.getNodeName();
node = #document
When the following is added the node returns the same exception above
String node = document.getFirstChildNode().getNodeName();
node = "ElementinQuestion"
xsd
<s: element name = "ElementinQuestion" type = elementinquestion:ElementinQuestion"
What else can I check?
Solution 1:[1]
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);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve |
