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: John Cowan <cowan AT ccil.org>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: 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 09:13:17 -0500

Elliotte Harold scripsit:

> Given that XOM is written in Java, type-safe results are simply not an
> option. The language doesn't support them. There's just no way in Java
> to return a type-safe list that can potentially contain any or all of
> node-sets, doubles, booleans, and strings.

Arrgh.

(sinking deeper and deeper into the quicksands of absolute inertia)

IT DOESN'T HAVE TO.

The value of an XPath 1.0 expression is any ONE of the following:

1) A double
2) A string
3) A boolean
4) A list of nodes.

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().

No lists containing things other than nodes are required.

This is orthogonal to the question of how to handle XPath nodes
that contain multiple XOM Text objects.

--
Time alone is real John Cowan <cowan AT ccil.org>
the rest imaginary http://www.reutershealth.com
like a quaternion --phma http://www.ccil.org/~cowan




Archive powered by MHonArc 2.6.24.

Top of Page