code: public TemplateSubPatternAssociation getHead(XPathContext xctxt, 
                                                 int targetNode, DTM dtm)
    {
      short targetNodeType = dtm.getNodeType(targetNode);
      TemplateSubPatternAssociation head;
  
      switch (targetNodeType)
      {
      case DTM.ELEMENT_NODE :
      case DTM.ATTRIBUTE_NODE :
        head = (TemplateSubPatternAssociation) m_patternTable.get(
          dtm.getLocalName(targetNode));
        break;
      case DTM.TEXT_NODE :
      case DTM.CDATA_SECTION_NODE :
        head = m_textPatterns;
        break;
      case DTM.ENTITY_REFERENCE_NODE :
      case DTM.ENTITY_NODE :
        head = (TemplateSubPatternAssociation) m_patternTable.get(
          dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
        break;
      case DTM.PROCESSING_INSTRUCTION_NODE :
        head = (TemplateSubPatternAssociation) m_patternTable.get(
          dtm.getLocalName(targetNode));
        break;
      case DTM.COMMENT_NODE :
        head = m_commentPatterns;
        break;
      case DTM.DOCUMENT_NODE :
      case DTM.DOCUMENT_FRAGMENT_NODE :
        head = m_docPatterns;
        break;
      case DTM.NOTATION_NODE :
      default :
        head = (TemplateSubPatternAssociation) m_patternTable.get(
          dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
      }
  
      return (null == head) ? m_wildCardPatterns : head;
    }
docs: Get the head of the most likely list of associations to check, based on
  the name and type of the targetNode argument.
  
  @param xctxt The XPath runtime context.
  @param targetNode The target node that will be checked for a match.
  @param dtm The dtm owner for the target node.
  
  @return The head of a linked list that contains all possible match pattern to
  template associations.