Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM 1.1: XPath

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: "'Bradley S. Huffman'" <hip AT a.cs.okstate.edu>, xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM 1.1: XPath
  • Date: Mon, 10 Jan 2005 10:00:50 -0800

Everybody already understands XPath's adjacent text semantics since the beginning of this thread.
But that's not the question. The question is why would output 1 *always* be the "right" thing, as opposed to output 2 or 3, or even output 4 (which is returning the first Text node as DOM XPath seems to do, as noted by Mike). In other words how to map XPath results on output to XOM nodes.

On Jan 10, 2005, at 2:57 AM, Elliotte Harold wrote:

Wolfgang Hoschek wrote:

Well, it would be helpful if you could state why this is "clearly correct".

The XPath data model does not allow adjacent text nodes. According to the spec,

"As much character data as possible is grouped into each text node: a text node never has an immediately following or preceding sibling that is a text node."

Getting this right is critical for making sure that positional predicates do what you expect, and not introducing off-by-one-or-more errors. There are other issues as well, but positional predicates are the ones that are going to come up most frequently.

Hmm, looking at the spec I see one other tricky bit we have to watch out for:

"A text node always has at least one character of data."

In other words, empty Text objects cannot be selected. That's going to be tricky to implement. Time to write a test case.


I'll add the following method to the next Nux release candidate, unless a convincing argument can be made that one can easily do without it:

I suspect this method might be useful in and of itself, irrespective of XPath issues. I'd say go ahead and add it.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim


-----------------------------------------------------------------------
Wolfgang Hoschek | email: whoschek AT lbl.gov
Distributed Systems Department | phone: (415)-533-7610
Berkeley Laboratory | http://dsd.lbl.gov/~hoschek/
-----------------------------------------------------------------------





Archive powered by MHonArc 2.6.24.

Top of Page