Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Siblings

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Bradley S. Huffman" <hip AT a.cs.okstate.edu>
  • To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Cc: hip AT cs.okstate.edu
  • Subject: Re: [XOM-interest] Siblings
  • Date: Tue, 22 Oct 2002 20:23:26 -0500

Elliotte Rusty Harold writes:
> At 6:29 AM -0700 10/22/02, Michael Fitzgerald wrote:
> >Likewise, I think
> >
> >nu.xom.Node getNextSibling()
> >nu.xom.Node getPreviousSibling()
>
>
> You know, these methods have bothered me for a while, and I think
> I've finally put my finger on the problem, and maybe come up with a
> solution. The problem is that they don't really fit well into XOM's
> mostly indexed style of access.

Works great with linked nodes like Xerces, not so good in List implementations
like JDOM, dom4j, and XOM.

> Perhaps instead, both of these methods should be replaced with the
> following:
>
> public int position()
>
> (Alternate names: indexOf(), index())

Or moved to ParentNode as getNextSibling(Node)/getPreviousSibling(Node)
since in this model Nodes don't have siblings unless they have a parent.
For performance the parent could keep last index fetched.

> Open questions (assuming this is a good idea at all):
>
> 1. What should position() return if the parent is null? 0? -1? throw
> an exception?

Or put position(Node) in ParentNode and throw a exception if parent the Node
not equal to ParentNode, otherwise it is guaranteed to return a valid index.

Brad




Archive powered by MHonArc 2.6.24.

Top of Page