jkesselm 02/05/16 10:06:06 Modified: java/src/org/apache/xml/dtm/ref DTMDefaultBaseIterators.java Log: Bugzilla 8324. This should have been checked into the main branch. Revision Changes Path 1.13 +18 -14 xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java Index: DTMDefaultBaseIterators.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- DTMDefaultBaseIterators.java 10 Apr 2002 20:33:16 -0000 1.12 +++ DTMDefaultBaseIterators.java 16 May 2002 17:06:06 -0000 1.13 @@ -1122,7 +1122,7 @@ /** * Iterator that returns preceding nodes of a given node. * This includes the node set {root+1, start-1}, but excludes - * all ancestors. + * all ancestors, attributes, and namespace nodes. */ private class PrecedingIterator extends InternalAxisIteratorBase { @@ -1231,19 +1231,23 @@ */ public int next() { - - int node = _currentNode + 1; - - if ((_sp >= 0) && (node < _stack[_sp])) - { - return returnNode(makeNodeHandle(_currentNode = node)); - } - else - { - _currentNode = node; // skip ancestor - - return --_sp >= 0 ? next() : NULL; - } + // Bugzilla 8324: We were forgetting to skip Attrs and NS nodes. + // Also recoded the loop controls for clarity and to flatten out + // the tail-recursion. + for(++_currentNode; + _sp>=0; + ++_currentNode) + { + if(_currentNode < _stack[_sp]) + { + if(_type(_currentNode) != ATTRIBUTE_NODE && + _type(_currentNode) != NAMESPACE_NODE) + return returnNode(makeNodeHandle(_currentNode)); + } + else + --_sp; + } + return NULL; } // redefine DTMAxisIteratorBase's reset
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]