if (axis == Constants.ANCESTOR_SELF_AXIS && test.matches(p)) result.add( new NodeProxy(p.getDocument(), p.gid, p.getInternalAddress()));
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); }
	protected NodeSet getAncestors(		XQueryContext context,		NodeSet contextSet) {		NodeSet result;		if (!test.isWildcardTest()) {			DocumentSet docs = getDocumentSet(contextSet);//			if (currentSet == null || currentDocs == null || !(docs.equals(currentDocs))) {//				currentDocs = docs;//				currentSet =//					(NodeSet) context.getBroker().getElementIndex().findElementsByTagName(//						ElementValue.ELEMENT, currentDocs,//						test.getName(), null);//			}//			result =//				currentSet.selectAncestors(//					contextSet,//					axis == Constants.ANCESTOR_SELF_AXIS,//					inPredicate);            NodeSelector selector = new AncestorSelector(contextSet, inPredicate, axis == Constants.ANCESTOR_SELF_AXIS);            result = context.getBroker().getElementIndex().findElementsByTagName(                    ElementValue.ELEMENT, docs, test.getName(), selector            );//			LOG.debug("getAncestors found " + result.getLength());		} else {			result = new ExtArrayNodeSet();			NodeProxy p;			for (Iterator i = contextSet.iterator(); i.hasNext();) {				p = (NodeProxy) i.next();				if (axis == Constants.ANCESTOR_SELF_AXIS && test.matches(p))					result.add(						new NodeProxy(p.getDocument(), p.gid, p.getInternalAddress()));				while ((p.gid = XMLUtil.getParentId(p.getDocument(), p.gid)) > 0) {					p.nodeType = Node.ELEMENT_NODE;					if (test.matches(p))						result.add(new NodeProxy(p.getDocument(), p.gid));				}			}		}		return result;	}