Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Query: Any way to determine ordering of two nodes?

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Mike Colbert <mbcolbert AT yahoo.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Query: Any way to determine ordering of two nodes?
  • Date: Wed, 15 Mar 2006 04:37:35 -0800 (PST)

Here's what I would do (good or bad, it seems okay):

First, determine if one is an ancestor of the other. If so, no brainer.

Next, determine what the common ancestor of the two nodes is. From there,
the node in the subtree to the left precedes the other node in document
order.

I may be oversimplifying, but I think that should basically work without too
much overhead.

Mike


Gregory Garretson wrote:
Hello,

I've been using XOM for a few months now, and I really like it. I find it
useful, simple, and elegant. However, occasionally I come across something I
can't find an obvious way to do. Here's one:

Given two nodes in the same document, Is there a good way to determine which
of the nodes precedes the other in normal document order? Assuming they are
non-identical, of course. The API, FAQ, and tutorial haven't given me any
clues. I suspect you could do it with XPath, but there's that restriction
about query() only returning a nodeset.

I can think of very cumbersome ways of doing it, but I'm looking for
something that will be relatively efficient. Maybe I've missed something
obvious. Any suggestions would be very welcome.

Thanks,
Gregory Garretson













Archive powered by MHonArc 2.6.24.

Top of Page