santiagopg    2002/10/29 09:26:21

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Log:
  Fixed problem in DOMImpl$ChildrenIterator.getLast(). It now returns 0
  when the nodeset is empty.
  
  Revision  Changes    Path
  1.88      +16 -13    
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.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- DOMImpl.java      21 Oct 2002 20:40:31 -0000      1.87
  +++ DOMImpl.java      29 Oct 2002 17:26:20 -0000      1.88
  @@ -655,14 +655,13 @@
                if (node >= _firstAttributeNode) node = NULL;
                if (node != _startNode) _last = -1;
                _startNode = node;
  +
                if (_includeSelf) {
                    _currentChild = -1;
                }
                else {
  -                 if (hasChildren(node))
  -                     _currentChild = _offsetOrChild[node];
  -                 else
  -                     _currentChild = END;
  +                 _currentChild = hasChildren(node) ? _offsetOrChild[node] 
  +                     : END;
                }
                return resetPosition();
            }
  @@ -674,10 +673,9 @@
            if (_includeSelf) {
                if (node == -1) {
                    node = _startNode;
  -                 if (hasChildren(node))
  -                     _currentChild = _offsetOrChild[node];
  -                 else
  -                     _currentChild = END;
  +                 _currentChild = hasChildren(node) ? _offsetOrChild[node] 
  +                     : END;
  +
                    // IMPORTANT: The start node (parent of all children) is
                    // returned, but the node position counter (_position)
                    // should not be increased, so returnNode() is not called
  @@ -698,11 +696,16 @@
   
        public int getLast() {
            if (_last == -1) {
  -             _last = 1;
  -             int node = _offsetOrChild[_startNode];
  -             while ((node = _nextSibling[node]) != END) _last++;
  +             _last = 0;
  +
  +             int node;
  +             if ((node = _offsetOrChild[_startNode]) != END) {
  +                 do {
  +                     _last++;
  +                 } while ((node = _nextSibling[node]) != END);
  +             }
            }
  -         return(_last);
  +         return _last;
        }
   
       } // end of ChildrenIterator
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to