@Override
    public InputSource resolveEntity(String publicId, String systemId)
            throws SAXException, IOException {
        String path = pathMap.get(systemId);
        if(path != null) {
            File f = new File(path);
            if (f.exists()) {
                TypedInputSource is = new TypedInputSource();
                is.setByteStream(new FileInputStream(f));
                is.setSystemId(systemId);
                is.setPublicId(publicId);
                if(systemId.endsWith(".rnc")) {
                    is.setType("application/relax-ng-compact-syntax");
                    if(!allowRnc) {
                        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");                    
                }
                return is;
            }            
        }
        return delegate.resolveEntity(publicId, systemId);
    }
@see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
     java.lang.String)
src/nu/validator/xml/LocalCacheEntityResolver.java