commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Hughes <ahhug...@gmail.com>
Subject [JXPath] Iterators and Pointers (on partial matches)
Date Thu, 04 Jun 2009 02:45:59 GMT
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)  :)

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