commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: [JXPath] Iterators and Pointers (on partial matches)
Date Thu, 04 Jun 2009 14:33:16 GMT

Hi Andrew,
  I'm not sure if JXPath is necessarily really the right tool for this.  This almost just
looks like a sort of hierarchical lookup.  I have a HierarchyTable we use at my $work for
these type purposes; unfortunately I haven't yet gotten clearance to release it into the wild.
 I plan someday to include it in [collections] but it may need rewriting before the Commons
community would even agree to it, the reason being that it's somewhat heavy.  I suppose I
can explain its implementation:  It stores hierarchical data a node per level, and its nodes
it uses each hold a HashMap (the heavy part) to keep track of child nodes.  So you _could_
implement your own version of that.  If you are determined to use JXPath for this, for example
if you just really need to be able to get at this information with an expression, you might
be able to accomplish it with a custom function but I'm still afraid at some point you might
have to parse the steps, or rely on JXPath RI
 packages/classes.

HTH,
Matt

--- On Wed, 6/3/09, Andrew Hughes <ahhughes@gmail.com> wrote:

> From: Andrew Hughes <ahhughes@gmail.com>
> Subject: [JXPath] Iterators and Pointers (on partial matches)
> To: "Commons Users List" <user@commons.apache.org>
> Date: Wednesday, June 3, 2009, 9:45 PM
> Hi Again,
> I'm trying to resolve an issue I have trying to step
> through object's
> slightly *different* to the JXPath ReferenceImpl.
> 
> Say I have String expression =
> "/Earth/Australia/NSW/Sydney/Utopia"; Since
> "Utopia" is a mythical place that never exists I'll never
> get a result from
> selectNode("/Earth/Australia/NSW/Sydney/Utopia");
> 
> Neither can I do this with an iterator:
> http://commons.apache.org/jxpath/apidocs/org/apache/commons/jxpath/JXPathContext.html#iteratePointers(java.lang.String)
> 
> "If the xpath matches no properties in the graph, the
> Iterator be empty, but
> not null."
> 
> I've tested this is and when I look for Utopia, I get an
> empty iterator....
> 
> I need an iterator that allows me see just how close I can
> get to 'Utopia':
> 
> Iterator step =
> jxpathContext.iterator("/Earth/Australia/NSW/Sydney/Utopia"
> );
> system.out.println(step.next().toString());// '' the root
> object
> system.out.println(step.next().toString());// 'Earth'
> system.out.println(step.next().toString());// 'Australia'
> system.out.println(step.next().toString());// 'NSW'
> system.out.println(step.next().toString());// 'Sydney'
> system.out.println(step.next().toString());// THROWS AN
> EXCEPTION BECAUSE
> UTOPIA DOES NOT EXIST!!!!
> 
> 
> Thanks heaps for reading (again)  :)
> 


      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message