I'm trying to parse a file (I am sure the file is syntactically correct, it was generated) using this schema. The file begins as such:
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://ift.tt/1mNZwKX" version="1.4.1">
...
This is my code to load it:
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setValidating(true);
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL schemaURL = new URL("http://ift.tt/1IFvl06");
Schema schema = sf.newSchema(schemaURL);
dbFactory.setSchema(schema);
DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
docBuilder.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException e) throws SAXException {
System.err.print("Warning: ");
e.printStackTrace();
}
@Override
public void fatalError(SAXParseException e) throws SAXException {
System.err.print("FATAL ERROR: ");
e.printStackTrace();
}
@Override
public void error(SAXParseException e) throws SAXException {
System.err.print("Error: ");
e.printStackTrace();
}
});
Document doc = docBuilder.parse(file); //Line throwing error
Parsing it as such throws the following error:
Error: org.xml.sax.SAXParseException; systemId: file:/home/ukraine/Desktop/Code/Java/Eclipse/3D%20Previewer/models/cube.dae; lineNumber: 2; columnNumber: 79; Element type "COLLADA" must be declared.
at ...
Error: org.xml.sax.SAXParseException; systemId: file:/home/.../cube.dae; lineNumber: 2; columnNumber: 79; cvc-elt.1: Cannot find the declaration of element 'COLLADA'.
at ...
Error: org.xml.sax.SAXParseException; systemId: file:/home/.../cube.dae; lineNumber: 3; columnNumber: 9; Element type "asset" must be declared.
at ...
Even though I'm fairly sure that this syntax is correct, I tried adding <!DOCTYPE COLLADA>
as per the recommendation of this question, which threw an exception saying:
FATAL ERROR: org.xml.sax.SAXParseException; systemId: file:/home/.../cube.dae; lineNumber: 2; columnNumber: 6; The processing instruction target matching "[xX][mM][lL]" is not allowed.
Aucun commentaire:
Enregistrer un commentaire