outerSequence.clearContext();
	private Sequence selectByPosition(Sequence outerSequence, Sequence contextSequence, int mode, Expression inner) throws XPathException {		if(Type.subTypeOf(contextSequence.getItemType(), Type.NODE) && outerSequence != null &&			outerSequence.getLength() > 0) {			Sequence result = new ArraySet(100);			NodeSet contextSet = contextSequence.toNodeSet();			boolean reverseAxis = isReverseAxis(mode);			if(!(reverseAxis || mode == Constants.FOLLOWING_SIBLING_AXIS                     || mode == Constants.FOLLOWING_AXIS					|| mode == Constants.SELF_AXIS)) {				Sequence ancestors = contextSet.selectAncestorDescendant(outerSequence.toNodeSet(),						NodeSet.ANCESTOR, true, true);				ArraySet temp = new ArraySet(100);				for(SequenceIterator i = ancestors.iterate(); i.hasNext(); ) {					Item item = i.nextItem();				    NodeProxy p = (NodeProxy)item;				    ContextItem contextNode = p.getContext();				    temp.reset();				    while (contextNode != null) {				    	temp.add(contextNode.getNode());				    	contextNode = contextNode.getNextItem();				    }				    temp.sortInDocumentOrder();				    				    Sequence innerSeq = inner.eval(contextSequence);				    for(SequenceIterator j = innerSeq.iterate(); j.hasNext(); ) {				        Item next = j.nextItem();				        NumericValue v = (NumericValue)next.convertTo(Type.NUMBER);				        p = temp.getUnsorted(v.getInt() - 1);				        if (p != null)				        	result.add(p);				    }				}			} else {				for(SequenceIterator i = outerSequence.iterate(); i.hasNext(); ) {				    Item item = i.nextItem();				    NodeProxy p = (NodeProxy)item;				    Sequence temp;				    switch(mode) {				    	case Constants.FOLLOWING_SIBLING_AXIS:				    	    temp = contextSet.selectSiblings(p, NodeSet.FOLLOWING);			    			break;				    	case Constants.PRECEDING_SIBLING_AXIS:				    	    temp = contextSet.selectSiblings(p, NodeSet.PRECEDING);				    		break;                        case Constants.PRECEDING_AXIS:                            temp = contextSet.selectPreceding(p);                            break;                        case Constants.FOLLOWING_AXIS:                            temp = contextSet.selectFollowing(p);                            break;				    	case Constants.PARENT_AXIS:				    	    temp = p.getParents(false);				    		break;				    	case Constants.ANCESTOR_AXIS:				    	case Constants.ANCESTOR_SELF_AXIS:				    	    temp = contextSet.selectAncestors(p, false, false);				    		break;				    	case Constants.SELF_AXIS:				    	    temp = p;				    		break;				    	default:				    	    temp = contextSet.selectAncestorDescendant(p, NodeSet.DESCENDANT, false, false);				    		break;				    }				    Sequence innerSeq = inner.eval(contextSequence);				    for(SequenceIterator j = innerSeq.iterate(); j.hasNext(); ) {				        Item next = j.nextItem();				        NumericValue v = (NumericValue)next.convertTo(Type.NUMBER);				        int pos = (reverseAxis ? temp.getLength() - v.getInt() : v.getInt() - 1);				        if(pos < temp.getLength() && pos > -1)				            result.add(temp.itemAt(pos));				    }				}			}			return result;		} else {			Sequence innerSeq = inner.eval(contextSequence);			ValueSequence result = new ValueSequence();			for(SequenceIterator i = innerSeq.iterate(); i.hasNext(); ) {				NumericValue v = (NumericValue)i.nextItem().convertTo(Type.NUMBER);				int pos = v.getInt() - 1;				if(pos < contextSequence.getLength() && pos > -1)					result.add(contextSequence.itemAt(pos));			}			return result;		}	}