xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralf Pfeiffer <rpfei...@apache.org>
Subject Re: Implementation of previousNode method in TreeWalkerImp
Date Wed, 05 Jan 2000 21:26:13 GMT
Michel,
This was indeed a bug/oversight. Thank you for finding it and posting an
excellent fix.
I have put in your fix, tested it and committed it.
Thanks again,
-rip

Michel Benhamou wrote:

> When testing the personal.xml file in TreeWalkerView, the previous node
> command doesn't give back the right node. It seems there is a mistake in
> the implementation of previousNode method in TreeWalkerImp class. If i'm
> not missing something, the correct code would be
>   public Node               previousNode() {
>         Node result;
>
>         if (fCurrentNode == null) return null;
>
>         // get sibling
>         result = getPreviousSibling(fCurrentNode);
>         if (result == null) {
>             result = getParentNode(fCurrentNode);
>             if (result != null) {
>                 fCurrentNode = result;
>                 return fCurrentNode;
>             }
>             return null;
>         }
>
>         // get the lastChild of result.
>
>         Node lastChild  = getLastChild(result);
>
> //modification
>         Node prev = lastChild ;
>         while (lastChild != null) {
>           prev = lastChild ;
>           lastChild = getLastChild(prev) ;
>         }
>
>         lastChild = prev ;
> // end modification
>
>         // if there is a lastChild which passes filters return it.
>         if (lastChild != null) {
>             fCurrentNode = lastChild;
>             return fCurrentNode;
>         }
>
>         // otherwise return the previous sibling.
>         if (result != null) {
>             fCurrentNode = result;
>             return fCurrentNode;
>         }
>
>         // otherwise return null.
>         return null;
>     }
>
> And indeed it gives the good result in TreeWalkerView test.


Mime
View raw message