NodeSet r = contextSet.getAncestors( (ArraySet) buf, axis == Constants.ANCESTOR_SELF_AXIS, inPredicate); LOG.debug("getAncestors found " + r.getLength()); return r;
	protected NodeSet getAncestors(		StaticContext context,		DocumentSet documents,		NodeSet contextSet) {		if (!test.isWildcardTest()) {			DBBroker broker = null;			try {				broker = pool.get();				if (buf == null) {					buf = (NodeSet) broker.findElementsByTagName(documents, test.getName());				}				NodeSet r =					contextSet.getAncestors(						(ArraySet) buf,						axis == Constants.ANCESTOR_SELF_AXIS,						inPredicate);				LOG.debug("getAncestors found " + r.getLength());				return r;			} catch (EXistException e) {				LOG.debug(e.getMessage(), e);				return null;			} finally {				pool.release(broker);			}		} else {			NodeSet result = new ArraySet(contextSet.getLength());			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.doc, p.gid, p.internalAddress));				while ((p.gid = XMLUtil.getParentId(p.doc, p.gid)) > 0) {					p.nodeType = Node.ELEMENT_NODE;					if (test.matches(p))						result.add(new NodeProxy(p.doc, p.gid));				}			}			return result;		}	}