Search in sources :

Example 1 with URIResolverHierarchy

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;
    }
}
Also used : EXistURISchemeURIResolver(org.exist.util.EXistURISchemeURIResolver) URIResolverHierarchy(org.exist.util.URIResolverHierarchy) ArrayList(java.util.ArrayList) PkgXsltModuleURIResolver(org.exist.repo.PkgXsltModuleURIResolver) URIResolver(javax.xml.transform.URIResolver) EXistURISchemeURIResolver(org.exist.util.EXistURISchemeURIResolver) PkgXsltModuleURIResolver(org.exist.repo.PkgXsltModuleURIResolver) Nullable(javax.annotation.Nullable)

Aggregations

ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 URIResolver (javax.xml.transform.URIResolver)1 PkgXsltModuleURIResolver (org.exist.repo.PkgXsltModuleURIResolver)1 EXistURISchemeURIResolver (org.exist.util.EXistURISchemeURIResolver)1 URIResolverHierarchy (org.exist.util.URIResolverHierarchy)1