Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] RE: XPath support in XOM

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Hallvard Trætteberg <hal AT idi.ntnu.no>, xom-interest <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: Re: [XOM-interest] RE: XPath support in XOM
  • Date: Mon, 10 Jan 2005 08:53:50 -0500

Hallvard Trætteberg wrote:

A better (and less constructed) example is an application which had one Text
node for each line of text, inside some Element (the Text nodes were
populated from and synchronized with a JList component, the document
structure was shown in a JTree) When using XPath I really wanted to match
the individual Text nodes, not the text as a whole. You can argue that this
doesn't follow the XPath model, but since I controlled the XML document and
object structure, I wanted this behavior (it was a feature, not a bug).


It seems to me that this case uses Java object boundaries to infer structure that is not actually present in the XML document. Therefore you want to use XPath to perform queries over this structure not expressed in XML.

The principle XOM is going to follow here is that significant structure should be marked up with XML, not with extra-XML information such as object boundaries. For more of my thoughts on this, see

http://www.cafeconleche.org/books/effectivexml/chapters/11.html

That being said, it is possible use XPath to query non-XML structures. For instance, Jaxen 1.1 includes an XPath binding to JavaBeans. You can plug other such custom bindings into Jaxen. The Jaxen 1.1 XOM binding currently has exactly the behavior you want.

I've just finished writing a binding to Jaxen that gives me the behavior I want -- no contiguous text nodes despite adjacent Text objects. I suspect this is what I'm going to push out with the next development release of XOM 1.1, and which will be the implementation used by the query method in Node. However, this shouldn't prohibit alternative bindings that implement slightly different models.

FYI, I'm not wedded to Jaxen for the future. I'm seriously considering using Saxon 6.5.3+fixes. However, I suspected that I could get a basic implementation working with Jaxen a lot faster since the code base seems much simpler, and since you had already done a lot of the basic work to integrate XOM with Jaxen.

--
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




Archive powered by MHonArc 2.6.24.

Top of Page