org.apache.xml.resolver.CatalogManager Java Examples

The following examples show how to use org.apache.xml.resolver.CatalogManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OASISCatalogManager.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static EntityResolver getResolver() {
    try {
        CatalogManager catalogManager = new CatalogManager();
        if (DEBUG_LEVEL != null) {
            catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL));
        }
        catalogManager.setUseStaticCatalog(false);
        catalogManager.setIgnoreMissingProperties(true);
        return new CatalogResolver(catalogManager) {
            public String getResolvedEntity(String publicId, String systemId) {
                String s = super.getResolvedEntity(publicId, systemId);
                if (s != null && s.startsWith("classpath:")) {
                    try {
                        URIResolver r = new URIResolver(s);
                        if (r.isResolved()) {
                            r.getInputStream().close();
                            return r.getURL().toExternalForm();
                        }
                    } catch (IOException e) {
                        //ignore
                    }
                }
                return s;
            }
        };
    } catch (Throwable t) {
        //ignore
    }
    return null;
}