if (n != null && n instanceof org.exist.memtree.NodeImpl) {
final XmldbURI[] docs = new XmldbURI[] { XmldbURI.create(res.getParentCollection().getName()) };
return doQuery(query, docs, (org.exist.memtree.NodeImpl)n, sortBy);
}
final NodeProxy node = ((LocalXMLResource) res).getNode();
if (node == null) {
// resource is a document
//TODO : use dedicated function in XmldbURI
final XmldbURI[] docs = new XmldbURI[] { XmldbURI.create(res.getParentCollection().getName()).append(res.getDocumentId()) };
return doQuery(query, docs, null, sortBy);
} else {
final NodeSet set = new ExtArrayNodeSet(1);
set.add(node);
final XmldbURI[] docs = new XmldbURI[] { node.getDocument().getURI() };
return doQuery(query, docs, set, sortBy);
}
}