commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jess Holle <je...@ptc.com>
Subject [jxpath] one-size-fits-all "eval"?
Date Wed, 09 Feb 2005 19:49:14 GMT
Dmitri Plotnikov wrote:

>Jess,
> 
>First of all, this discussion is probably better suited to the commons-user mailing list.
>  
>
Sorry, you're right -- I crossed a line with this follow on question.

>As far as your specific questions are concerned, getValue() will always return a primitive
value (Number, Boolean or String) when applied to DOM.  selectSingleNode() will return either
a primitive value or a DOM Node. 
>  
>
I really need to efficiently return a primitive or a 
node-set/list/iterator as most appropriate, i.e. my callers pass an 
XPath expression and they get back the most appropriate object from 
these possibilities.  I don't mind having to write a few lines of code 
to do this -- as long as it is efficient, e.g. doing the whole eval a 
couple times to see what's what is a non-starter.  Along these lines I 
looked at calling iterate() instead, but it just returns an Iterator -- 
which does not nicely cover the use case without starting to iterate 
over the iterator.

If this is doable with JXPath, great -- I will give it a shot given some 
guidance.  If not, then it won't fit under the wrapper API I wrote and 
use of JXPath would thus be only for new callers if/when need arose.

>Dumb question (which I probably figured out last time I tried this 
>stuff, but have no notes/recollection of):
>
>Is there an equivalent of Xalan's one-size-fits-all "XObject xobj =
>xpath.execute(...)" mechanism in JXPath?
>
>I'm looking for a CompiledExpression.getValue() that returns an Object 
>for which:
>
>1. I know the various possible return types when this is applied to a
>DOM.
>2. The result is the most appropriate (as per the XPath standard) of
>the following:
>* NodeList or NodeIterator -- or something from which I can
>easily implement one or both of these interfaces
>* Boolean
>* Number
>* String
>
>[I assume callers will apply includes castes within their XPath 
>expressions as necessary where they expect a non-node result.]
>
>Is there such a beast?
>
>The one-API fits all (beans, JDOM, DOM, etc) approach makes this a bit 
>hard for me to decipher.
>
>--
>Jess Holle
>  
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message