OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   DOM traversal: NodeIterator + NodeFilter vs. TreeWalker

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: DOM traversal: NodeIterator + NodeFilter vs. TreeWalker
  • From: Razvan MIHAIU <mihaiu@mihaiu.name>
  • Date: Sun, 20 Mar 2005 11:49:14 +0200
  • User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)


Hi,



It seems to me that TreeWalker can very easily be simulated using 
NodeIterator with a Nodefilter. In Java my filter could look like this:

class CustomFilter implements NodeFilter
{
public short acceptNode(Node node)
{
…
}
}

Since the member function acceptNode() takes a node as its input that 
means that in this function I have access to all member functions of the 
Node object:

|*getFirstChild <cid:part1.09080503.07000705@mihaiu.name>*()
*getLastChild <cid:part2.00040703.07070505@mihaiu.name>*()
*getNextSibling <cid:part3.07060006.03010105@mihaiu.name>*||()
*getParentNode <cid:part4.05070703.04020808@mihaiu.name>*||()|

| a.s.o.|

| Using those functions I can fully access the DOM tree even if the 
object implementing NodeIterator is not aware of the tree-like structure 
of DOM. Isn’t this the “r|eason d'être”| for the TreeWalker interface ? 
(the fact that NodeIterator uses a ‘flat’ model for its DOM 
representation)||
Are there situation where a TreeWalker is more appropriate than a 
NodeIterator + NodeFilter ? Please provide an example.|

|


Regards,
Razvan|

|www.mihaiu.name <http://www.mihaiu.name/>
|

|
|





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS