Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Alpha 2

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' <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Alpha 2
  • Date: Wed, 02 Mar 2005 16:08:51 -0500

Michael Kay wrote:


That's a weird design. To count how many empty paragraphs there are, I
evaluate the expression count(//para[not(node())]), catch the exception, and
extract the number?

Can you explain the thinking?

It's not meant to count the paragraphs at all. The way to do that is node.query("//p").size(). I'm not even willing to promise that what comes out of getReturnValue() for node.query("count(//p)") is a number.

This mostly helps distinguish between problems that arise due to XPath syntax errors and problems that arise because the XPath expressions go outside the bounds of what XOM supports.

Possibly I should add a third exception to account for bugs in the XPath engine, though hopefully I'll have most of those resolved or worked around before shipping.

Once I'd added this distinction, it was pretty straight-forward to add the additional method without cluttering the primary interfaces. The immediate impetus was simply to help me track down a few bugs in Jaxen.

However, it's still my opinion that the primary use case for XPath operating over XOM is to select node-sets. It is not to do simple arithmetic or string manipulation. Java code is far more effective and efficient at these tasks, and the interface reflects that. Remember, XOM tries to make it easy to do the right thing, and make it hard to impossible to do the wrong thing. using XPath to do arithmetic and string manipulation inside a Java program is the wrong thing.

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