Search in sources :

Example 1 with EXistURISchemeURIResolver

use of org.exist.util.EXistURISchemeURIResolver 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)

Example 2 with EXistURISchemeURIResolver

use of org.exist.util.EXistURISchemeURIResolver in project exist by eXist-db.

the class ApacheFopProcessorAdapter method getResourceResolver.

/**
 * Returns a scheme aware ResourceResolver which supports:
 * file://
 * exist:// (which will be translated to xmldb:exist://)
 * http://
 * https://
 *
 * @return The resource resolver
 */
private ResourceResolver getResourceResolver(final DBBroker broker, final String baseUri) {
    final ResourceResolverFactory.SchemeAwareResourceResolverBuilder builder = ResourceResolverFactory.createSchemeAwareResourceResolverBuilder(ResourceResolverFactory.createDefaultResourceResolver());
    final URIResolverAdapter uriResolver = new URIResolverAdapter(new EXistURISchemeURIResolver(new EXistURIResolver(broker.getBrokerPool(), baseUri)));
    builder.registerResourceResolverForScheme("exist", uriResolver);
    builder.registerResourceResolverForScheme("http", uriResolver);
    builder.registerResourceResolverForScheme("https", uriResolver);
    return builder.build();
}
Also used : URIResolverAdapter(org.apache.xmlgraphics.io.URIResolverAdapter) EXistURIResolver(org.exist.xslt.EXistURIResolver) ResourceResolverFactory(org.apache.fop.apps.io.ResourceResolverFactory) EXistURISchemeURIResolver(org.exist.util.EXistURISchemeURIResolver)

Aggregations

EXistURISchemeURIResolver (org.exist.util.EXistURISchemeURIResolver)2 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 URIResolver (javax.xml.transform.URIResolver)1 ResourceResolverFactory (org.apache.fop.apps.io.ResourceResolverFactory)1 URIResolverAdapter (org.apache.xmlgraphics.io.URIResolverAdapter)1 PkgXsltModuleURIResolver (org.exist.repo.PkgXsltModuleURIResolver)1 URIResolverHierarchy (org.exist.util.URIResolverHierarchy)1 EXistURIResolver (org.exist.xslt.EXistURIResolver)1