NodeProxy next = contextNode.getNode(); if(contextIsVirtual || contextSet.contains(next)) { next.addMatches(current); result.add(next, sizeHint);
if (contextNode.getContextId() == getExpressionId()) { NodeProxy next = contextNode.getNode(); if(contextIsVirtual || contextSet.contains(next)) { next.addMatches(current); result.add(next, sizeHint); }
	protected Sequence applyWhereExpression(Sequence contextSequence) throws XPathException {		if (contextSequence != null &&			Type.subTypeOf(whereExpr.returnsType(), Type.NODE) &&			Type.subTypeOf(contextSequence.getItemType(), Type.NODE)) {			// if the where expression returns a node set, check the context			// node of each node in the set           			NodeSet contextSet = contextSequence.toNodeSet();			boolean contextIsVirtual = contextSet instanceof VirtualNodeSet;                      Sequence seq = whereExpr.eval(contextSequence);            NodeSet nodes = seq.toNodeSet(); 			NodeSet result = new ExtArrayNodeSet();            DocumentImpl lastDoc = null;            int count = 0;			for (Iterator i = nodes.iterator(); i.hasNext(); count++) {                NodeProxy current = (NodeProxy) i.next();                int sizeHint = Constants.NO_SIZE_HINT;				if(lastDoc == null || current.getDocument() != lastDoc) {					lastDoc = current.getDocument();					sizeHint = nodes.getSizeHint(lastDoc);				}                ContextItem	contextNode = current.getContext();				if (contextNode == null) {					throw new XPathException("Internal evaluation error: context node is missing for node " +						current.getGID() + "!");				}				//TODO : review to consider transverse context				while (contextNode != null) {                    NodeProxy next = contextNode.getNode();                    					if(contextIsVirtual || contextSet.contains(next)) {						next.addMatches(current);						result.add(next, sizeHint);					}					contextNode = contextNode.getNextDirect();				}			}			return result;		} else if (contextSequence == null) {			Sequence innerSeq = whereExpr.eval(null);			return innerSeq.effectiveBooleanValue() ? BooleanValue.TRUE : BooleanValue.FALSE;		} else {			// general where clause: just check the effective boolean value			ValueSequence result = new ValueSequence();			int p = 0;						for (SequenceIterator i = contextSequence.iterate(); i.hasNext(); p++) {				Item item = i.nextItem();				context.setContextPosition(p);                Sequence innerSeq = whereExpr.eval(contextSequence, item);                				if (innerSeq.effectiveBooleanValue())					result.add(item);                    			}			return result;		}	}