((NodeProxy)contextItem).addContextNode((NodeProxy)contextItem);
((NodeProxy)contextItem).addContextNode(getExpressionId(), (NodeProxy)contextItem);
	public Sequence eval(Sequence contextSequence, Item contextItem, Sequence resultSequence)        throws XPathException {        if (context.getProfiler().isEnabled()) {            context.getProfiler().start(this);                   context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));            if (contextSequence != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);            if (contextItem != null)                context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());            if (resultSequence != null)                        context.getProfiler().message(this, Profiler.START_SEQUENCES, "RESULT SEQUENCE", resultSequence);        }        		// Save the local variable stack		LocalVariable mark = context.markLocalVariables(false);				// Evaluate the "in" expression		Sequence in = inputSequence.eval(null, null);        		clearContext(in);         		// Declare the iteration variable		LocalVariable var = new LocalVariable(QName.parse(context, varName, null));        var.setSequenceType(sequenceType);		context.declareVariableBinding(var);      				// Declare positional variable		LocalVariable at = null;		if(positionalVariable != null) {			at = new LocalVariable(QName.parse(context, positionalVariable, null));            at.setSequenceType(POSITIONAL_VAR_TYPE);			context.declareVariableBinding(at);		}				// Assign the whole input sequence to the bound variable.		// This is required if we process the "where" or "order by" clause		// in one step.		var.setValue(in);				// Save the current context document set to the variable as a hint		// for path expressions occurring in the "return" clause.		if(in instanceof NodeSet) {		    DocumentSet contextDocs = ((NodeSet)in).getDocumentSet();		    var.setContextDocs(contextDocs);		}		// Check if we can speed up the processing of the "order by" clause.		boolean fastOrderBy = false; // checkOrderSpecs(in);				// See if we can process the "where" clause in a single step (instead of		// calling the where expression for each item in the input sequence)		// This is possible if the input sequence is a node set and has no		// dependencies on the current context item.		boolean fastExec = whereExpr != null &&			( whereExpr.getDependencies() & Dependency.CONTEXT_ITEM ) == 0 &&			at == null &&			Type.subTypeOf( in.getItemType() , Type.NODE);				// If possible, apply the where expression ahead of the iteration		if(fastExec) {			if(!in.isCached())				setContext(in);			in = applyWhereExpression(in);			if(!in.isCached())				clearContext(in);		}				// PreorderedValueSequence applies the order specs to all items		// in one single processing step		if(fastOrderBy) {			in = new PreorderedValueSequence(orderSpecs, in);		}				// Otherwise, if there's an order by clause, wrap the result into		// an OrderedValueSequence. OrderedValueSequence will compute		// order expressions for every item when it is added to the result sequence.		if(resultSequence == null) {			if(orderSpecs != null && !fastOrderBy)				resultSequence = new OrderedValueSequence(orderSpecs, in.getLength());			else				resultSequence = new ValueSequence();		}					Sequence val = null;		int p = 1;		IntegerValue atVal = new IntegerValue(1);		if(positionalVariable != null)			at.setValue(atVal);				// Loop through each variable binding		for (SequenceIterator i = in.iterate(); i.hasNext(); p++) {		    context.proceed(this);			contextItem = i.nextItem();			context.setContextPosition(p);			//			atVal.setValue(p); // seb: this does not create a new Value. the old Value is referenced from results			if(positionalVariable != null)				at.setValue(new IntegerValue(p));			 			contextSequence = contextItem.toSequence();			// set variable value to current item			var.setValue(contextSequence);            var.checkType();			val = contextSequence;						// check optional where clause			if (whereExpr != null && (!fastExec)) {				if(contextItem instanceof NodeProxy)					((NodeProxy)contextItem).addContextNode((NodeProxy)contextItem);				Sequence bool = applyWhereExpression(null);				if(contextItem instanceof NodeProxy)					((NodeProxy)contextItem).clearContext();				// if where returned false, continue				if(!bool.effectiveBooleanValue())					continue;			} else				val = contextItem.toSequence();						/* if the returnExpr is another BindingExpression, call it			 * with the result sequence.			 */			if(returnExpr instanceof BindingExpression)				((BindingExpression)returnExpr).eval(null, null, resultSequence);						// otherwise call the return expression and add results to resultSequence			else {				val = returnExpr.eval(null);				resultSequence.addAll(val);			}		}		if(orderSpecs != null && !fastOrderBy)			((OrderedValueSequence)resultSequence).sort();				// restore the local variable stack		context.popLocalVariables(mark);		        if (context.getProfiler().isEnabled())            context.getProfiler().end(this, "", resultSequence);		return resultSequence;	}