if (mode == FOLLOWING)
if (mode == FOLLOWING) { nb.addContextNode(na);
	public NodeSet selectSiblings(NodeSet siblings, int mode) {		if (siblings.getLength() == 0 || getLength() == 0)			return EMPTY_SET;		NodeSet result = new ExtArrayNodeSet();		Iterator ia = iterator();		Iterator ib = siblings.iterator();		NodeProxy na = (NodeProxy) ia.next(), nb = (NodeProxy) ib.next();		long pa, pb;		while (true) {			// first, try to find nodes belonging to the same doc			if (na.doc.getDocId() < nb.doc.getDocId()) {				if (ia.hasNext())					na = (NodeProxy) ia.next();				else					break;			} else if (na.doc.getDocId() > nb.doc.getDocId()) {				if (ib.hasNext())					nb = (NodeProxy) ib.next();				else					break;			} else {				// same document: check if the nodes have the same parent				pa = XMLUtil.getParentId(na.doc, na.gid);				pb = XMLUtil.getParentId(nb.doc, nb.gid);				if (pa < pb) {					// wrong parent: proceed					if (ia.hasNext())						na = (NodeProxy) ia.next();					else						break;				} else if (pa > pb) {					// wrong parent: proceed					if (ib.hasNext())						nb = (NodeProxy) ib.next();					else						break;				} else {					// found two nodes with the same parent					// now, compare the ids: a node is a following sibling					// if its id is greater than the id of the other node					if (nb.gid < na.gid) {						// found a preceding sibling						if (mode == PRECEDING)							result.add(nb);						if (ib.hasNext())							nb = (NodeProxy) ib.next();						else							break;					} else if (nb.gid > na.gid) {						// found a following sibling												if (mode == FOLLOWING)							result.add(nb);						if (ib.hasNext())							nb = (NodeProxy) ib.next();						else							break;						// equal nodes: proceed with next node					} else if (ib.hasNext())						nb = (NodeProxy) ib.next();					else						break;				}			}		}		return result;	}