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: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: John Cowan <cowan AT ccil.org>, xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] New XPath issue: what to do with non-nodes?
  • Date: Thu, 13 Jan 2005 11:37:04 -0800

John Cowan wrote:


There is no problem in handling this pattern in a type-safe way.
You just need an XPathResult class with four extraction methods:
double doubleValue(), String stringValue(), boolean booleanValue(),
and Nodes nodelistValue().

Just for illustration: Nux has an interface "ResultSequence". Its intent corresponds to such an XPathResult class.
Currently it only has methods "Nodes toNodes()" (corresponding to nodeListValue()), and "Node next()" to get the next node of the sequence. I have left out methods doubleValue(), String stringValue(), boolean booleanValue() on ResultSequence because the same behaviour can be achieved via

ResultSequence results = xquery.execute(contextNode);
String s = results.next().getValue();
double d = Double.parseDouble(results.next().getValue())
boolean b = new Boolean(results.next().getValue()).booleanValue()
Nodes nodes = results.toNodes();

To me this seems only marginally more complex, so convenience methods for this (or slight variations on it) seemed to add more API complexity (and correspondingly obscure understanding) than they'd eliminate.





Archive powered by MHonArc 2.6.24.

Top of Page