sboag       00/02/13 08:36:51

  Modified:    src/org/apache/xalan/xpath/dtm DTMNodeLocator.java
  Log:
  Removed most overrides of SimpleNodeLocator.
  
  Revision  Changes    Path
  1.11      +1 -785    
xml-xalan/src/org/apache/xalan/xpath/dtm/DTMNodeLocator.java
  
  Index: DTMNodeLocator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/dtm/DTMNodeLocator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DTMNodeLocator.java       2000/02/08 14:43:52     1.10
  +++ DTMNodeLocator.java       2000/02/13 16:36:51     1.11
  @@ -86,792 +86,8 @@
       m_locater = (null == m_locater) ? new DTMNodeLocator() : m_locater;
       return m_locater;
     }
  -  
  -  /**
  -   * Add the descendants (and the context if the stepType is 
  -   * FROM_DESCENDANTS_OR_SELF) to the list if they meet 
  -   * the NodeTest qualification.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @param stepType Value of xpath.FROM_DESCENDANTS or 
xpath.FROM_DESCENDANTS_OR_SELF.
  -   * @param subQueryResults Should be an empty node list where the 
  -   * results of the step will be put.
  -   * @returns the length of the argument (i.e. amount to add to predicate 
pos 
  -   * or end of step).
  -   */
  -  protected int findDescendants(XPath xpath, XPathSupport execContext, Node 
context, int opPos, 
  -                                int stepType, MutableNodeList 
subQueryResults)
  -    throws org.xml.sax.SAXException
  -  { 
  -    // return super.findDescendants(xpath, execContext, context, opPos, 
stepType, subQueryResults);
  -    int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -    int newOpPos = opPos + 3;
  -    try
  -    {
  -      DTMProxy dtmp = (DTMProxy)context;
  -      int dtmpPos = dtmp.node;
  -      DTM dtm = dtmp.dtm;
  -      
  -      if(stepType == xpath.FROM_DESCENDANTS_OR_SELF)
  -      {
  -        if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, execContext, context, 
newOpPos, argLen, stepType))
  -        {
  -          subQueryResults.addNode(context);
  -        }
  -      }
  -
  -      // Walk across the kids until all have been accounted for
  -      for (int kid = dtm.getFirstChild(dtmpPos); 
  -           kid != -1; 
  -           kid = dtm.getNextDescendant(dtmpPos, kid))
  -      {
  -        DTMProxy kidNode = dtm.getNode(kid);
  -        if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, execContext, kidNode, 
newOpPos, argLen, stepType))
  -        {
  -          subQueryResults.addNode(kidNode);
  -        }
  -        
  -      }
  -    }
  -    catch(ClassCastException cce)
  -    {
  -      return super.findDescendants(xpath, execContext, context, opPos, 
stepType, subQueryResults);
  -    }
  -    return argLen+3;
  -  }
  -  
  -  /**
  -   * Add the nodes preceding the context to the list if they meet 
  -   * the NodeTest qualification.
  -   * The preceding axis contains all nodes in the same document 
  -   * as the context node that are before the context node in document 
  -   * order, excluding any ancestors and excluding attribute nodes 
  -   * and namespace nodes; the nodes are ordered in reverse document order.
  -   * Note that the ancestor, descendant, following, preceding and 
  -   * self axes partition a document (ignoring attribute and namespace 
  -   * nodes): they do not overlap and together they contain all the 
  -   * nodes in the document.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @param stepType Value of xpath.FROM_PRECEDING.
  -   * @param subQueryResults Should be an empty node list where the 
  -   * results of the step will be put.
  -   * @returns the length of the argument (i.e. amount to add to predicate 
pos 
  -   * or end of step).
  -   */
  -  protected int findPreceding(XPath xpath, XPathSupport execContext, Node 
context, int opPos, 
  -                              int stepType, MutableNodeList subQueryResults)
  -    throws org.xml.sax.SAXException
  -  {
  -    int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -    int newOpPos = opPos + 3;
  -    try
  -    {
  -      DTMProxy dtmp = (DTMProxy)context;
  -      int dtmpPos = dtmp.node;
  -      DTM dtm = dtmp.dtm;
  -      
  -      // Walk across the kids until all have been accounted for.
  -      for (int preceding = dtm.getNextPreceding(dtmpPos, dtmpPos); 
  -           preceding != -1; 
  -           preceding = dtm.getNextPreceding(dtmpPos, preceding))
  -      {
  -        DTMProxy precedingNode = dtm.getNode(preceding);
  -        if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, execContext, 
precedingNode, newOpPos, argLen, stepType))
  -        {
  -          subQueryResults.addNode(precedingNode);
  -        }
  -      }
  -    }
  -    catch(ClassCastException cce)
  -    {
  -      return super.findPreceding(xpath, execContext, context, opPos, 
stepType, subQueryResults);
  -    }
  -    return argLen+3;
  -  }
  -  
  -  /**
  -   * Add children to the list if they meet 
  -   * the NodeTest qualification.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @param stepType Value of xpath.FROM_CHILDREN.
  -   * @param subQueryResults Should be an empty node list where the 
  -   * results of the step will be put.
  -   * @returns the length of the argument (i.e. amount to add to predicate 
pos 
  -   * or end of step).
  -   */
  -  protected int findChildren(XPath xpath, XPathSupport execContext, Node 
context, int opPos, 
  -                             int stepType, MutableNodeList subQueryResults)
  -    throws org.xml.sax.SAXException
  -  {
  -    int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -    int newOpPos = opPos + 3;
  -    try
  -    {
  -      DTMProxy dtmp = (DTMProxy)context;
  -      int dtmpPos = dtmp.node;
  -      DTM dtm = dtmp.dtm;
  -            
  -      // Walk across the kids until all have been accounted for.
  -      for (int child = dtm.getFirstChild(dtmpPos); 
  -           child != -1; 
  -           child = dtm.getNextSibling(child))
  -      {
  -        DTMProxy childNode = dtm.getNode(child);
  -        if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, execContext, childNode, 
newOpPos, argLen, stepType))
  -        {
  -          subQueryResults.addNode(childNode);
  -        }
  -      }
  -    }
  -    catch(ClassCastException cce)
  -    {
  -      return super.findChildren(xpath, execContext, context, opPos, 
stepType, subQueryResults);
  -    }
  -    
  -    return argLen+3;
  -  }
  -  
  -  /**
  -   * Add attributes to the list if they meet 
  -   * the NodeTest qualification.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @param stepType Value of xpath.FROM_ATTRIBUTES.
  -   * @param subQueryResults Should be an empty node list where the 
  -   * results of the step will be put.
  -   * @returns the length of the argument (i.e. amount to add to predicate 
pos 
  -   * or end of step).
  -   */
  -  protected int findAttributes(XPath xpath, XPathSupport execContext, Node 
context, int opPos, 
  -                                 int stepType, MutableNodeList 
subQueryResults)
  -    throws org.xml.sax.SAXException
  -  {
  -    int argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -    int newOpPos = opPos + 3;
  -
  -    try
  -    {
  -      DTMProxy dtmp = (DTMProxy)context;
  -      int dtmpPos = dtmp.node;
  -      DTM dtm = dtmp.dtm;
  -            
  -      // Walk across the kids until all have been accounted for.
  -      for (int child = dtm.getFirstAttribute(dtmpPos); 
  -           child != -1; 
  -           child = dtm.getNextAttribute(child))
  -      {
  -        Attr attr = (Attr)dtm.getNode(child);
  -        if(xpath.MATCH_SCORE_NONE != nodeTest(xpath, execContext, attr, 
newOpPos, argLen, stepType))
  -        {
  -          subQueryResults.addNode(attr);
  -        }
  -      }
  -    }
  -    catch(ClassCastException cce)
  -    {
  -      return super.findAttributes(xpath, execContext, context, opPos, 
stepType, subQueryResults);
  -    }
  -
  -    return argLen+3;
  -  }
  -
  -  /**
  -   * Create an XPathFactory for DTMNodeLocator.
  -   */
  -  public static XPathFactory factory() 
  -  {
  -    return new DTMNodeLocatorFactory();
  -  }
  -  
  -  /**
  -   * Execute a location path pattern.  This will return a score
  -   * of MATCH_SCORE_NONE, MATCH_SCORE_NODETEST, 
  -   * MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @returns score, one of MATCH_SCORE_NODETEST, 
  -   * MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
  -   */
  -  /*
  -  public double locationPathPattern(XPath xpath, XPathSupport execContext, 
Node context, int opPos)
  -  {
  -    try
  -    {
  -      DTMProxy contextp = (DTMProxy)context;
  -      return locationPathPattern(xpath, execContext, contextp.dtm, 
contextp.node, opPos);
  -    }
  -    catch(ClassCastException cce)
  -    {
  -      return super.locationPathPattern(xpath, execContext, context, opPos);
  -    }
  -  }
  -  */
  -  
  -  /**
  -   * Execute a a location path pattern.  This will return a score
  -   * of MATCH_SCORE_NONE, MATCH_SCORE_NODETEST, 
  -   * MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @returns score, one of MATCH_SCORE_NODETEST, 
  -   * MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
  -   */
  -  public double locationPathPattern(XPath xpath, XPathSupport execContext, 
DTM dtm, int context, int opPos) 
  -    throws org.xml.sax.SAXException
  -  {    
    opPos+=2;
  -    double[] scoreHolder = 
  -    {
  -      xpath.MATCH_SCORE_NONE};
    stepPattern(xpath, execContext, dtm, context, opPos, scoreHolder);
    return scoreHolder[0];
  -  }

  /**
  -   * Execute a step in a location path.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @returns the last matched context node.
  -   */
  -  protected int stepPattern(XPath xpath, XPathSupport execContext, DTM dtm, 
int context, int opPos, double scoreHolder[]) 
  -    throws org.xml.sax.SAXException
  -  {    
    int startOpPos = opPos;
    int stepType = xpath.m_opMap[opPos];
  -    
  -    int endStep = xpath.getNextOpPos(opPos);
  -    int nextStepType = xpath.m_opMap[endStep];
  -    double score;
  -    
  -    if(xpath.ENDOP != nextStepType)
  -    {
  -      // Continue step via recursion...
  -      context = stepPattern(xpath, execContext, dtm, context, endStep, 
scoreHolder);
  -      if(-1 == context)
  -        scoreHolder[0] = xpath.MATCH_SCORE_NONE;
  -      if(scoreHolder[0] == xpath.MATCH_SCORE_NONE)
  -        return -1;
  -      scoreHolder[0] = xpath.MATCH_SCORE_OTHER;
  -      context = dtm.getParent(context);
  -      if(-1 == context)
  -        return -1;
  -    }
  -    
  -    int argLen;
  -
  -    switch(stepType)
  -    {
  -    case XPath.OP_FUNCTION:
  -      {
  -        argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH];
  -        Node contextNode = dtm.getNode( context );
  -        XObject obj = xpath.execute(execContext, contextNode, opPos);
  -        NodeList nl = obj.nodeset();
  -        int len = nl.getLength();
  -        score = xpath.MATCH_SCORE_NONE;
  -        for(int i = 0; i < len; i++)
  -        {
  -          Node n = nl.item(i);
  -          score = (contextNode.equals( n )) ? xpath.MATCH_SCORE_OTHER : 
xpath.MATCH_SCORE_NONE;
  -          if(score == xpath.MATCH_SCORE_OTHER)
  -          {
  -            context = ((DTMProxy)n).getDTMNodeNumber();
  -            break;
  -          }
  -        }
  -      }
  -      break;
  -    case XPath.FROM_ROOT:
  -      {
  -        argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -        opPos += 3; 
  -        score = (0 == context) ? xpath.MATCH_SCORE_OTHER : 
xpath.MATCH_SCORE_NONE;
  -        if(score == xpath.MATCH_SCORE_OTHER)
  -        {
  -          context = 0;
  -        }
  -      }
  -      break;
  -    case XPath.MATCH_ATTRIBUTE:
  -      {
  -        argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -        opPos += 3;
  -        score = nodeTest(xpath, execContext, dtm, context, opPos, argLen, 
xpath.FROM_ATTRIBUTES);
  -        break;
  -      }
  -    case XPath.MATCH_ANY_ANCESTOR:
  -      {
  -        argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -        opPos += 3;
  -        score = xpath.MATCH_SCORE_NONE;
  -        while(-1 != context)
  -        {
  -          score = nodeTest(xpath, execContext, dtm, context, opPos, argLen, 
stepType);
  -          if(xpath.MATCH_SCORE_NONE != score)
  -            break;
  -          context = dtm.getParent(context);
  -        }
  -      }
  -      break;
  -    case XPath.MATCH_IMMEDIATE_ANCESTOR:
  -      argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -      opPos += 3;
  -      score = nodeTest(xpath, execContext, dtm, context, opPos, argLen, 
stepType);
  -      break;
  -    default:
  -      argLen = xpath.m_opMap[opPos+xpath.MAPINDEX_LENGTH+1]-3;
  -      opPos += 3;
  -      score = xpath.MATCH_SCORE_NONE;
  -      xpath.error(dtm.getNode( context ), 
XPATHErrorResources.ER_UNKNOWN_MATCH_OPERATION); //"unknown match operation!");
  -      break;
  -    }
  -    opPos += argLen;
  -    nextStepType = xpath.m_opMap[opPos];
  -    
  -    if(((score != xpath.MATCH_SCORE_NONE)) && (xpath.OP_PREDICATE == 
nextStepType))
  -    {
  -      score = xpath.MATCH_SCORE_OTHER;
  -      // Execute the xpath.predicates, but if we have an index, then we have 
  -      // to start over and do a search from the parent.  It would be nice 
  -      // if I could sense this condition earlier...
  -      try
  -      {
  -        execContext.setThrowFoundIndex(true);
  -        int startPredicates = opPos;
  -        opPos = startPredicates;
  -        nextStepType = xpath.m_opMap[opPos];
  -        while(xpath.OP_PREDICATE == nextStepType)
  -        {
  -          XObject pred = xpath.predicate(execContext, dtm.getNode( context 
), opPos);
  -          if(XObject.CLASS_NUMBER == pred.getType())
  -          {
  -            throw new FoundIndex();
  -          }
  -          else if(!pred.bool())
  -          {
  -            score = xpath.MATCH_SCORE_NONE;
  -            break; // from while(xpath.OP_PREDICATE == nextStepType)
  -          }
  -          opPos = xpath.getNextOpPos(opPos);
  -          nextStepType = xpath.m_opMap[opPos];
  -        }
  -        execContext.setThrowFoundIndex(false);
  -      }
  -      catch(FoundIndex fi)
  -      {
  -        // We have an index somewhere in our pattern.  So, we have 
  -        // to do a full search for our step, using the parent as 
  -        // context, then see if the current context is found in the 
  -        // node set.  Seems crazy, but, so far, it seems like the 
  -        // easiest way.
  -        execContext.setThrowFoundIndex(true);
  -        int parentContext = dtm.getParent(context);
  -        MutableNodeList mnl = step(xpath, execContext, 
dtm.getNode(dtm.getParent(parentContext)), startOpPos);
  -        int nNodes = mnl.getLength();
  -        score = xpath.MATCH_SCORE_NONE;
  -        for(int i = 0; i < nNodes; i++)
  -        {
  -          try
  -          {
  -            DTMProxy child = (DTMProxy)mnl.item(i);
  -            if((null != child) && (child.getDTMNodeNumber() == context))
  -            {
  -              score = xpath.MATCH_SCORE_OTHER;
  -              break;
  -            }
  -          }
  -          catch(ClassCastException cce) {}
  -        }
  -      }
  -    }
  -    // If we haven't found a score yet, or the test was 
  -    // negative, assign the score.
  -    if((scoreHolder[0] == xpath.MATCH_SCORE_NONE) || 
  -       (score == xpath.MATCH_SCORE_NONE))
  -      scoreHolder[0] = score;
  -    
  -    return (score == xpath.MATCH_SCORE_NONE) ? -1 : context;
  -  }
  -
  -  
  -  /**
  -   * Test a node to see if it matches the given node test.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  -   * @param opPos The current position in the xpath.m_opMap array.
  -   * @param len The length of the argument.
  -   * @param len The type of the step.
  -   * @returns score in an XNumber, one of MATCH_SCORE_NODETEST, 
  -   * MATCH_SCORE_NONE, MATCH_SCORE_OTHER, MATCH_SCORE_QNAME.
  -   */
  -  public double nodeTest(XPath xpath, XPathSupport execContext, DTM dtm, int 
context, int opPos, int argLen, int stepType)
  -    throws org.xml.sax.SAXException
  -  {
  -    double score;
  -    int testType = xpath.m_opMap[opPos];
  -    int nodeType = dtm.getNodeType(context);
  -    opPos++;
  -    switch(testType)
  -    {
  -    case XPath.NODETYPE_COMMENT:
  -      score = (Node.COMMENT_NODE == nodeType)
  -              ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -      break;
  -    case XPath.NODETYPE_TEXT:
  -      score = (((Node.CDATA_SECTION_NODE == nodeType) 
  -                || (Node.TEXT_NODE == nodeType)) &&
  -               (!execContext.shouldStripSourceNode(dtm.getNode( context ))))
  -              ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -      break;
  -    case XPath.NODETYPE_PI:
  -      if( (Node.PROCESSING_INSTRUCTION_NODE == nodeType) )
  -      {
  -        if(argLen == 2)
  -        {
  -          XString name = (XString)xpath.m_tokenQueue[xpath.m_opMap[opPos]];
  -          score = dtm.getNodeName(context).equals(name.str())
  -                  ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -        }
  -        else if(argLen == 1)
  -        {
  -          score = xpath.MATCH_SCORE_NODETEST;
  -        }
  -        else
  -        {
  -          score = xpath.MATCH_SCORE_NONE;
  -          xpath.error(XPATHErrorResources.ER_INCORRECT_ARG_LENGTH); //"Arg 
length of processing-instruction() node test is incorrect!");
  -        }
  -      }
  -      else
  -      {
  -        score = xpath.MATCH_SCORE_NONE;
  -      }
  -      break;
  -    case XPath.NODETYPE_NODE:
  -      if((Node.CDATA_SECTION_NODE == nodeType) 
  -         || (Node.TEXT_NODE == nodeType))
  -      {
  -        score = (!execContext.shouldStripSourceNode(dtm.getNode( context )))
  -                ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -      }
  -      else
  -      {
  -        score = xpath.MATCH_SCORE_NODETEST;
  -      }
  -      break;
  -    case XPath.NODETYPE_ROOT:
  -      score = ( (Node.DOCUMENT_FRAGMENT_NODE == nodeType) 
  -                || (Node.DOCUMENT_NODE == nodeType))
  -              ? xpath.MATCH_SCORE_OTHER : xpath.MATCH_SCORE_NONE;
  -      break;
  -      
  -    case XPath.NODENAME:
  -      {
  -        boolean test;
  -        int queueIndex = xpath.m_opMap[opPos];
  -        String targetNS = (queueIndex >= 0) ? 
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
  -                                              : null;
  -        opPos++;
  -        
  -        // From the draft: "Two expanded names are equal if they 
  -        // have the same local part, and either both have no URI or 
  -        // both have the same URI."
  -        // "A node test * is true for any node of the principal node type. 
  -        // For example, child::* will select all element children of the 
  -        // context node, and attribute::* will select all attributes of 
  -        // the context node."
  -        // "A node test can have the form NCName:*. In this case, the prefix 
  -        // is expanded in the same way as with a QName using the context 
  -        // namespace declarations. The node test will be true for any node 
  -        // of the principal type whose expanded name has the URI to which 
  -        // the prefix expands, regardless of the local part of the name."
  -        boolean isTotallyWild = (null == targetNS) && (xpath.m_opMap[opPos] 
== xpath.ELEMWILDCARD);
  -        boolean processNamespaces = execContext.getProcessNamespaces();
  -        boolean didMatchNS = false;
  -        if(!isTotallyWild && processNamespaces)
  -        {
  -          String contextNS = dtm.getNamespaceURI(context);
  -          if((null != targetNS) && (null != contextNS))
  -          {
  -            test = contextNS.equals(targetNS);
  -            didMatchNS = true;
  -          }
  -          else
  -          {
  -            test = (xpath.ELEMWILDCARD == queueIndex) || 
  -                   (((null == contextNS) || (contextNS.length() == 0)) &&
  -                    ((null == targetNS) || (targetNS.length() == 0)));
  -          }
  -        }
  -        else 
  -          test = true;
  -        
  -        queueIndex = xpath.m_opMap[opPos];
  -        String targetLocalName = (queueIndex >= 0) ? 
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
  -                                                     : null;
  -        
  -        if(!test)
  -        {
  -          score = xpath.MATCH_SCORE_NONE;
  -        }
  -        else
  -        {
  -          switch(nodeType)
  -          {
  -          case Node.ATTRIBUTE_NODE:
  -            if(stepType == xpath.FROM_ATTRIBUTES)
  -            {            
  -              
  -              if(xpath.ELEMWILDCARD == queueIndex)
  -              {
  -                String attrName = dtm.getNodeName(context);
  -                if(processNamespaces)
  -                {
  -                  score = (!((attrName.startsWith("xmlns:") 
  -                              || attrName.equals("xmlns"))))
  -                          ? xpath.MATCH_SCORE_NODETEST 
  -                            : xpath.MATCH_SCORE_NONE;
  -                }
  -                else
  -                {
  -                  score = xpath.MATCH_SCORE_NODETEST;
  -                }
  -              }
  -              else
  -              {
  -                String localAttrName 
  -                  =dtm.getLocalName(context);
  -                score = localAttrName.equals(targetLocalName)
  -                        ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -              }
  -            }
  -            else
  -            {
  -              score  = xpath.MATCH_SCORE_NONE;
  -            }
  -            break;
  -
  -          case Node.ELEMENT_NODE:
  -            if(stepType != xpath.FROM_ATTRIBUTES)
  -            {
  -              if(xpath.ELEMWILDCARD == queueIndex)
  -              {
  -                score = (didMatchNS ? 
  -                         xpath.MATCH_SCORE_NSWILD : 
xpath.MATCH_SCORE_NODETEST);
  -              }
  -              else
  -              {
  -                
  -                score = (dtm.getLocalName(context).equals(targetLocalName))
  -                        ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -              }
  -            }
  -            else
  -            {
  -              score  = xpath.MATCH_SCORE_NONE;
  -            }
  -            break;
  -            
  -          default:
  -            // Trying to match on anything else causes nasty bugs.
  -            score  = xpath.MATCH_SCORE_NONE;
  -            break;
  -
  -          } // end switch(nodeType)
  -        } // end if(test)
  -      } // end case xpath.NODENAME
  -      break;
  -    default:
  -      score  = xpath.MATCH_SCORE_NONE;
  -    } // end switch(testType)
  -    
  -    return score;    
  -    /*
  -    double score;
  -    int testType = xpath.m_opMap[opPos];
  -    int nodeType = dtm.getNodeType( context );
  -    opPos++;
  -    switch(testType)
  -    {
  -    case xpath.NODETYPE_COMMENT:
  -    score = (Node.COMMENT_NODE == nodeType)
  -    ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -    break;
  -    case xpath.NODETYPE_TEXT:
  -    score = (((Node.CDATA_SECTION_NODE == nodeType) 
  -    || (Node.TEXT_NODE == nodeType)) &&
  -    (!execContext.shouldStripSourceNode(dtm.getNode( context ))))
  -    ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -    break;
  -    case xpath.NODETYPE_PI:
  -    if( (Node.PROCESSING_INSTRUCTION_NODE == nodeType) )
  -    {
  -    if(argLen == 2)
  -    {
  -    XString name = (XString)xpath.m_tokenQueue[xpath.m_opMap[opPos]];
  -    
  -    score = dtm.getNodeName(context).equals(name.str())
  -    ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -    }
  -    else if(argLen == 1)
  -    {
  -    score = xpath.MATCH_SCORE_NODETEST;
  -    }
  -    else
  -    {
  -    score = xpath.MATCH_SCORE_NONE;
  -    xpath.error("Arg length of processing-instruction() node test is 
incorrect!");
  -    }
  -    }
  -    else
  -    {
  -    score = xpath.MATCH_SCORE_NONE;
  -    }
  -    break;
  -    case xpath.NODETYPE_NODE:
  -    if((Node.CDATA_SECTION_NODE == nodeType) 
  -    || (Node.TEXT_NODE == nodeType))
  -    {
  -    score = (!execContext.shouldStripSourceNode(dtm.getNode( context )))
  -    ? xpath.MATCH_SCORE_NODETEST : xpath.MATCH_SCORE_NONE;
  -    }
  -    else
  -    {
  -    score = xpath.MATCH_SCORE_NODETEST;
  -    }
  -    break;
  -    case xpath.NODETYPE_ROOT:
  -    score = ( (Node.DOCUMENT_FRAGMENT_NODE == nodeType) 
  -    || (Node.DOCUMENT_NODE == nodeType))
  -    ? xpath.MATCH_SCORE_OTHER : xpath.MATCH_SCORE_NONE;
  -    break;
  -    
  -    case xpath.NODENAME:
  -    {
  -    boolean test;
  -    int queueIndex = xpath.m_opMap[opPos];
  -    String targetNS = (queueIndex >= 0) ? 
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
  -    : null;
  -    opPos++;
  -    
  -    // From the draft: "Two expanded names are equal if they 
  -    // have the same local part, and either both have no URI or 
  -    // both have the same URI."
  -    // "A node test * is true for any node of the principal node type. 
  -    // For example, child::* will select all element children of the 
  -    // context node, and attribute::* will select all attributes of 
  -    // the context node."
  -    // "A node test can have the form NCName:*. In this case, the prefix 
  -    // is expanded in the same way as with a QName using the context 
  -    // namespace declarations. The node test will be true for any node 
  -    // of the principal type whose expanded name has the URI to which 
  -    // the prefix expands, regardless of the local part of the name."
  -    boolean isTotallyWild = (null == targetNS) && (xpath.m_opMap[opPos] == 
xpath.ELEMWILDCARD);
  -    boolean processNamespaces = execContext.getProcessNamespaces();
  -    boolean didMatchNS = false;
  -    if(!isTotallyWild && processNamespaces)
  -    {
  -    String contextNS = dtm.getNamespaceURI(context);
  -    if((null != targetNS) && (null != contextNS))
  -    {
  -    test = contextNS.equals(targetNS);
  -    didMatchNS = true;
  -    }
  -    else
  -    {
  -    test = (xpath.ELEMWILDCARD == queueIndex) || 
  -    (((null == contextNS) || (contextNS.length() == 0)) &&
  -    ((null == targetNS) || (targetNS.length() == 0)));
  -    }
  -    }
  -    else 
  -    test = true;
  -    
  -    queueIndex = xpath.m_opMap[opPos];
  -    String targetLocalName = (queueIndex >= 0) ? 
(String)xpath.m_tokenQueue[xpath.m_opMap[opPos]]
  -    : null;
  -    
  -    if(!test)
  -    {
  -    score = xpath.MATCH_SCORE_NONE;
  -    }
  -    else
  -    {
  -    switch(nodeType)
  -    {
  -    case Node.ATTRIBUTE_NODE:
  -    if(stepType == xpath.FROM_ATTRIBUTES)
  -    {            
  -    
  -    if(xpath.ELEMWILDCARD == queueIndex)
  -    {
  -    String attrName = dtm.getNodeName(context);
  -    if(processNamespaces)
  -    {
  -    score = (!((attrName.startsWith("xmlns:") 
  -    || attrName.equals("xmlns"))))
  -    ? xpath.MATCH_SCORE_NODETEST 
  -    : xpath.MATCH_SCORE_NONE;
  -    }
  -    else
  -    {
  -    score = xpath.MATCH_SCORE_NODETEST;
  -    }
  -    }
  -    else
  -    {
  -    String localAttrName = dtm.getLocalName(context);
  -    score = localAttrName.equals(targetLocalName)
  -    ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -    }
  -    }
  -    else
  -    {
  -    score  = xpath.MATCH_SCORE_NONE;
  -    }
  -    break;
  -
  -    case Node.ELEMENT_NODE:
  -    if(stepType != xpath.FROM_ATTRIBUTES)
  -    {
  -    if(xpath.ELEMWILDCARD == queueIndex)
  -    {
  -    score = (didMatchNS ? 
  -    xpath.MATCH_SCORE_NSWILD : xpath.MATCH_SCORE_NODETEST);
  -    }
  -    else
  -    {
  -    String elemName = dtm.getLocalName(context);
  -    score = (elemName.equals(targetLocalName))
  -    ? xpath.MATCH_SCORE_QNAME : xpath.MATCH_SCORE_NONE;
  -    }
  -    }
  -    else
  -    {
  -    score  = xpath.MATCH_SCORE_NONE;
  -    }
  -    break;
  -    
  -    default:
  -    // Trying to match on anything else causes nasty bugs.
  -    score  = xpath.MATCH_SCORE_NONE;
  -    break;
  -
  -    } // end switch(nodeType)
  -    } // end if(test)
  -    } // end case xpath.NODENAME
  -    break;
  -    default:
  -    score  = xpath.MATCH_SCORE_NONE;
  -    } // end switch(testType)
  -    
  -    return score;    
  -    */
  -  }
   }
  -
  +  
   /**
    * Override the createXLocatorHandler method.
    */
  
  
  

Reply via email to