public Object evaluate(Context context) throws JaxenException { List nodeSet = context.getNodeSet(); List contextNodeSet = new ArrayList(nodeSet); ContextSupport support = context.getContextSupport(); Context stepContext = new Context(support); Iterator stepIter = getSteps().iterator(); while ( stepIter.hasNext() ) { Step eachStep = (Step) stepIter.next(); stepContext.setNodeSet(contextNodeSet); contextNodeSet = eachStep.evaluate(stepContext); // now we need to reverse the list if this is a reverse axis if (isReverseAxis(eachStep)) { Collections.reverse(contextNodeSet); } } if (getSteps().size() > 1 || nodeSet.size() > 1) { Collections.sort(contextNodeSet, new NodeComparator(support.getNavigator())); } return contextNodeSet; }