@Override
    public InputSource resolveEntity(String publicId, String systemId)
            throws SAXException, IOException {
        String path = PATH_MAP.get(systemId);
        if (path != null) {
            @SuppressWarnings("resource")
            InputStream stream = LOADER.getResourceAsStream(path);
            if (stream != null) {
                TypedInputSource is = new TypedInputSource();
                if (systemId.endsWith(".rnc")) {
                    is.setType("application/relax-ng-compact-syntax");
                    if (!allowRnc) {
                        stream.close();
                        throw new IOException("Not an XML resource: "
                                + systemId);
                    }
                } else if (systemId.endsWith(".dtd")) {
                    is.setType("application/xml-dtd");
                } else if (systemId.endsWith(".ent")) {
                    is.setType("application/xml-external-parsed-entity");
                } else {
                    is.setType("application/xml");
                }
                is.setByteStream(stream);
                is.setSystemId(systemId);
                is.setPublicId(publicId);
                return is;
            }
        }
        return delegate.resolveEntity(publicId, systemId);
    }
@see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
     java.lang.String)
src/nu/validator/localentities/LocalCacheEntityResolver.java