I know, it is a little bizarre, but I think JXPath does what the spec is
telling it to do.

>From JXPath's perspective "BVALUE" is not a mere boolean value, it is a node
set containing that boolean value.  And that makes a huge difference.
According to the XPath spec, this should is actually interpreted as true
(non-empty node set), rather than false (the boolean value of the first
element of the set).

In other words, the expression "not(BVALUE)" is interpreted as meaning
"BVALUE does not exist", rather than "BVALUE is false".

The way to get around this is to reformulate the expression:
"not(BVALUE=true())" or "BVALUE=false()"

I hope this helps.

- Dmitri

----- Original Message -----
From: "Luca Biolcati" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 4:54 AM
Subject: [JXpath] boolean value


Hello,
I don't understand how JXPath evaluates boolean values. It seems it converts
them in integer values, instead of treating them as boolean. I used a Map as
context:

==============================
Map myMap = new HashMap();

myMap.put("BVALUE", Boolean.FALSE);

JXPathContext ctx = JXPathContext.newContext(myMap);

String exp = "not(BVALUE)";

System.out.println("["+exp+"]: "+ctx.getValue(exp));

==============================

end the output is:

[not(BVALUE)]: false

if I use an expression like BVALUE=0 it works fine. But for what I know
about xpath syntax, expressions like BVALUE=false or not(BVALUE) should
produce the same result, am I wrong?



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

Reply via email to