Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] New XPath issue: what to do with non-nodes?

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: Nils_Kilden-Pedersen AT Countrywide.Com
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] New XPath issue: what to do with non-nodes?
  • Date: Wed, 12 Jan 2005 16:38:49 -0500

Nils_Kilden-Pedersen AT Countrywide.Com wrote:


I'm wondering if that'll limit the usefulness of an XOM XPath implementation to be close to zero?

I tend to doubt it. The purpose here is simply to query an XML document. Restricting to XPath expressions that return node-sets seems to solve that pretty well.

XPath expressions that don't return node-sets tend to get used heavily in XSLT stylesheets, but that's a very different use-case. The assumption here is you can do all the arithmetic and logic you need to do in Java. The only thing I've ever needed from XPath in Java is a quick, convenient way to say "give me all the nodes that match a certain condition". XPath functionality beyond this is quite limited. I suppose you could ask, "how many nodes match this condition?", "is there a node that matches this condition?", or "what is the string-value of the first node that matches this condition?" but these are all quite easy to do in Java as well. The only thing that's hard to do in Java and easy to do in XPath is find the nodes.

Note that you can use doubles, strings, floats and the full XPath expression syntax in predicates to choose those nodes. XOM is simply limiting the ultimate return type.

3. Return Double, String, Boolean as Text?

It's been suggested before. What it would really take to convince me are some solid use cases for this. What XPath 1.0 expressions might you use in a Java program that do not return node-sets?

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