The default bug view has changed. See this FAQ.

support for validating xsd:double schema type

RESOLVED FIXED

Status

Core Graveyard
XForms
RESOLVED FIXED
11 years ago
9 months ago

People

(Reporter: aaronr, Assigned: Steve Speicher)

Tracking

({fixed1.8.0.5, fixed1.8.1})

Trunk
x86
All
fixed1.8.0.5, fixed1.8.1
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 3 obsolete attachments)

(Reporter)

Description

11 years ago
Be nice if we could validate xsd:double schema type.

This actually fails testcase 8.1.7.f in the testsuite.
(Reporter)

Comment 1

11 years ago
Created attachment 216458 [details]
testcase
(Reporter)

Updated

11 years ago
Blocks: 322255
(Assignee)

Comment 2

11 years ago
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.
Attachment #221706 - Flags: review?(doronr)

Comment 3

11 years ago
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?
Attachment #221706 - Flags: review?(doronr) → review+
(Assignee)

Comment 4

11 years ago
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.
Attachment #221706 - Attachment is obsolete: true
Attachment #221739 - Flags: review?(doronr)

Comment 5

11 years ago
Why is it failing?  I am not sure we need to even consider the 3 text values, do other processors support them?
(Assignee)

Comment 6

11 years ago
(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.
(Assignee)

Comment 7

11 years ago
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

11 years ago
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.
Attachment #221739 - Flags: review?(doronr) → review+
(Assignee)

Updated

11 years ago
Attachment #221739 - Flags: review?(allan)
(Assignee)

Comment 9

11 years ago
Comment on attachment 221811 [details] [diff] [review]
patch for schema test suite, shows INF edge cases

obsoleting, will move to bug regarding INF/-INF
Attachment #221811 - Attachment is obsolete: true

Comment 10

11 years ago
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
Attachment #221739 - Flags: review?(allan) → review+
(Assignee)

Comment 11

11 years ago
Created attachment 222030 [details] [diff] [review]
patch 3, with comment fixed

Doron allowed me to enter Doron-land.

Fixed comment, ready for checkin.
Attachment #221739 - Attachment is obsolete: true

Comment 12

11 years ago
(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?
(Reporter)

Updated

11 years ago
Assignee: doronr → sspeiche
(Reporter)

Comment 13

11 years ago
checked into trunk for sspeiche
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
Whiteboard: xf-to-branch
Doron-land is a happy place with clowns and free baloons.
(Assignee)

Updated

11 years ago
Blocks: 331209

Updated

11 years ago
Keywords: fixed1.8.1

Updated

11 years ago
Keywords: fixed1.8.0.5

Updated

11 years ago
Whiteboard: xf-to-branch
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.