use of org.apache.xerces.xni.parser.XMLEntityResolver in project intellij-community by JetBrains.
the class ModelGen method loadModel.
public void loadModel(final File... modelRoots) throws Exception {
XMLEntityResolver resolver = new XMLEntityResolver() {
public XMLInputSource resolveEntity(XMLResourceIdentifier xmlResourceIdentifier) throws XNIException, IOException {
String esid = xmlResourceIdentifier.getExpandedSystemId();
if (esid == null) {
final String location = schemaLocationMap.get(xmlResourceIdentifier.getNamespace());
if (location != null) {
esid = location;
} else {
return null;
}
}
// Util.log("resolving "+esid);
File f = null;
for (File root : modelRoots) {
if (root == null)
continue;
if (root.isDirectory()) {
final String fileName = esid.substring(esid.lastIndexOf('/') + 1);
f = new File(root, fileName);
} else {
f = root;
}
}
if (f == null || !f.exists()) {
Util.logerr("unable to resolve: " + esid);
return null;
}
esid = f.getPath();
return new XMLInputSource(null, esid, null);
}
};
ArrayList<File> files = new ArrayList<>();
for (File root : modelRoots) {
ContainerUtil.addAll(files, root.listFiles());
}
loader.loadModel(model, files, resolver);
Util.log(model.jtMap.size() + " java types loaded");
}
Aggregations