commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <>
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


--- On Wed, 6/3/09, Andrew Hughes <> wrote:

> From: Andrew Hughes <>
> Subject: [JXPath] Iterators and Pointers (on partial matches)
> To: "Commons Users List" <>
> 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:
> "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(;// '' the root
> object
> system.out.println(;// 'Earth'
> system.out.println(;// 'Australia'
> system.out.println(;// 'NSW'
> system.out.println(;// 'Sydney'
> system.out.println(;// THROWS AN
> Thanks heaps for reading (again)  :)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message