xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mm...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xpath/axes LocPathIterator.java OneStepIterator.java PredicatedNodeTest.java
Date Tue, 06 Nov 2001 19:25:53 GMT
mmidy       01/11/06 11:25:53

  Modified:    java/src/org/apache/xpath/axes LocPathIterator.java
                        OneStepIterator.java PredicatedNodeTest.java
  Log:
  Bugzilla 4638: When we are in a subcontext we need to clip off the predicate when evaluating.
If not, we end up with the wrong nodeset. This also relates to test position68.
  
  Revision  Changes    Path
  1.33      +26 -6     xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
  
  Index: LocPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- LocPathIterator.java	2001/08/07 19:16:43	1.32
  +++ LocPathIterator.java	2001/11/06 19:25:53	1.33
  @@ -536,7 +536,7 @@
         return m_last;
       else if(null == m_cachedNodes || !m_foundLast)
       {
  -      m_last = getLastPos(m_execContext);
  +      m_last = findLastPos(m_execContext);
       }
       else
       {
  @@ -906,8 +906,8 @@
     {
       m_last = last;
     }
  -
  -  /**
  +  
  +   /**
      * Get the index of the last node that can be itterated to.
      * This probably will need to be overridded by derived classes.
      *
  @@ -917,6 +917,19 @@
      */
     public int getLastPos(XPathContext xctxt)
     {
  +    return getLength();
  +  }
  +    
  +  /**
  +   * Get the index of the last node that can be itterated to.
  +   * This probably will need to be overridded by derived classes.
  +   *
  +   * @param xctxt XPath runtime context.
  +   *
  +   * @return the index of the last node that can be itterated to.
  +   */
  +  public int findLastPos(XPathContext xctxt)
  +  {
       int savedPos;
       if(null != m_cachedNodes)
         savedPos = m_cachedNodes.getCurrentPos();
  @@ -939,10 +952,17 @@
       catch (CloneNotSupportedException cnse)
       {
         return -1;
  +    }
  +
  +    // We want to clip off the last predicate, but only if we are a sub 
  +    // context node list, NOT if we are a context list.  See pos68 test, 
  +    // also test against bug4638.
  +    int predCount = clone.getPredicateCount();
  +    if(predCount > 0 && this == m_execContext.getSubContextList())
  +    {
  +      // Don't call setPredicateCount, because it clones and is slower.
  +      clone.m_predCount = predCount - 1;
       }
  -    // %REVIEW% Commented this out, as it was messing up pos68 test. count-1?
  -    // System.out.println("clone.getPredicateCount(): "+clone.getPredicateCount());
  -    // clone.setPredicateCount(clone.getPredicateCount() - 1);
   
       int next;
   
  
  
  
  1.7       +9 -3      xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java
  
  Index: OneStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OneStepIterator.java	2001/08/07 19:16:43	1.6
  +++ OneStepIterator.java	2001/11/06 19:25:53	1.7
  @@ -152,7 +152,8 @@
           xctxt.pushCurrentNode(root);
           clone.setRoot(root, xctxt);
   
  -        clone.setPredicateCount(predicateIndex);
  +        // clone.setPredicateCount(predicateIndex);
  +        clone.m_predCount = predicateIndex;
   
           // Count 'em all
           int count = 1;
  @@ -201,7 +202,7 @@
      *
      * @return the number of nodes in this node list.
      */
  -  public int getLastPos(XPathContext xctxt)
  +  public int findLastPos(XPathContext xctxt)
     {
       if(!isReverseAxes())
         return super.getLastPos(xctxt);
  @@ -216,7 +217,12 @@
         xctxt.pushCurrentNode(root);
         clone.setRoot(root, xctxt);
   
  -      clone.setPredicateCount(this.getPredicateCount() - 1);
  +      int predCount = clone.getPredicateCount();
  +      if(predCount > 0 && this == m_execContext.getSubContextList())
  +      {
  +        // Don't call setPredicateCount, because it clones and is slower.
  +        clone.m_predCount = predCount - 1;
  +      }
   
         // Count 'em all
         // count = 1;
  
  
  
  1.9       +7 -1      xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java
  
  Index: PredicatedNodeTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PredicatedNodeTest.java	2001/07/30 17:32:32	1.8
  +++ PredicatedNodeTest.java	2001/11/06 19:25:53	1.9
  @@ -87,6 +87,9 @@
   
       return clone;
     }
  +  
  +  // Only for clones for findLastPos.  See bug4638.
  +  protected int m_predCount = -1;
   
     /**
      * Get the number of predicates that this walker has.
  @@ -95,7 +98,10 @@
      */
     public int getPredicateCount()
     {
  -    return (null == m_predicates) ? 0 : m_predicates.length;
  +    if(-1 == m_predCount)
  +      return (null == m_predicates) ? 0 : m_predicates.length;
  +    else
  +      return m_predCount;
     }
   
     /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message