use of org.exist.util.URIResolverHierarchy in project exist by eXist-db.
the class XsltURIResolverHelper method getXsltURIResolver.
/**
* Get a URI Resolver for XSLT Modules.
*
* @param brokerPool the database
* @param defaultResolver the default fallback resolver, or null
* @param base the URI base, or null
* @param avoidSelf true to avoid nesting {@link URIResolverHierarchy}
*
* @return the URIResolver, or null if there is no resolver
*/
@Nullable
public static URIResolver getXsltURIResolver(final BrokerPool brokerPool, @Nullable final URIResolver defaultResolver, @Nullable final String base, final boolean avoidSelf) {
final List<URIResolver> resolvers = new ArrayList<>();
if (base != null) {
// database resolver
resolvers.add(new EXistURISchemeURIResolver(new EXistURIResolver(brokerPool, base)));
}
// EXpath Pkg resolver
brokerPool.getExpathRepo().map(repo -> resolvers.add(new PkgXsltModuleURIResolver(repo)));
// default resolver
if (defaultResolver != null) {
if (avoidSelf) {
if (!defaultResolver.getClass().getName().equals(URIResolverHierarchy.class.getName())) {
resolvers.add(defaultResolver);
}
} else {
resolvers.add(defaultResolver);
}
}
if (resolvers.size() > 0) {
return new URIResolverHierarchy(resolvers);
} else {
return null;
}
}
Aggregations