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: Michael Kay <mike AT saxonica.com>
  • Cc: xom-interest AT lists.ibiblio.org, 'John Cowan' <jcowan AT reutershealth.com>, Nils_Kilden-Pedersen AT Countrywide.Com
  • Subject: Re: [XOM-interest] New XPath issue: what to do with non-nodes?
  • Date: Thu, 13 Jan 2005 08:50:33 -0500

Michael Kay wrote:

Elliotte Harold scripsit:


What XPath 1.0 expressions might you use in a Java program that do not return node-sets?

I can't think of any.


I think you're assuming a scenario where users like to code in Java and only
use XPath as a last resort. There's another scenario where users hate coding
in Java (all those fiddly iterators) and like to use XPath as much as
possible.

I think that's accurate. I assume such users will use XSLT or XQuery rather than Java+XOM. I hear a lot more pain from Java programmers who can't get a handle on XSLT than from XSLT programmers who can't get a handle on Java.

There's also a scenario where the Java application with embedded
XPath is machine-generated.

sum(*[@code=23]/@value)
lang('de')
count(../following-sibling::foo) = 0

That's an interesting use case. It's not one I've encountered before. Can you provide some more information about such machines? i.e. is there anywhere I can look at some such software to see what they're doing, what their needs are, how useful they are, and so forth? Personally, I don't think I've ever written software that generated XPaths.

I was thinking about this yesterday when I noticed dom4j had a function to generate a location path for any given node. I've seen several people ask for this in various contexts, and I thought I might write a sample program that did this, though I wasn't going to add it to the core like dom4j did. However, that expression always returns a node-set; and it's the only example of machine generated XPath I can think of right now.

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