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
[EMAIL PROTECTED]
www.virbus.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to