1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

fix file-access in AlgorithmConfigXmlReader

This commit is contained in:
Stefan Schroeder 2013-06-06 11:50:05 +02:00
parent 4ea045348b
commit aa76b68685
2 changed files with 3 additions and 33 deletions

View file

@ -90,38 +90,8 @@ public class AlgorithmConfigXmlReader {
public void read(String filename){ public void read(String filename){
log.info("read algorithm-config from file " + filename); log.info("read algorithm-config from file " + filename);
algorithmConfig.getXMLConfiguration().setFileName(filename); URL url = Resource.getAsURL(filename);
algorithmConfig.getXMLConfiguration().setAttributeSplittingDisabled(true); read(url);
algorithmConfig.getXMLConfiguration().setDelimiterParsingDisabled(true);
if(schemaValidation){
final URL resource = Resource.getAsURL("algorithm_schema.xsd");
if(resource != null) {
EntityResolver resolver = new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
{
InputSource is = new InputSource(resource.getFile());
return is;
}
}
};
algorithmConfig.getXMLConfiguration().setEntityResolver(resolver);
algorithmConfig.getXMLConfiguration().setSchemaValidation(true);
log.info("validating " + filename + " with xsd-schema");
}
else{
log.warn("cannot find schema-xsd file (algorithm_xml_schema.xsd). try to read xml without xml-file-validation.");
}
}
try {
algorithmConfig.getXMLConfiguration().load();
} catch (ConfigurationException e) {
log.error(e);
e.printStackTrace();
System.exit(1);
}
} }
} }

View file

@ -43,7 +43,7 @@ public class Resource {
*/ */
public final static URL getAsURL(final String filename) { public final static URL getAsURL(final String filename) {
// look for the file locally // look for the file locally
File file = new File("/" + filename); File file = new File(filename);
if (file.exists()) { if (file.exists()) {
try { try {
return file.toURI().toURL(); return file.toURI().toURL();