You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/10/30 11:20:28 UTC

DO NOT REPLY [Bug 24246] New: - The number() function fails

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24246>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24246

The number() function fails

           Summary: The number() function fails
           Product: XalanJ2
           Version: 2.5
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: dperezcar@fcc.es


For example if we try number('   ') (all spaces), the following happens:

  public double toDouble()
  {
      if(m_length == 0)
        return Double.NaN;
      int i;
      char c;
      String valueString = fsb().getString(m_start,m_length);
      
      for (i=0;i<m_length;i++)
        if (!XMLCharacterRecognizer.isWhiteSpace(valueString.charAt(i)))
          break;
      if (valueString.charAt(i) == '-')  
            <---------Fails here with a StringIndexOutOfBoundsException
        i++;
      .....

  }


An easy solution is to catch the StringIndexOutOfBoundsException and return in
that case Double.NaN.

Note: this error has been detected in version 2.5.1, but appears to be also in 2.5.2