if (includeSelf) {
if (Expression.NO_CONTEXT_ID != contextId)
{current.addContextNode(contextId, current);}
ancestors.add(current);
}
NodeId parentID = current.getNodeId().getParentId();
while (parentID != null) {
//Filter out the temporary nodes wrapper element
if (parentID != NodeId.DOCUMENT_NODE &&
!(parentID.getTreeLevel() == 1 && current.getDocument().getCollection().isTempCollection())) {
final NodeProxy parent = new NodeProxy(current.getDocument(), parentID, Node.ELEMENT_NODE);
if (Expression.NO_CONTEXT_ID != contextId)
{parent.addContextNode(contextId, current);}
else
{parent.copyContext(current);}
ancestors.add(parent);
}
parentID = parentID.getParentId();
}
}
ancestors.mergeDuplicates();
return ancestors;
}