[ 
https://issues.apache.org/jira/browse/JXPATH-197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Peter Verthez updated JXPATH-197:
---------------------------------
    Description: 
If you evaluate an expression that amounts to '' = 0 (comparison of empty 
string with 0), then JXPath is returning true for that although it should be 
false in my interpretation.

Analysis:
 * when comparing a string with a number, a conversion is done: if at least one 
object to be compared is a number, then each object to be compared is converted 
to a number as if by applying the number function 
([https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans])
 * the number function converts an empty string to a NaN number 
([https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Number-Functions])

I see that in the InfoSetUtil class the following is implemented:
{code:java}
    public static double doubleValue(Object object) {
        ...
        if (object instanceof String) {
            if (object.equals("")) {
                return 0.0;
            }
           ...
 {code}
This is the cause of this problem, instead of 0.0 NaN should be returned.

  was:
If you evaluate an expression that amounts to '' = 0, then JXPath is returning 
true for that although it should be false in my interpretation.

Analysis:
 * when comparing a string with a number, a conversion is done: if at least one 
object to be compared is a number, then each object to be compared is converted 
to a number as if by applying the number function 
([https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans])
 * the number function converts an empty string to a NaN number 
([https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Number-Functions])

I see that in the InfoSetUtil class the following is implemented:
{code:java}
    public static double doubleValue(Object object) {
        ...
        if (object instanceof String) {
            if (object.equals("")) {
                return 0.0;
            }
           ...
 {code}

This is the cause of this problem, instead of 0.0 NaN should be returned.


> number() function does not work correctly on empty string
> ---------------------------------------------------------
>
>                 Key: JXPATH-197
>                 URL: https://issues.apache.org/jira/browse/JXPATH-197
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Peter Verthez
>            Priority: Major
>
> If you evaluate an expression that amounts to '' = 0 (comparison of empty 
> string with 0), then JXPath is returning true for that although it should be 
> false in my interpretation.
> Analysis:
>  * when comparing a string with a number, a conversion is done: if at least 
> one object to be compared is a number, then each object to be compared is 
> converted to a number as if by applying the number function 
> ([https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans])
>  * the number function converts an empty string to a NaN number 
> ([https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Number-Functions])
> I see that in the InfoSetUtil class the following is implemented:
> {code:java}
>     public static double doubleValue(Object object) {
>         ...
>         if (object instanceof String) {
>             if (object.equals("")) {
>                 return 0.0;
>             }
>            ...
>  {code}
> This is the cause of this problem, instead of 0.0 NaN should be returned.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to