private InputSource tryResolveEntity(String systemId, Function<String, InputStream> resourceLocator) throws IOException { URL url = new URL(systemId); if (!"file".equals(url.getProtocol())) { return emptyResource(); } File file = new File(url.getFile()); if (file.exists()) { return new InputSource(new FileInputStream(file)); } if (resourceLocator == null) { return emptyResource(); } InputStream stream = resourceLocator.apply(file.getName()); if (stream != null) { return new InputSource(stream); } return emptyResource(); }