org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element
Hello,
I'm pretty new in Java.
I validate my xml againt xsd file, but this error org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element occurred.
Code :
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setAttribute(SCHEMA_LANGUAGE_ATTRIBUTE, XSD_SCHEMA_LANGUAGE);
factory.setIgnoringComments(true);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId){
return new InputSource(xsd);
}
});
builder.setErrorHandler(new ErrorHandler() {
public void error(SAXParseException exception) throws SAXException {
exception.printStackTrace();
}
public void fatalError(SAXParseException exception)
throws SAXException {
exception.printStackTrace();
}
public void warning(SAXParseException exception)
throws SAXException {
exception.printStackTrace();
}
});
builder.parse(xml);
Re: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element
Sorry,
The problem was solved :), some stupid mistakes. :(