You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by tb...@debis.com on 2000/02/25 16:24:52 UTC

[Xerces-J] NodeIteratorImpl behavior

The NodeIteratorImpl class implements some strange behavior:

when you iterate the nodes using nextNode(), the first call of
previousNode() returns the same node as the last nextNode() call did.

This unexpected bahavior is only described in the source code and not
mentioned in the javadoc documentation (it is really hard to find). It
is unexpected too, if you rely on the documentation of
org.w3c.dom.traversal.NodeIterator .

I learned that it is caused by the fCurrentNode pointer which is being
_between_ two nodes. Is there a special reason that fCurrentNode does
point between two nodes (instead directly on the last returned node,
which would cause a more intuitive behavior)?

Ciao, Bens.
______________________________________________________________________
      _______
     / __   /____________ ______
    / /_/  // __  /     //     /\        Thomas Bensler
   /   ___// /_/ /      7  ___/_/       debis Systemhaus GEI
  / __    7  ___/  /   /___    /\     Lademannbogen 21-23
 / /_/   /  /  /  /   /       / /    D-22339 Hamburg
/_______/_____/__/___/_______/ /   fon: +49-40-5395-1879
\_______\_____\__\___\_______\/   net: tbensler@debis.com


Re: [Xerces-J] NodeIteratorImpl behavior

Posted by Arnaud Le Hors <le...@us.ibm.com>.
The reason for the iterator pointer to be between nodes is robustness.
NodeIterators are designed to keep working even under mutations of the
document tree being iterated. Having the pointer between nodes allows to
specify how it "floats" under the mutations.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

Re: [Xerces-J] NodeIteratorImpl behavior

Posted by Chih-Hsiang Chou <ch...@jtcsv.com>.
This behavior is normal and spec-compliant.  See the examples at:
http://www.w3.org/TR/DOM-Level-2/traversal.html#Iterator-Moving


Chih-Hsiang Chou
IBM Center for Java Technology - Silicon Valley
chchou@us.ibm.com

----- Original Message ----- 
From: <tb...@debis.com>
To: "Xerces-Dev (E-Mail)" <xe...@xml.apache.org>
Sent: Friday, February 25, 2000 7:24 AM
Subject: [Xerces-J] NodeIteratorImpl behavior


The NodeIteratorImpl class implements some strange behavior:

when you iterate the nodes using nextNode(), the first call of
previousNode() returns the same node as the last nextNode() call did.

This unexpected bahavior is only described in the source code and not
mentioned in the javadoc documentation (it is really hard to find). It
is unexpected too, if you rely on the documentation of
org.w3c.dom.traversal.NodeIterator .

I learned that it is caused by the fCurrentNode pointer which is being
_between_ two nodes. Is there a special reason that fCurrentNode does
point between two nodes (instead directly on the last returned node,
which would cause a more intuitive behavior)?

Ciao, Bens.
______________________________________________________________________
      _______
     / __   /____________ ______
    / /_/  // __  /     //     /\        Thomas Bensler
   /   ___// /_/ /      7  ___/_/       debis Systemhaus GEI
  / __    7  ___/  /   /___    /\     Lademannbogen 21-23
 / /_/   /  /  /  /   /       / /    D-22339 Hamburg
/_______/_____/__/___/_______/ /   fon: +49-40-5395-1879
\_______\_____\__\___\_______\/   net: tbensler@debis.com