You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jess Holle <je...@ptc.com> on 2005/02/09 20:49:14 UTC
[jxpath] one-size-fits-all "eval"?
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
>
>
Re: [jxpath] one-size-fits-all "eval"?
Posted by Jess Holle <je...@ptc.com>.
Ooops. I meant to type "commons-user"...
Correcting now.
--
Jess Holle
Jess Holle wrote:
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org