Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 71252 invoked from network); 5 Jun 2009 00:25:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jun 2009 00:25:50 -0000 Received: (qmail 46403 invoked by uid 500); 5 Jun 2009 00:26:00 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 46307 invoked by uid 500); 5 Jun 2009 00:26:00 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 46297 invoked by uid 99); 5 Jun 2009 00:26:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jun 2009 00:26:00 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ahhughes@gmail.com designates 209.85.216.177 as permitted sender) Received: from [209.85.216.177] (HELO mail-px0-f177.google.com) (209.85.216.177) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Jun 2009 00:25:51 +0000 Received: by pxi7 with SMTP id 7so837106pxi.10 for ; Thu, 04 Jun 2009 17:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=ALQKoGyQnicK3t66rNjQPOJQJKzRrg7CHsMOuTrgk/Y=; b=gkRqULeLhcKssDSwaZyFCfKfyw6qzXJLBX+QMTAinqvjXwU7TkBwZlhMKkt+EBXZGl oCs6dHmsZoqvuvsSMPRqKaakAT4VgFHgNhG5CgUIlyZskjGMqkAQFSWEvsOQjkjXLibd EjGuYtruc0aeDAI5E2NObE/LJPyHC21rwhgUc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=QfIUe6DM7TefWk3buW82fvif9nT3m6ZQDPajQAOVlvrgpxf2Buf55auP6wSrd5NO7D SuSD39vMzQIUAD8l1kO81lRosCvEejWSBpY1siHvU6OHaWiQOFxR8IaGOe6t/FNZqET7 +RxF5L04DlcBvZaN91QDGWrctCiUZbKL5OmM0= MIME-Version: 1.0 Received: by 10.142.179.2 with SMTP id b2mr998473wff.280.1244161529153; Thu, 04 Jun 2009 17:25:29 -0700 (PDT) In-Reply-To: <55934.37789.qm@web55106.mail.re4.yahoo.com> References: <55934.37789.qm@web55106.mail.re4.yahoo.com> Date: Fri, 5 Jun 2009 09:55:27 +0930 Message-ID: <5f528cf40906041725i448bafa1rd4e89ebb5a204690@mail.gmail.com> Subject: Re: [JXPath] Iterators and Pointers (on partial matches) From: Andrew Hughes To: Commons Users List Content-Type: multipart/alternative; boundary=000e0cd32a60fd10f4046b8eedc0 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd32a60fd10f4046b8eedc0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Matt, Your explanation re: HierarchyTable sounds very similar. Another possible option is if I can somehow tokenize the "steps" in the expression itself. Then I could keep appending the .next() token... and re-run the expression until it fails (in actual fact it would be best to start removing '--' tokens from the end and re-querying as it is more responsive). Somthing that would look like... Iterator tokens = MythicalTokenizer.tokenize("/Earth/Australia/NSW/Sydney/Utopia"); jxpathContext.selectNode(expression+=tokens.next()); // success with expression = "/Earth" jxpathContext.selectNode(expression+=tokens.next()); // success with expression = "/Earth/Australia" jxpathContext.selectNode(expression+=tokens.next()); // success with expression = "/Earth/Australia/NSW" jxpathContext.selectNode(expression+=tokens.next()); // success with expression = "/Earth/Australia/NSW/Sydney" jxpathContext.selectNode(expression+=tokens.next()); // FAILURE with expression = "/Earth/Australia/NSW/Sydney/Utopia" I've had a look at the compiled expressions and parser's on the RI but I can't see anything that would allow me to do this :'( Hopefully I am missing something. THANKS HEAPS FOR THE RESPONSE!!!! --Andrew On Fri, Jun 5, 2009 at 12:03 AM, Matt Benson wrote: > > 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 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: > > > 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 > > --000e0cd32a60fd10f4046b8eedc0--