_dialog.notify("fatal error: unable to create SAX parser.");
return;
}
SchemaContext schemaContext = new SchemaContextImpl();
SchemaUnmarshaller schemaUnmarshaller = null;
try {
schemaUnmarshaller = new SchemaUnmarshaller(schemaContext);
} catch (XMLException e) {
//--The default constructor cannot throw exception so this should never happen
//--just log the exception
e.printStackTrace();
System.exit(1);
}
Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
parser.setDocumentHandler(handler);
parser.setErrorHandler(handler);
try {
parser.parse(source);
} catch (java.io.IOException ioe) {
_dialog.notify("error reading XML Schema file");
if (_failOnFirstError) {
throw ioe;
}
return;
} catch (org.xml.sax.SAXException sx) {
Exception except = sx.getException();
if (except == null) {
except = sx;
}
if (except instanceof SAXParseException) {
SAXParseException spe = (SAXParseException) except;
_dialog.notify("SAXParseException: " + spe);
_dialog.notify(" - occured at line ");
_dialog.notify(Integer.toString(spe.getLineNumber()));
_dialog.notify(", column ");
_dialog.notify(Integer.toString(spe.getColumnNumber()));
} else {
except.printStackTrace();
}
if (_failOnFirstError) {
String msg = "Source Generator: schema parser threw an Exception";
throw new CastorRuntimeException(msg, sx);
}
return;
}
Schema schema = schemaUnmarshaller.getSchema();
try {
schema.validate();
} catch (ValidationException vx) {
throw new NestedIOException(vx);