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();
}
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);
}
}
}
}
Aggregations