code: public double toDouble()
    {
      /* XMLCharacterRecognizer.isWhiteSpace(char c) methods treats the following 
       * characters as white space characters.
       * ht - horizontal tab, nl - newline , cr - carriage return and sp - space
       * trim() methods by default also takes care of these white space characters
       * So trim() method is used to remove leading and trailing white spaces.
       */
  	XMLString s = trim();
  	double result = Double.NaN;
  	for (int i = 0; i < s.length(); i++)
  	{
  		char c = s.charAt(i);
      if (c != '-' && c != '.' && ( c < 0X30 || c > 0x39)) {
              // The character is not a '-' or a '.' or a digit
              // then return NaN because something is wrong.
  			return result;
          }
  	}
  	try
  	{
  		result = Double.parseDouble(s.toString());
  	} catch (NumberFormatException e){}
  
  	return result;
  }
docs: Convert a string to a double -- Allowed input is in fixed
  notation ddd.fff.
  
  @return A double value representation of the string, or return Double.NaN
  if the string can not be converted.