in taverna-scufl2-ucfpackage/src/main/java/org/apache/taverna/scufl2/ucfpackage/impl/odfdom/pkg/OdfPackage.java [1699:1754]
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException {
// This deactivates the attempt to loadPackage the Math DTD
if (publicId != null
&& publicId
.startsWith("-//OpenOffice.org//DTD Modified W3C MathML"))
return new InputSource(new ByteArrayInputStream(
"<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
if (systemId == null)
return null;
if ((mBaseURI != null) && systemId.startsWith(mBaseURI)) {
if (systemId.equals(mBaseURI))
try {
InputStream in = getInputStream();
InputSource ins = new InputSource(in);
ins.setSystemId(systemId);
return ins;
} catch (Exception e) {
throw new SAXException(e);
}
else if (systemId.length() > mBaseURI.length() + 1)
try (InputStream in = getInputStream(systemId
.substring(mBaseURI.length() + 1))) {
InputSource ins = new InputSource(in);
ins.setSystemId(systemId);
return ins;
} catch (Exception ex) {
mLog.log(Level.SEVERE, null, ex);
}
} else if (systemId.startsWith("resource:/")) {
int i = systemId.indexOf('/');
if ((i > 0) && systemId.length() > i + 1) {
String res = systemId.substring(i + 1);
ClassLoader cl = OdfPackage.class.getClassLoader();
InputStream in = cl.getResourceAsStream(res);
if (in != null) {
InputSource ins = new InputSource(in);
ins.setSystemId(systemId);
return ins;
}
}
} else if (systemId.startsWith("jar:"))
try {
URL url = new URL(systemId);
JarURLConnection jarConn = (JarURLConnection) url
.openConnection();
InputSource ins = new InputSource(jarConn.getInputStream());
ins.setSystemId(systemId);
return ins;
} catch (IOException ex) {
mLog.log(Level.SEVERE, null, ex);
}
return null;
}