Last Comment Bug 331897 - support for validating xsd:double schema type
: support for validating xsd:double schema type
Status: RESOLVED FIXED
: fixed1.8.0.5, fixed1.8.1
Product: Core Graveyard
Classification: Graveyard
Component: XForms (show other bugs)
: Trunk
: x86 All
: -- normal (vote)
: ---
Assigned To: Steve Speicher
: Stephen Pride
Mentors:
Depends on:
Blocks: 322255 331209
  Show dependency treegraph
 
Reported: 2006-03-27 14:09 PST by aaronr
Modified: 2016-07-15 14:46 PDT (History)
3 users (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
testcase (1.17 KB, application/xhtml+xml)
2006-03-27 14:10 PST, aaronr
no flags Details
patch (10.48 KB, patch)
2006-05-11 07:12 PDT, Steve Speicher
doronr: review+
Details | Diff | Splinter Review
patch2 - with support for INF/-INF/NaN (12.21 KB, patch)
2006-05-11 13:35 PDT, Steve Speicher
doronr: review+
allan: review+
Details | Diff | Splinter Review
patch for schema test suite, shows INF edge cases (4.25 KB, patch)
2006-05-12 07:39 PDT, Steve Speicher
no flags Details | Diff | Splinter Review
patch 3, with comment fixed (13.63 KB, patch)
2006-05-15 06:15 PDT, Steve Speicher
no flags Details | Diff | Splinter Review

Description aaronr 2006-03-27 14:09:11 PST
Be nice if we could validate xsd:double schema type.

This actually fails testcase 8.1.7.f in the testsuite.
Comment 1 aaronr 2006-03-27 14:10:30 PST
Created attachment 216458 [details]
testcase
Comment 2 Steve Speicher 2006-05-11 07:12:16 PDT
Created attachment 221706 [details] [diff] [review]
patch

patch + updated test cases.  Verified against attached test case and W3C test suite.

JST review complains about a few things that I think it's just confused about the & operand and String arg types.
Comment 3 Doron Rosenberg (IBM) 2006-05-11 08:10:07 PDT
Comment on attachment 221706 [details] [diff] [review]
patch

Patch looks good, but the spec says for the lexical space:

http://www.w3.org/TR/xmlschema-2/#double

"The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively. Lexical representations for zero may take a positive or negative sign."

Do we need to worry about those?
Comment 4 Steve Speicher 2006-05-11 13:35:12 PDT
Created attachment 221739 [details] [diff] [review]
patch2 - with support for INF/-INF/NaN

I hesitate to say this is good enough since the one test case fails.  Though it is unclear if -INF < INF, I would think so.

Let me know if there might be a better way to handle this.
Comment 5 Doron Rosenberg (IBM) 2006-05-11 14:09:10 PDT
Why is it failing?  I am not sure we need to even consider the 3 text values, do other processors support them?
Comment 6 Steve Speicher 2006-05-12 07:34:18 PDT
(In reply to comment #5)
> Why is it failing?  I am not sure we need to even consider the 3 text values,
> do other processors support them?
> 

It is failing since strtod doesn't return appropriate values for INF and -INF (actually tested float and ToFloat() has the same problems).  strtod usually returns 0.0 for both INF and -INF. ToFloat() usually returns garbage for INF and -INF.

X-Smiles uses the Xerces validator, which handles these properly ie -INF < INF, -INF < everything, everything < INF, ... what you'd expect.

So I recommend considering support for double done and followup with with a separate INF/-INF bug for str functions (or should we handle it indirectly in our processing of infinity).  Note, after saying all of this...I can't possibly think that anyone is using infinity but you never know.
Comment 7 Steve Speicher 2006-05-12 07:39:57 PDT
Created attachment 221811 [details] [diff] [review]
patch for schema test suite, shows INF edge cases

Don't know if you want these committed but thought it might be helpful.  Updated to test with INF/-INF
Comment 8 Doron Rosenberg (IBM) 2006-05-12 08:11:26 PDT
Comment on attachment 221739 [details] [diff] [review]
patch2 - with support for INF/-INF/NaN

Yeah, lets go with this and file a bug about INF/-INF.
Comment 9 Steve Speicher 2006-05-12 12:35:41 PDT
Comment on attachment 221811 [details] [diff] [review]
patch for schema test suite, shows INF edge cases

obsoleting, will move to bug regarding INF/-INF
Comment 10 Allan Beaufour 2006-05-15 04:57:56 PDT
Comment on attachment 221739 [details] [diff] [review]
patch2 - with support for INF/-INF/NaN

Isn't this Doron-land? That said, the code looks sane, except for:

>-  return (pEnd != aString);
>+  // If end pointer hasn't moved, then there was an error

Either the code or the comment is wrong then.

>+  if (pEnd == aString) {
>+    NS_NAMED_LITERAL_CSTRING(temp, aString);
>+
>+    // doubles may be INF, -INF or NaN
>+    if (!temp.Equals(NS_LITERAL_CSTRING("INF")) &&
>+        !temp.Equals(NS_LITERAL_CSTRING("-INF")) &&
>+        !temp.Equals(NS_LITERAL_CSTRING("NaN"))) {
>+      isValid = PR_FALSE;
>+    }
>+  }
>+  return isValid;

With that fixed, r=me
Comment 11 Steve Speicher 2006-05-15 06:15:51 PDT
Created attachment 222030 [details] [diff] [review]
patch 3, with comment fixed

Doron allowed me to enter Doron-land.

Fixed comment, ready for checkin.
Comment 12 Allan Beaufour 2006-05-15 06:49:42 PDT
(In reply to comment #11)
> Created an attachment (id=222030) [edit]
> patch 3, with comment fixed
> 
> Doron allowed me to enter Doron-land.

:) I meant: r=doronr, and be done with it?
Comment 13 aaronr 2006-05-15 14:35:26 PDT
checked into trunk for sspeiche
Comment 14 Doron Rosenberg (IBM) 2006-05-15 19:29:15 PDT
Doron-land is a happy place with clowns and free baloons.

Note You need to log in before you can comment on or make changes to this bug.