else expr.setContextDocSet(null);
    public Sequence eval(Sequence contextSequence, Item contextItem) 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());        }                Sequence result = null;                if (steps.size() == 0) {            result = Sequence.EMPTY_SEQUENCE;        } else {            //we will filter out nodes from the contextSequence            result = contextSequence;                        DocumentSet contextDocs = null;            Expression expr = (Expression) steps.get(0);            if (expr instanceof VariableReference) {                Variable var = ((VariableReference) expr).getVariable();                if (var != null)                     contextDocs = var.getContextDocs();                        }                if (contextDocs != null)            	setContextDocSet(contextDocs);                                 //To prevent processing nodes after atomic values...            //TODO : let the parser do it ? -pb            boolean gotAtomicResult = false;                        for (Iterator iter = steps.iterator(); iter.hasNext();) {                                expr = (Expression) iter.next();                                //TODO : maybe this could be detected by the parser ? -pb                    if (gotAtomicResult && !Type.subTypeOf(expr.returnsType(), Type.NODE)                        //Ugly workaround to allow preceding *text* nodes.                        && !(expr instanceof EnclosedExpr)) {                    LOG.debug("Path steps:" + steps);                    LOG.debug("Current expression:" + expr);                    throw new XPathException("XPTY0019: left operand of '/' must be a node. Got '" +                             Type.getTypeName(result.getItemType()) + Cardinality.toString(result.getCardinality()) + "'");                                    }                                 if (contextDocs != null)                     expr.setContextDocSet(contextDocs);                                if (Dependency.dependsOn(expr.getDependencies(), Dependency.CONTEXT_ITEM)) {                    if (result == null || result.getLength() == 0) {                        result = expr.eval(Sequence.EMPTY_SEQUENCE, null);                                        } else {                                                Sequence values = null;                        if (result.getLength() > 1)                            values = new ValueSequence();                          //Restore a position which may have been modified by inner expressions                         int p = context.getContextPosition();                        for (SequenceIterator iterInner = result.iterate(); iterInner.hasNext(); p++) {                            context.setContextPosition(p);                            Item current = iterInner.nextItem();                                                        if (values == null)                                values = expr.eval(result, current);                            else                                values.addAll(expr.eval(result, current));                                                   }                        result = values;                                        }                                                   } else {                    result = expr.eval(result);                }                            //TOUNDERSTAND : why did I have to write this test :-) ? -pb                //it looks like an empty sequence could be considered as a sub-type of Type.NODE                //well, no so stupid I think...                                if (!Type.subTypeOf(result.getItemType(), Type.NODE) && result.getLength() > 0)                    gotAtomicResult = true;                if(steps.size() > 1)                    // remove duplicate nodes if this is a path                     // expression with more than one step                    result.removeDuplicates();                            }        }                if (context.getProfiler().isEnabled())             context.getProfiler().end(this, "", result);                return result;    }