if (Dependency.dependsOn(expr, Dependency.CONTEXT_POSITION) && !result.isEmpty()) {
if ((Dependency.dependsOn(expr, Dependency.CONTEXT_ITEM) || Dependency.dependsOn(expr, Dependency.CONTEXT_POSITION)) && result != null && !result.isEmpty()) {
    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();                //TOUNDERSTAND : how null could be possible here ? -pb                if (var != null)                     contextDocs = var.getContextDocs();                        }            //contextDocs == null *is* significant            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)) {                    throw new XPathException("XPTY0019: left operand of '/' must be a node. Got '" +                             Type.getTypeName(result.getItemType()) + Cardinality.toString(result.getCardinality()) + "'");                                    }                                                 //contextDocs == null *is* significant                expr.setContextDocSet(contextDocs);                          //DESIGN : first test the dependency then the result                if (Dependency.dependsOn(expr, Dependency.CONTEXT_POSITION) &&                 		!result.isEmpty()) {                                          Sequence exprResult = 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();                           //0 or 1 item                        if (!result.hasMany())                        	exprResult = expr.eval(result, current);                        else {                        	                        	exprResult.addAll(expr.eval(result, current));                        }                    }                    result = exprResult;                                                     } 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 (steps.size() > 1 && !result.isEmpty() && !Type.subTypeOf(result.getItemType(), Type.NODE))                    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;    }