commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject Re: [jxpath] problem with predicates
Date Thu, 19 Feb 2004 15:08:18 GMT
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.

- 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


Mime
View raw message