public Sequence eval(StaticContext context, DocumentSet docs, Sequence contextSequence, Item contextItem) throws XPathException { int  count = 1; switch(contextSequence.getItemType()) { case Type.NODE: NodeProxy contextNode = (NodeProxy)contextItem; NodeSet contextSet = (NodeSet)contextSequence; DocumentImpl doc = contextNode.getDoc(); NodeSet set = contextSet.getSiblings(doc, contextNode.getGID());  NodeProxy p; for(Iterator i = set.iterator(); i.hasNext(); count++) { p = (NodeProxy)i.next(); if(p.gid == contextNode.gid) return new IntegerValue(count); } break; default: for(SequenceIterator i = contextSequence.iterate(); i.hasNext(); count++) { if(i.nextItem() == contextItem) return new IntegerValue(count); } break; } return new IntegerValue(-1);
public Sequence eval(DocumentSet docs, Sequence contextSequence, Item contextItem) throws XPathException { if(contextSequence == null || contextSequence.getLength() == 0) return Sequence.EMPTY_SEQUENCE; return new IntegerValue(context.getContextPosition() + 1);
    public Sequence eval(StaticContext context, DocumentSet docs, Sequence contextSequence,     	Item contextItem) throws XPathException {    	int  count = 1;    	switch(contextSequence.getItemType()) {    		case Type.NODE:    			NodeProxy contextNode = (NodeProxy)contextItem;    			NodeSet contextSet = (NodeSet)contextSequence;		        	DocumentImpl doc = contextNode.getDoc();		        NodeSet set = contextSet.getSiblings(doc, contextNode.getGID());		        // determine position of current node in the set		        NodeProxy p;		        for(Iterator i = set.iterator(); i.hasNext(); count++) {		            p = (NodeProxy)i.next();		            if(p.gid == contextNode.gid)		                return new IntegerValue(count);		        }		        break;		     default:		     	for(SequenceIterator i = contextSequence.iterate(); i.hasNext(); count++) {		     		if(i.nextItem() == contextItem)		     			return new IntegerValue(count);		     	}		     	break;    	}        return new IntegerValue(-1);    }