You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Dmitri Plotnikov <dm...@apache.org> on 2004/01/17 04:31:20 UTC
Re: [jxpath] using the last() function? (repost)
Joern,
The last() function is now fixed.
- Dmitri
----- Original Message -----
From: "joern turner" <jo...@web.de>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Sent: Sunday, January 04, 2004 7:02 PM
Subject: [jxpath] using the last() function? (repost)
> Hello,
>
> first of all, thanks for this great piece of code - its a vital part of
> our own open-source project.
>
> but i have a problem using the last() function in jxpath. i'm using the
> following xml:
>
> <instance>
> <my:order my:money="4711">
> <my:item my:money="50">
> <my:amount>500</my:amount>
> <my:discount>100</my:discount>
> </my:item>
> <my:item my:money="4711">
> <my:amount>77</my:amount>
> <my:discount>77</my:discount>
> </my:item>
> </my:order>
> </instance>
>
> i'm trying to get the last element of a nodeset like this:
>
> JXPathContext context = JXPathContext.newContext(doc);
>
> Pointer pointer1 = context.getPointer("//my:order/my:item[2]");
>
assertTrue(pointer1.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
> works ok.
>
> Pointer pointer2
> =context.getPointer("//my:order/my:item[position()=count(../*)]");
>
assertTrue(pointer2.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
> works ok.
>
> Pointer pointer3 =
> context.getPointer("//my:order/my:item[position()=2]");
>
assertTrue(pointer3.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
> works ok.
>
> Pointer pointer4 = context.getPointer("//my:order/my:item[last()]");
>
assertTrue(pointer4.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
> fails with stacktrace. what am i doing wrong? please help. i've
> investigated the problem but cannot find a way to get it working.
>
> any help appreaciated.
>
> Joern
>
>
testLast(org.chiba.xml.xforms.xpath.test.JXPathTest)java.lang.NullPointerExc
eption
> at
>
org.apache.commons.jxpath.ri.model.dom.DOMNodeIterator.previous(DOMNodeItera
tor.java:131)
> at
>
org.apache.commons.jxpath.ri.model.dom.DOMNodeIterator.setPosition(DOMNodeIt
erator.java:121)
> at
>
org.apache.commons.jxpath.ri.axes.ChildContext.setPosition(ChildContext.java
:152)
> at
>
org.apache.commons.jxpath.ri.compiler.CoreFunction.functionLast(CoreFunction
.java:335)
> at
>
org.apache.commons.jxpath.ri.compiler.CoreFunction.computeValue(CoreFunction
.java:259)
> at
>
org.apache.commons.jxpath.ri.axes.PredicateContext.nextNode(PredicateContext
.java:127)
> at
>
org.apache.commons.jxpath.ri.EvalContext.getSingleNodePointer(EvalContext.ja
va:333)
> at
> org.apache.commons.jxpath.ri.compiler.Path.searchForPath(Path.java:211)
> at
>
org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointerForSteps(Path
.java:192)
> at
>
org.apache.commons.jxpath.ri.compiler.LocationPath.computeValue(LocationPath
.java:128)
> at
>
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getPointer(JXPathCon
textReferenceImpl.java:366)
> at
>
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getPointer(JXPathCon
textReferenceImpl.java:362)
> at
> org.chiba.xml.xforms.xpath.test.JXPathTest.testLast(JXPathTest.java:162)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
> at
>
com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [jxpath] using the last() function? (repost)
Posted by joern turner <jo...@web.de>.
Dmitri Plotnikov wrote:
> Joern,
>
> The last() function is now fixed.
thanks so much. i tried to debug it myself but got lost in the contexts ;)
Joern
>
> - Dmitri
>
> ----- Original Message -----
> From: "joern turner" <jo...@web.de>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Sunday, January 04, 2004 7:02 PM
> Subject: [jxpath] using the last() function? (repost)
>
>
>
>>Hello,
>>
>>first of all, thanks for this great piece of code - its a vital part of
>>our own open-source project.
>>
>>but i have a problem using the last() function in jxpath. i'm using the
>>following xml:
>>
>><instance>
>> <my:order my:money="4711">
>> <my:item my:money="50">
>> <my:amount>500</my:amount>
>> <my:discount>100</my:discount>
>> </my:item>
>> <my:item my:money="4711">
>> <my:amount>77</my:amount>
>> <my:discount>77</my:discount>
>> </my:item>
>> </my:order>
>></instance>
>>
>>i'm trying to get the last element of a nodeset like this:
>>
>>JXPathContext context = JXPathContext.newContext(doc);
>>
>>Pointer pointer1 = context.getPointer("//my:order/my:item[2]");
>>
>
> assertTrue(pointer1.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
>>works ok.
>>
>>Pointer pointer2
>> =context.getPointer("//my:order/my:item[position()=count(../*)]");
>>
>
> assertTrue(pointer2.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
>>works ok.
>>
>>Pointer pointer3 =
>> context.getPointer("//my:order/my:item[position()=2]");
>>
>
> assertTrue(pointer3.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
>>works ok.
>>
>>Pointer pointer4 = context.getPointer("//my:order/my:item[last()]");
>>
>
> assertTrue(pointer4.asPath().equals("/instance[1]/my:order[1]/my:item[2]"));
>
>>fails with stacktrace. what am i doing wrong? please help. i've
>>investigated the problem but cannot find a way to get it working.
>>
>>any help appreaciated.
>>
>>Joern
>>
>>
>
> testLast(org.chiba.xml.xforms.xpath.test.JXPathTest)java.lang.NullPointerExc
> eption
>
>> at
>>
>
> org.apache.commons.jxpath.ri.model.dom.DOMNodeIterator.previous(DOMNodeItera
> tor.java:131)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.model.dom.DOMNodeIterator.setPosition(DOMNodeIt
> erator.java:121)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.axes.ChildContext.setPosition(ChildContext.java
> :152)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.compiler.CoreFunction.functionLast(CoreFunction
> .java:335)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.compiler.CoreFunction.computeValue(CoreFunction
> .java:259)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.axes.PredicateContext.nextNode(PredicateContext
> .java:127)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.EvalContext.getSingleNodePointer(EvalContext.ja
> va:333)
>
>> at
>>org.apache.commons.jxpath.ri.compiler.Path.searchForPath(Path.java:211)
>> at
>>
>
> org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointerForSteps(Path
> .java:192)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.compiler.LocationPath.computeValue(LocationPath
> .java:128)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getPointer(JXPathCon
> textReferenceImpl.java:366)
>
>> at
>>
>
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getPointer(JXPathCon
> textReferenceImpl.java:362)
>
>> at
>>org.chiba.xml.xforms.xpath.test.JXPathTest.testLast(JXPathTest.java:162)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>>
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>
>> at
>>
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>
>> at
>>
>
> com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
>
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org