Search in sources :

Example 1 with ExternalModule

use of org.exist.xquery.ExternalModule in project exist by eXist-db.

the class ModuleInfo method outputModule.

private void outputModule(final MemTreeBuilder builder, final Module module) {
    builder.startElement(MODULE_QNAME, null);
    builder.addAttribute(MODULE_URI_ATTR, module.getNamespaceURI());
    builder.addAttribute(MODULE_PREFIX_ATTR, module.getDefaultPrefix());
    if (!module.isInternalModule()) {
        final Source source = ((ExternalModule) module).getSource();
        if (source != null) {
            builder.addAttribute(MODULE_SOURCE_ATTR, source.pathOrContentOrShortIdentifier());
        }
    }
    builder.startElement(MODULE_DESC_QNAME, null);
    builder.characters(module.getDescription());
    // <description>
    builder.endElement();
    // <module>
    builder.endElement();
}
Also used : ExternalModule(org.exist.xquery.ExternalModule) Source(org.exist.source.Source)

Example 2 with ExternalModule

use of org.exist.xquery.ExternalModule in project exist by eXist-db.

the class XQueryInspector method getDependencies.

private static void getDependencies(final XQueryContext xqyCtx, final Map<String, Set<String>> dependencies) {
    final String xqueryUri = getDbUri(xqyCtx.getSource());
    Set<String> depSet = dependencies.get(xqueryUri);
    if (depSet == null) {
        final Iterator<Module> itModule = xqyCtx.getModules();
        while (itModule.hasNext()) {
            final Module module = itModule.next();
            if (module instanceof ExternalModule) {
                final ExternalModule extModule = (ExternalModule) module;
                final Source source = extModule.getSource();
                if (source instanceof DBSource) {
                    final String moduleUri = getDbUri(source);
                    if (depSet == null) {
                        depSet = new HashSet<>();
                    }
                    depSet.add(moduleUri);
                    /*
                         * must merge map here as recursive function
                         * can cause problems with recursive
                         * module imports m1 -> m2 -> m2 -> m1
                         */
                    dependencies.put(xqueryUri, depSet);
                }
                getDependencies(extModule.getContext(), dependencies);
            }
        }
    }
}
Also used : DBSource(org.exist.source.DBSource) Module(org.exist.xquery.Module) ExternalModule(org.exist.xquery.ExternalModule) ExternalModule(org.exist.xquery.ExternalModule) Source(org.exist.source.Source) DBSource(org.exist.source.DBSource)

Aggregations

Source (org.exist.source.Source)2 ExternalModule (org.exist.xquery.ExternalModule)2 DBSource (org.exist.source.DBSource)1 Module (org.exist.xquery.Module)1