ancestor.copyContext(p);
ancestor.copyContext(current);
	protected NodeSet getAncestors(XQueryContext context, NodeSet contextSet) {				if (test.isWildcardTest()) {            NodeSet result = new ExtArrayNodeSet();            NodeProxy p, ancestor;            for (Iterator i = contextSet.iterator(); i.hasNext();) {                p = (NodeProxy) i.next();                if (axis == Constants.ANCESTOR_SELF_AXIS && test.matches(p)) {                    ancestor = new NodeProxy(p.getDocument(), p.getGID(), p.getInternalAddress());                    if (inPredicate)                        ancestor.addContextNode(p);                    else                        ancestor.copyContext(p);                    result.add(ancestor);                }                long parentID = XMLUtil.getParentId(p.getDocument(), p.getGID());                               while (parentID > 0) {                    ancestor = new NodeProxy(p.getDocument(), parentID, Node.ELEMENT_NODE);                                           //TODO : optimize !!!! -pb                    if (parentID != NodeProxy.DOCUMENT_NODE_GID &&                             //Remove the temorary nodes wrapper element                             //TODO : optimize this !!!                            !(parentID == NodeProxy.DOCUMENT_ELEMENT_GID && p.getDocument().getCollection().isTempCollection())) {                                                                                                    if (test.matches(ancestor)) {                            if (inPredicate)                                ancestor.addContextNode(p);                            else                                ancestor.copyContext(p);                            result.add(ancestor);                                                }                    }                    parentID = XMLUtil.getParentId(ancestor);                }            }            return result;        } else if (preloadNodeSets()) {                        DocumentSet docs = getDocumentSet(contextSet);            if (currentSet == null || currentDocs == null || !(docs.equals(currentDocs))) {                ElementIndex index = context.getBroker().getElementIndex();                 if (context.getProfiler().isEnabled())                    context.getProfiler().message(this, Profiler.OPTIMIZATIONS,                             "OPTIMIZATION", "using index '" + index.toString() + "'");                  currentSet = index.findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null);                currentDocs = docs;                registerUpdateListener();            }                       switch (axis) {                case Constants.ANCESTOR_SELF_AXIS :                    return currentSet.selectAncestors(contextSet, true, inPredicate);                                   case Constants.ANCESTOR_AXIS :                                 return currentSet.selectAncestors(contextSet, false, inPredicate);                                    default :                    throw new IllegalArgumentException("Unsupported axis specified");                               }        		} else {            NodeSelector selector;                        DocumentSet docs = getDocumentSet(contextSet);            switch (axis) {                case Constants.ANCESTOR_SELF_AXIS :                    selector = new AncestorSelector(contextSet, inPredicate, true);                     break;                case Constants.ANCESTOR_AXIS :                                 selector = new AncestorSelector(contextSet, inPredicate, false);                    break;                default :                    throw new IllegalArgumentException("Unsupported axis specified");                               }            ElementIndex index = context.getBroker().getElementIndex();            if (context.getProfiler().isEnabled())                context.getProfiler().message(this, Profiler.OPTIMIZATIONS,                         "OPTIMIZATION", "using index '" + index.toString() + "'");                          return index.findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), selector);		}			}