Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Tree walking

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Johannes Döbler <jd AT aztecrider.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Tree walking
  • Date: Thu, 19 Sep 2002 17:38:12 +0200

Visitor is straightforward to implement (see below)
Then the first NodeVisitor example could be the Serializer (with the pleasant side-effect that the ugly method "public void write(TreeNode node) throws IOException"
would vanish).

Problem: which types of exception is a NodeVisitor allowed to throw?

Johannes

------------------

public interface NodeVisitor
{
public void visitDocument(Document document);
public void visitElement(Element element);
public void visitText(Text text)
...
}

and Node gets a method

public abstract void accept(NodeVisitor visitor);

with implementations

Element.accept(NodeVisitor visitor)
{
visitor.visitElement(this);
}

etc. (ok, you knew that already :-))


At 10:33 AM +0200 9/19/02, Laurent Bihanic wrote:


- Tree walking: XOM should provide classes to ease walking document trees (TreeWalker, Visitor...).

Agreed. Right now I'm focusing on the core, and trying to make that solid. Tree walking utility classes will probably come later (or a third party could implement them separately).
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest





Archive powered by MHonArc 2.6.24.

Top of Page