code: public short acceptNode(int testNode)
    {
      boolean foundKey = false;
      KeyIterator ki = (KeyIterator) m_lpi;
      org.apache.xpath.XPathContext xctxt = ki.getXPathContext();
      Vector keys = ki.getKeyDeclarations();
  
      QName name = ki.getName();
      try
      {
        // System.out.println("lookupKey: "+lookupKey);
        int nDeclarations = keys.size();
  
        // Walk through each of the declarations made with xsl:key
        for (int i = 0; i < nDeclarations; i++)
        {
          KeyDeclaration kd = (KeyDeclaration) keys.elementAt(i);
  
          // Only continue if the name on this key declaration
          // matches the name on the iterator for this walker. 
          if (!kd.getName().equals(name))
            continue;
  
          foundKey = true;
          // xctxt.setNamespaceContext(ki.getPrefixResolver());
  
          // See if our node matches the given key declaration according to 
          // the match attribute on xsl:key.
          XPath matchExpr = kd.getMatch();
          double score = matchExpr.getMatchScore(xctxt, testNode);
  
          if (score == kd.getMatch().MATCH_SCORE_NONE)
            continue;
  
          return DTMIterator.FILTER_ACCEPT;
  
        } // end for(int i = 0; i < nDeclarations; i++)
      }
      catch (TransformerException se)
      {
  
        // TODO: What to do?
      }
  
      if (!foundKey)
        throw new RuntimeException(
          XSLMessages.createMessage(
            XSLTErrorResources.ER_NO_XSLKEY_DECLARATION,
            new Object[] { name.getLocalName()}));
            
      return DTMIterator.FILTER_REJECT;
    }
docs: Test whether a specified node is visible in the logical view of a
  TreeWalker or NodeIterator. This function will be called by the
  implementation of TreeWalker and NodeIterator; it is not intended to
  be called directly from user code.
  
  @param testNode  The node to check to see if it passes the filter or not.
  
  @return  a constant to determine whether the node is accepted,
  rejected, or skipped, as defined  above .