xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From il...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xpath/axes LocPathIterator.java PredicatedNodeTest.java OneStepIterator.java
Date Fri, 22 Nov 2002 17:30:51 GMT
ilene       2002/11/22 09:30:51

  Modified:    java/src/org/apache/xpath/axes Tag: xslt20
                        LocPathIterator.java PredicatedNodeTest.java
                        OneStepIterator.java
  Log:
  Just a small foray into merging main branch with xslt20 branch.  I applied 
  patches for bugs#13501,14365,14368.  This should fix conformance tests:
  position104-109 on the xslt20 branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.35.2.1.2.2 +20 -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.35.2.1.2.1
  retrieving revision 1.35.2.1.2.2
  diff -u -r1.35.2.1.2.1 -r1.35.2.1.2.2
  --- LocPathIterator.java	11 Nov 2002 19:51:17 -0000	1.35.2.1.2.1
  +++ LocPathIterator.java	22 Nov 2002 17:30:50 -0000	1.35.2.1.2.2
  @@ -522,15 +522,26 @@
      */
     public int getLength()
     {      
  +    // Tell if this is being called from within a predicate.
     	boolean isPredicateTest = (this == m_execContext.getSubContextList());
  +
  +    // And get how many total predicates are part of this step.
     	int predCount = getPredicateCount();
     	
  -  	if(-1 != m_length && !isPredicateTest)
  +    // If we have already calculated the length, and the current predicate 
  +    // is the first predicate, then return the length.  We don't cache 
  +    // the anything but the length of the list to the first predicate.
  +    if (-1 != m_length && isPredicateTest && m_predicateIndex < 1)
     		return m_length;
     	
  -  	if(m_foundLast)
  +    // I'm a bit worried about this one, since it doesn't have the 
  +    // checks found above.  I suspect it's fine.  -sb
  +    if (m_foundLast)
     		return m_pos;
     		
  +    // Create a clone, and count from the current position to the end 
  +    // of the list, not taking into account the current predicate and 
  +    // predicates after the current one.
       int pos = (m_predicateIndex >= 0) ? getProximityPosition() : m_pos;
                 
       LocPathIterator clone;
  @@ -547,10 +558,13 @@
       // 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.
  -    if(predCount > 0 && isPredicateTest)
  +    if (predCount > 0 && isPredicateTest)
       {
         // Don't call setPredicateCount, because it clones and is slower.
  -      clone.m_predCount = predCount - 1;
  +      clone.m_predCount = m_predicateIndex;
  +      // The line above used to be:
  +      // clone.m_predCount = predCount - 1;
  +      // ...which looks like a dumb bug to me. -sb
       }
   
       int next;
  @@ -560,7 +574,7 @@
         pos++;
       }
       
  -    if(!isPredicateTest)
  +    if (isPredicateTest && m_predicateIndex < 1)
         m_length = pos;
       
       return pos;
  @@ -1052,5 +1066,5 @@
     	}
     }
   
  -  
  +  
   }
  
  
  
  1.11.2.1.2.1 +6 -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.11.2.1
  retrieving revision 1.11.2.1.2.1
  diff -u -r1.11.2.1 -r1.11.2.1.2.1
  --- PredicatedNodeTest.java	14 Aug 2002 20:06:57 -0000	1.11.2.1
  +++ PredicatedNodeTest.java	22 Nov 2002 17:30:50 -0000	1.11.2.1.2.1
  @@ -366,7 +366,12 @@
             // course of itteration, then we know there can be no more true 
             // occurances of this predicate, so flag that we're done after 
             // this.
  -          if(m_predicates[i].isStableNumber())
  +          //
  +          // bugzilla 14365
  +          // We can't set m_foundLast = true unless we're sure that -all-
  +          // remaining parameters are stable, or else last() fails. Fixed so
  +          // only sets m_foundLast if on the last predicate
  +          if(m_predicates[i].isStableNumber() && i == nPredicates - 1)
             {
               m_foundLast = true;
             }
  
  
  
  1.8.4.1.2.1 +57 -0     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.8.4.1
  retrieving revision 1.8.4.1.2.1
  diff -u -r1.8.4.1 -r1.8.4.1.2.1
  --- OneStepIterator.java	14 Aug 2002 20:06:57 -0000	1.8.4.1
  +++ OneStepIterator.java	22 Nov 2002 17:30:51 -0000	1.8.4.1.2.1
  @@ -194,6 +194,63 @@
     }
   
     /**
  +   *  The number of nodes in the list. The range of valid child node indices
  +   * is 0 to <code>length-1</code> inclusive.
  +   *
  +   * @return The number of nodes in the list, always greater or equal to zero.
  +   */
  +  public int getLength()
  +  {
  +    if(!isReverseAxes())
  +      return super.getLength();
  +      
  +    // Tell if this is being called from within a predicate.
  +    boolean isPredicateTest = (this == m_execContext.getSubContextList());
  +
  +    // And get how many total predicates are part of this step.
  +    int predCount = getPredicateCount();
  +   
  +    // If we have already calculated the length, and the current predicate 
  +    // is the first predicate, then return the length.  We don't cache 
  +    // the anything but the length of the list to the first predicate.
  +    if (-1 != m_length && isPredicateTest && m_predicateIndex < 1)
  +       return m_length;      
  +
  +    int count = 0;
  +    
  +    XPathContext xctxt = getXPathContext();
  +    try
  +    {
  +      OneStepIterator clone = (OneStepIterator) this.cloneWithReset();
  +      
  +      int root = getRoot();
  +      xctxt.pushCurrentNode(root);
  +      clone.setRoot(root, xctxt);
  + 
  +      clone.m_predCount = m_predicateIndex;
  +
  +      int next;
  +
  +      while (DTM.NULL != (next = clone.nextNode()))
  +      {
  +        count++;
  +      }
  +    }
  +    catch (CloneNotSupportedException cnse)
  +    {
  +       // can't happen
  +    }
  +    finally
  +    {
  +      xctxt.popCurrentNode();
  +    }
  +    if (isPredicateTest && m_predicateIndex < 1)
  +      m_length = count;    
  +      
  +    return count;
  +  }
  +
  +  /**
      * Count backwards one proximity position.
      *
      * @param i The predicate index.
  
  
  

---------------------------------------------------------------------
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