commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject Re: [Fwd: [jxpath] one-size-fits-all "eval"?]
Date Thu, 10 Feb 2005 02:09:00 GMT
Jess,
 
You might want to use selectNodes and check the returned value.  It always returns a List,
but the list may contain DOM Nodes or a value: Boolean, Number or String.
 
I hope this helps.
 
- Dmitri


Jess Holle <jessh@ptc.com> wrote:



> ATTACHMENT part 2 message/rfc822 name=[jxpath] one-size-fits-all "eval"?
Date: Wed, 09 Feb 2005 13:49:14 -0600
From: Jess Holle 
To: Jakarta Commons Developers List , 
dmitri@apache.org
Subject: [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 aDOM.2. The
result is the most appropriate (as per the XPath standard) ofthe following:* NodeList or NodeIterator
-- or something from which I caneasily 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  
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message