} else {
t.addContextNode(contextId, current);
t.addMatches(current);
}
}
NodeId parentID = current.getNodeId().getParentId();
while (parentID != null) {
ancestor = new NodeProxy(current.getDocument(), parentID,
Node.ELEMENT_NODE);
// Filter out the temporary nodes wrapper element
if (parentID != NodeId.DOCUMENT_NODE
&& !(parentID.getTreeLevel() == 1 && current
.getDocument().getCollection()
.isTempCollection())) {
if (test.matches(ancestor)) {
final NodeProxy t = result.get(ancestor);
if (t == null) {
if (Expression.NO_CONTEXT_ID != contextId)
{ancestor.addContextNode(contextId, current);}
else
{ancestor.copyContext(current);}
ancestor.addMatches(current);
result.add(ancestor);
} else {
t.addContextNode(contextId, current);
t.addMatches(current);
}
}
}
parentID = parentID.getParentId();
}
}
return result;
} else if (hasPreloadedData()) {
DocumentSet docs = getDocumentSet(contextSet);