Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 54414 invoked from network); 12 Feb 2003 16:44:24 -0000 Received: from mail.virbus.de (HELO sati.virbus.de) (145.253.246.201) by daedalus.apache.org with SMTP; 12 Feb 2003 16:44:24 -0000 Received: from sati.virbus.de (localhost [127.0.0.1]) by sati.virbus.de (8.9.3/8.9.3) with ESMTP id RAA21763 for ; Wed, 12 Feb 2003 17:44:26 +0100 Received: from cambio.virbus.de (saraswati.virbus.de [212.144.5.199]) by sati.virbus.de (8.9.3/8.9.3) with ESMTP id RAA21757 for ; Wed, 12 Feb 2003 17:44:25 +0100 Received: by cambio.virbus.de with Internet Mail Service (5.5.2653.19) id <1YKQR3BA>; Wed, 12 Feb 2003 17:44:25 +0100 Message-ID: <31D95EFC91E3D311A57800105A4AF67502350EB0@cambio.virbus.de> From: Peter Neumcke To: "'commons-user@jakarta.apache.org'" Subject: [JXPATH] parentContext not used for XPath starting with '../' Date: Wed, 12 Feb 2003 17:44:24 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi people, I have a question, which I couldn't answer by reading the docs. What happens, if the XPath uses '../' at the beginning to go back one step? Will the parentContext be used to evaluate the XPath? Here's my testcode (adapted from the original test code): public void testRootHandling(){ if (!enabled){ return; } System.out.println("testing root handling start"); JXPathContext context = JXPathContext.newContext(bean); JXPathContext nestedContext = JXPathContext.newContext(context, bean.getNestedBean()); testGetValue(nestedContext, "/boolean", Boolean.FALSE); System.out.println("accessing /boolean in nested context worked!"); testGetValue(nestedContext, "../boolean", Boolean.FALSE); System.out.println("accessing ../boolean in nested context worked!"); } The corresponding output: test.jxpath: [echo] Running JXPath tests ... [java] .testing root handling start [java] accessing /boolean in nested context worked! [java] E..... [java] Time: 1.578 [java] There was 1 error: [java] 1) testRootHandling(org.virbus.websheet.jxpath.JXPathTestCase) [java] org.apache.commons.jxpath.JXPathException: No value for xpath: ../boolean [java] at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathConte xtReferenceImpl.java:206) [java] at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathConte xtReferenceImpl.java:200) [java] at org.virbus.websheet.jxpath.JXPathTestCase.testGetValue(JXPathTestCase.java:3 99) [java] at org.virbus.websheet.jxpath.JXPathTestCase.testRootHandling(JXPathTestCase.ja va:178) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) It looks like it's possible to go back using '/' at the beginning, but using '../' doesn't work. Has anyone got some advice? I'm using commons-jxpath-1.0 I'm new to JXPath, so excuse me, if I understood something wrong or if there's an obvious solution. Mit freundlichen Gruessen, Peter Neumcke -- Software Development VIRBUS AG Fon +49(0)341-979-7421 Fax +49(0)341-979-7409 pneumcke@virbus.de www.virbus.de