result = currentSet.selectAncestors( contextSet, axis == Constants.ANCESTOR_SELF_AXIS, inPredicate); } else { DocumentSet docs = getDocumentSet(contextSet); NodeSelector selector = new AncestorSelector(contextSet, inPredicate, axis == Constants.ANCESTOR_SELF_AXIS);
	protected NodeSet getAncestors(		XQueryContext context,		NodeSet contextSet) {				NodeSet result;		if (test.isWildcardTest()) {            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.gid, p.getInternalAddress());                    if (inPredicate)                        ancestor.addContextNode(p);                    else                        ancestor.copyContext(p);                    result.add(ancestor);                }                ancestor = new NodeProxy(p.getDocument(), p.gid);                while ((ancestor.gid = XMLUtil.getParentId(p.getDocument(), ancestor.gid)) > 0) {                    ancestor.nodeType = Node.ELEMENT_NODE;                    if (test.matches(ancestor)) {                        if (inPredicate)                            ancestor.addContextNode(p);                        else                            ancestor.copyContext(p);                        result.add(ancestor);                        ancestor = new NodeProxy(p.getDocument(), ancestor.gid);                    }                }            }        } else if(preloadNodeSets()) {            DocumentSet docs = getDocumentSet(contextSet);            if (currentSet == null || currentDocs == null || !(docs.equals(currentDocs))) {                currentDocs = docs;                currentSet =                    context.getBroker().getElementIndex().findElementsByTagName(                            ElementValue.ELEMENT, currentDocs,                            test.getName(), null);                registerUpdateListener();            }            result =                currentSet.selectAncestors(                        contextSet,                        axis == Constants.ANCESTOR_SELF_AXIS,                        inPredicate);		} else {            DocumentSet docs = getDocumentSet(contextSet);            NodeSelector selector = new AncestorSelector(contextSet, inPredicate, axis == Constants.ANCESTOR_SELF_AXIS);            result = context.getBroker().getElementIndex().findElementsByTagName(                    ElementValue.ELEMENT, docs, test.getName(), selector            );		}		return result;	}