code: protected LocPathIterator changePartToRef(final QName uniquePseudoVarName, WalkingIterator wi, 
                                   final int numSteps, final boolean isGlobal)
    {
    	Variable var = new Variable();
    	var.setQName(uniquePseudoVarName);
    	var.setIsGlobal(isGlobal);
    	if(isGlobal)
    	{	ElemTemplateElement elem = getElemFromExpression(wi);
    		StylesheetRoot root = elem.getStylesheetRoot();
    		Vector vars = root.getVariablesAndParamsComposed();
    		var.setIndex(vars.size()-1);
    	}
    	
    	// Walk to the first walker after the one's we are replacing.
    	AxesWalker walker = wi.getFirstWalker();
    	for(int i = 0; i < numSteps; i++)
    	{
    		assertion(null != walker, "Walker should not be null!");
    		walker = walker.getNextWalker();
    	}
    	
    	if(null != walker)
    	{
    	
    	  FilterExprWalker few = new FilterExprWalker(wi);
    	  few.setInnerExpression(var);
    	  few.exprSetParent(wi);
    	  few.setNextWalker(walker);
    	  walker.setPrevWalker(few);
    	  wi.setFirstWalker(few);
    	  return wi;
    	}
    	else
    	{
    	  FilterExprIteratorSimple feis = new FilterExprIteratorSimple(var);
    	  feis.exprSetParent(wi.exprGetParent());
    	  return feis;
    	}
    }
docs: Change a given number of steps to a single variable reference.
  
  @param uniquePseudoVarName The name of the variable reference.
  @param wi The walking iterator that is to be changed.
  @param numSteps The number of steps to be changed.
  @param isGlobal true if this will be a global reference.