Commons JXPath
  1. Commons JXPath
  2. JXPATH-7

number() function doesn't work correctly on Boolean variable

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1 Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      When running the number() function on a Boolean variable, as in the following
      code:
      JXPathContext context = JXPathContextFactory.newInstance().newContext
      (null, null);
      Variables vars = new BasicVariables();
      vars.declareVariable("bool", new Boolean("true"));
      context.setVariables(vars);
      Number num = (Number)context.getValue("number($bool)");
      System.out.println("num = " + num);
      The value returned is NaN, instead of 1.0, as per the XPath spec.

        Activity

        Shahar Mosek created issue -
        Hide
        Dmitri Plotnikov added a comment -

        Was converting boolean to string before converting it to number. That was just
        wrong. Now the wrong has been righted, thanks to Shahar.

        Show
        Dmitri Plotnikov added a comment - Was converting boolean to string before converting it to number. That was just wrong. Now the wrong has been righted, thanks to Shahar.
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 28753 12341430
        Henri Yandell made changes -
        Component/s JXPath [ 12311120 ]
        Affects Version/s 1.1 Final [ 12311652 ]
        Project Commons [ 12310458 ] Commons JXPath [ 12310480 ]
        Key COM-1278 JXPATH-7
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Henri Yandell made changes -
        Affects Version/s 1.1 Final [ 12311793 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Shahar Mosek
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development