if (mode == NodeSet.PRECEDING) { nb.addContextNode(na); result.add(nb); }
if (mode == NodeSet.PRECEDING) { if (rememberContext) nb.addContextNode(na); else nb.copyContext(na); result.add(nb); }
	public static NodeSet selectSiblings(NodeSet set, NodeSet siblings, int mode) {		if (siblings.getLength() == 0 || set.getLength() == 0)			return NodeSet.EMPTY_SET;		NodeSet result = new ExtArrayNodeSet();		Iterator ia = siblings.iterator();		Iterator ib = set.iterator();        NodeProxy na = (NodeProxy) ia.next();        NodeProxy nb = (NodeProxy) ib.next();				while (true) {			// first, try to find nodes belonging to the same doc			if (na.getDocument().getDocId() < nb.getDocument().getDocId()) {				if (ia.hasNext())					na = (NodeProxy) ia.next();				else					break;			} else if (na.getDocument().getDocId() > nb.getDocument().getDocId()) {				if (ib.hasNext())					nb = (NodeProxy) ib.next();				else					break;			} else {				// same document: check if the nodes have the same parent                long pa = XMLUtil.getParentId(na.getDocument(), na.getGID());                long pb = XMLUtil.getParentId(nb.getDocument(), nb.getGID());				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.getGID() < na.getGID()) {						// found a preceding sibling						if (mode == NodeSet.PRECEDING) {                             nb.addContextNode(na);                                                        result.add(nb);                        }						if (ib.hasNext())							nb = (NodeProxy) ib.next();						else							break;					} else if (nb.getGID() > na.getGID()) {						// found a following sibling												if (mode == NodeSet.FOLLOWING) {                            nb.addContextNode(na);                                                        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;	}