You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/09/25 21:45:03 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMImpl.java NodeIteratorBase.java

morten      01/09/25 12:45:03

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
                        NodeIteratorBase.java
  Log:
  A fix to ensure that the current position of any iterator is always kept
  updated. The returnNode() method of the NodeIteratorBase base class updates
  the _position variable for each returned node. This method should be called
  by the next() method of any iterator, except for next() methods that call
  super.next() (because this method calls returnNode() and so _position
  would be incremented twice or more for one returned node).
  PR:		bugzilla 3816
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.35      +15 -12    xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- DOMImpl.java	2001/09/25 15:57:22	1.34
  +++ DOMImpl.java	2001/09/25 19:45:03	1.35
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.34 2001/09/25 15:57:22 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.35 2001/09/25 19:45:03 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -857,7 +857,8 @@
   	public int next() {
   	    int node;
   	    while ((node = super.next()) != NULL) {
  -		if (_type[node] == _nodeType) return node;
  +		if (_type[node] == _nodeType) return(node);
  +		_position--;
   	    }
   	    return END;
   	}
  @@ -1007,9 +1008,9 @@
            
   	public int next() {
   	    int node;
  -	    while ((node = super.next()) != NULL && _type[node] != _nodeType) {
  -	    }
  -	    return returnNode(node);
  +	    while ((node = super.next()) != NULL && _type[node] != _nodeType)
  +		_position--;
  +	    return(node);
   	}
   
       } // end of PrecedingSiblingIterator
  @@ -1069,7 +1070,8 @@
   	    // Advance node index and check if all nodes have been returned.
   	    while (++_node < _startNode) {
   		// Check if we reached one of the base node's ancestors
  -		if ((_sp < 0) || (_node < _stack[_sp])) return(_node);
  +		if ((_sp < 0) || (_node < _stack[_sp]))
  +		    return returnNode(_node);
   		// Anvance past the next ancestor node
   		_sp--;
   	    }
  @@ -1109,8 +1111,8 @@
            
   	public int next() {
   	    int node;
  -	    while ((node = super.next()) != NULL && _type[node] != _nodeType) {
  -	    }
  +	    while ((node = super.next()) != NULL && _type[node] != _nodeType)
  +		_position--; 
   	    return node;
   	}
   
  @@ -1166,7 +1168,8 @@
   	public int next() {
   	    int node;
   	    while ((node = super.next()) != NULL) {
  -		if (_type[node] == _nodeType) return node;
  +		if (_type[node] == _nodeType) return(node);
  +		_position--;
   	    }
   	    return END;
   	}
  @@ -1256,8 +1259,8 @@
   	public int next() {
   	    int node;
   	    while ((node = super.next()) != NULL) {
  -		if (_type[node] == _nodeType)
  -		    return returnNode(node);
  +		if (_type[node] == _nodeType) return(node);
  +		_position--;
   	    }
   	    return(NULL);
   	}
  @@ -1395,7 +1398,7 @@
   		    } while ((pos<_pos) && (child = _nextSibling[child]) != 0);
   		}
   
  -		if (node == child) return node;
  +		if (node == child) return node; 
   	    }
   	    return(END);
   	}
  
  
  
  1.4       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java
  
  Index: NodeIteratorBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NodeIteratorBase.java	2001/09/13 08:08:38	1.3
  +++ NodeIteratorBase.java	2001/09/25 19:45:03	1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: NodeIteratorBase.java,v 1.3 2001/09/13 08:08:38 morten Exp $
  + * @(#)$Id: NodeIteratorBase.java,v 1.4 2001/09/25 19:45:03 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -68,7 +68,7 @@
   
   public abstract class NodeIteratorBase implements NodeIterator {
       private int _last = -1;
  -    private int _position = 0;
  +    protected int _position = 0;
   
       protected int _markedNode;
       protected int _startNode = NodeIterator.END;
  
  
  

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