code: public int getCountOfContextNodeList(XPathContext xctxt)
            throws javax.xml.transform.TransformerException
    {
  
      // assert(null != m_contextNodeList, "m_contextNodeList must be non-null");
      // If we're in a predicate, then this will return non-null.
      SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList();
  
      // System.out.println("iter: "+iter);
      if (null != iter)
        return iter.getLastPos(xctxt);
  
      DTMIterator cnl = xctxt.getContextNodeList();
      int count;
      if(null != cnl)
      {
        count = cnl.getLength();
        // System.out.println("count: "+count); 
      }
      else
        count = 0;   
      return count;
    }
docs: Get the position in the current context node list.
  
  @param xctxt non-null reference to XPath runtime context.
  
  @return The number of nodes in the list.
  
  @throws javax.xml.transform.TransformerException