commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joern turner <joern.tur...@web.de>
Subject Re: [jxpath] problem with predicates
Date Thu, 19 Feb 2004 16:56:49 GMT
hello Dmitri,

Dmitri Plotnikov wrote:

> Joern,
> 
> An attribute pointer (like many other kinds of pointers) holds onto the
> node it represents and therefore may return a stale value.  To get the
> fresh value you need to do something like this:
> 
> Object newValue = context.getValue(pointer.asPath());
> 
> I hope this helps.
yes and thanks for the quick answer. this clarifies some problems i had. 
actually my testcase wasn't correct which lead to the problems but 
nevertheless your answer is very helpfull for our understanding.

best,

Joern


> 
> - Dmitri
> 
> --- joern turner <joern.turner@web.de> wrote:
> 
>>hello,
>>
>>i've got a problem evaluating predicates when used in conjunction
>>with 
>>relative contexts.
>>
>>here the xml-input i'm using:
>><people>
>>     <person name="Name1"></person>
>>     <person name="Name2"></person>
>>     <person name="Name3"></person>
>>     <person name="Name4"></person>
>>     <new name="NameX"></new>
>></people>
>>
>>
>>here's the code:
>>
>>//document is a DOM containing the above xml
>>JXPathContext rootContext = JXPathContext.newContext(document);
>>
>>//the xpath must be evaluated relative to pointer
>>Pointer pointer = rootContext.getPointer("/people/new/@name");
>>JXPathContext relativeContext =
>>       rootContext.getRelativeContext(this.pointer);
>>
>>//ok 
>>
> 
> assertTrue(relativeContext.getPointer("not(//person/@name=.)").getValue().toString().equals("true"));
> 
>>//fails
>>this.pointer.setValue("Name1"); 
>>
> 
> assertTrue(relativeContext.getPointer("not(//person/@name=.)").getValue().toString().equals("false"));
> 
>>i've tried this and that but with no success. can someone shed some 
>>light on this or teach me what i'm doing wrong?
>>
>>thanks,
>>
>>
>>Joern
>>
>>---------------------------------------------------------------------
>>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


Mime
View raw message