You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@apache.org on 2002/10/07 20:49:17 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/axes ExceptPathIterator.java IntersectPathIterator.java UnionPathIterator.java

mmidy       2002/10/07 11:49:17

  Modified:    java/src/org/apache/xpath/axes Tag: xslt20
                        ExceptPathIterator.java IntersectPathIterator.java
                        UnionPathIterator.java
  Log:
  Fix problems with intersect and except iterators.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +40 -20    xml-xalan/java/src/org/apache/xpath/axes/Attic/ExceptPathIterator.java
  
  Index: ExceptPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/ExceptPathIterator.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ExceptPathIterator.java	19 Sep 2002 21:43:30 -0000	1.1.2.2
  +++ ExceptPathIterator.java	7 Oct 2002 18:49:17 -0000	1.1.2.3
  @@ -87,25 +87,40 @@
   
       super();
     }
  -
  +  
     /**
  -   *  Get a cloned Iterator that is reset to the beginning
  -   *  of the query.
  -   * 
  -   *  @return A cloned NodeIterator set of the start of the query.
  -   * 
  -   *  @throws CloneNotSupportedException
  +   * Initialize the context values for this expression 
  +   * after it is cloned.
  +   *
  +   * @param execContext The XPath runtime context for this 
  +   * transformation.
      */
  -  public DTMIterator cloneWithReset() throws CloneNotSupportedException
  +  public void initIterators(int context)
     {
  +    try
  +    {
  +      if (null != m_exprs)
  +      {
  +        int n = m_exprs.length;
  +        DTMIterator newIters[] = new DTMIterator[n];
   
  -    ExceptPathIterator clone = (ExceptPathIterator) super.cloneWithReset();
  -
  -    clone.resetProximityPositions();
  -
  -    return clone;
  +        for (int i = 0; i < n; i++)
  +        {
  +          DTMIterator iter = m_exprs[i].asIterator(m_execContext, context);
  +          newIters[i] = iter;
  +          iter.setShouldCache(true);
  +          iter.nextNode();
  +        }
  +        m_iterators = newIters;
  +      }
  +    }
  +    catch (Exception e)
  +    {
  +      throw new org.apache.xml.utils.WrappedRuntimeException(e);
  +    }
     }
   
  +
     /**
      *  Returns the next node in the set and advances the position of the
      * iterator in the set. After a DTMIterator is created, the first call
  @@ -218,19 +233,24 @@
     	 accept = super.acceptNode(n);
     	if (accept == DTMIterator.FILTER_ACCEPT)
     	{
  -  	  try
  -  	  {
  -  	    DTMIterator iterator = (DTMIterator)m_iterators[1].clone();
  -  		int node = iterator.getCurrentNode();
  +  	    DTMIterator iterator = (DTMIterator)m_iterators[1];
  +  	    int node;
  +  	    if (iterator.isFresh())
  +  	      node = iterator.nextNode();
  +  	    else
  +  		  node = iterator.getCurrentNode();
     		while (node != DTM.NULL)
     		{
     			if (n ==  node)
  -  			return DTMIterator.FILTER_SKIP;
  +  			{
  +  			  iterator.reset();
  +  			  return DTMIterator.FILTER_SKIP;
  +  			}
     			node = iterator.nextNode();
     		}
  -  	  }
  -  	  catch (CloneNotSupportedException ex) {} 
  +  		iterator.reset();
     	}
  +  	
     	return accept;
     }
   
  
  
  
  1.1.2.2   +0 -18     xml-xalan/java/src/org/apache/xpath/axes/Attic/IntersectPathIterator.java
  
  Index: IntersectPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/IntersectPathIterator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- IntersectPathIterator.java	19 Sep 2002 21:43:30 -0000	1.1.2.1
  +++ IntersectPathIterator.java	7 Oct 2002 18:49:17 -0000	1.1.2.2
  @@ -87,24 +87,6 @@
   
       super();
     }
  -
  -  /**
  -   *  Get a cloned Iterator that is reset to the beginning
  -   *  of the query.
  -   * 
  -   *  @return A cloned NodeIterator set of the start of the query.
  -   * 
  -   *  @throws CloneNotSupportedException
  -   */
  -  public DTMIterator cloneWithReset() throws CloneNotSupportedException
  -  {
  -
  -    IntersectPathIterator clone = (IntersectPathIterator) super.cloneWithReset();
  -
  -    clone.resetProximityPositions();
  -
  -    return clone;
  -  }
     
     /**
      *  Test whether a specified node is visible in the logical view of a
  
  
  
  1.26.4.1.2.2 +12 -1     xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
  
  Index: UnionPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
  retrieving revision 1.26.4.1.2.1
  retrieving revision 1.26.4.1.2.2
  diff -u -r1.26.4.1.2.1 -r1.26.4.1.2.2
  --- UnionPathIterator.java	6 Sep 2002 15:06:06 -0000	1.26.4.1.2.1
  +++ UnionPathIterator.java	7 Oct 2002 18:49:17 -0000	1.26.4.1.2.2
  @@ -105,7 +105,18 @@
     public void setRoot(int context, Object environment)
     {
       super.setRoot(context, environment);
  -
  +    initIterators(context); 
  +  }
  +  
  +   /**
  +   * Initialize the context values for this expression 
  +   * after it is cloned.
  +   *
  +   * @param execContext The XPath runtime context for this 
  +   * transformation.
  +   */
  +  public void initIterators(int context)
  +  {
       try
       {
         if (null != m_exprs)
  
  
  

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