LOG.warn(String.format("SKIP - The SQL dialect file '%s' does not exist", this.xmlFile));
return (false);
}
// COPIED FROM VoltDB's VoltCompiler.java
DialectsType dialects = null;
try {
JAXBContext jc = JAXBContext.newInstance(this.xmlContext);
// This schema shot the sheriff.
SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(this.xmlSchemaURL);
Unmarshaller unmarshaller = jc.createUnmarshaller();
// But did not shoot unmarshaller!
unmarshaller.setSchema(schema);
@SuppressWarnings("unchecked")
JAXBElement<DialectsType> result = (JAXBElement<DialectsType>) unmarshaller.unmarshal(this.xmlFile);
dialects = result.getValue();
}
catch (JAXBException ex) {
// Convert some linked exceptions to more friendly errors.
if (ex.getLinkedException() instanceof org.xml.sax.SAXParseException) {
throw new RuntimeException(String.format("Error schema validating %s - %s", xmlFile, ex.getLinkedException().getMessage()), ex);
}
throw new RuntimeException(ex);
}
catch (SAXException ex) {
throw new RuntimeException(String.format("Error schema validating %s - %s", xmlFile, ex.getMessage()), ex);
}
if (LOG.isDebugEnabled())
LOG.debug(String.format("Loading the SQL dialect file '%s' for %s",
this.xmlFile.getName(), this.dbType));
for (DialectType dialect : dialects.getDialect()) {
assert(this.dbType != null);
assert(dialect != null);
if (dialect.getType().equalsIgnoreCase(this.dbType.name()) == false)
continue;