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: John Cowan <jcowan AT reutershealth.com>
  • Cc: Elliotte Harold <elharo AT metalab.unc.edu>, xom-interest AT lists.ibiblio.org, Nils_Kilden-Pedersen AT Countrywide.Com
  • Subject: Re: [XOM-interest] New XPath issue: what to do with non-nodes?
  • Date: Wed, 12 Jan 2005 14:27:12 -0800


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

I can't think of any.


See the example below:

public Nodes query(String xpath) throws ToBeDeterminedException
public Nodes query(String xpath, Map namespaceBindings)
throws ToBeDeterminedException


It occurred to me that you could handle expressions returning a string,
boolean, or number by wrapping the result in a specially-created Text node.
This would be better than offering only a restricted subset of XPath.

That would be possible, but probably overkill as it exposes a huge (W3C) type system that's rarely needed on output.
With Nux, the implicit conversions of atomic values to nodes on output are by default designed such that boolean, number, string, etc. can be nicely composed in orthogonal manners without the need of any convenience methods. As in:

int count = Integer.parseInt(new XQuery("count(//*)", null).execute(contextNode).next().getValue());





Archive powered by MHonArc 2.6.24.

Top of Page