How can I define an XML XSD type to describe the subset of “double” excluding “NaN”...
up vote
1
down vote
favorite
I have an existing XSD where the type for an element is specified as "double", according to the spec this restricts the valid values to:
1) the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive.
2) In addition to these values, the ·value space· of double also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
I am fine with the first part, but I want to disallow/exclude the following:
- positiveInfinity
- negativeInfinity
- notANumber (NaN)
What is the XML XSD syntax/definition to define this new type, that represents "double, except for positiveInfinity, negativeInfinity, notANumber (NaN)'.
xml xsd xsd-validation
add a comment |
up vote
1
down vote
favorite
I have an existing XSD where the type for an element is specified as "double", according to the spec this restricts the valid values to:
1) the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive.
2) In addition to these values, the ·value space· of double also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
I am fine with the first part, but I want to disallow/exclude the following:
- positiveInfinity
- negativeInfinity
- notANumber (NaN)
What is the XML XSD syntax/definition to define this new type, that represents "double, except for positiveInfinity, negativeInfinity, notANumber (NaN)'.
xml xsd xsd-validation
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have an existing XSD where the type for an element is specified as "double", according to the spec this restricts the valid values to:
1) the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive.
2) In addition to these values, the ·value space· of double also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
I am fine with the first part, but I want to disallow/exclude the following:
- positiveInfinity
- negativeInfinity
- notANumber (NaN)
What is the XML XSD syntax/definition to define this new type, that represents "double, except for positiveInfinity, negativeInfinity, notANumber (NaN)'.
xml xsd xsd-validation
I have an existing XSD where the type for an element is specified as "double", according to the spec this restricts the valid values to:
1) the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive.
2) In addition to these values, the ·value space· of double also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
I am fine with the first part, but I want to disallow/exclude the following:
- positiveInfinity
- negativeInfinity
- notANumber (NaN)
What is the XML XSD syntax/definition to define this new type, that represents "double, except for positiveInfinity, negativeInfinity, notANumber (NaN)'.
xml xsd xsd-validation
xml xsd xsd-validation
edited Nov 22 at 6:31
asked Nov 20 at 6:57
MattG
1,05721121
1,05721121
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can probably achieve this with a restriction
<xs:element name="myDouble">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="-INF"/>
<xs:maxExclusive value="INF"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Note : NaN seems to be also stopped by <xs:maxExclusive value="INF"/>
ERROR: Element 'myDouble': [facet 'maxExclusive'] The value 'NaN' must
be less than 'INF'.
I've tried it and it work with
<myDouble>123.456</myDouble> <!-- OK -->
<myDouble>+1234.456</myDouble> <!-- OK -->
<myDouble>-1.2344e56</myDouble> <!-- OK -->
<myDouble>-.45E-6</myDouble> <!-- OK -->
<myDouble>INF</myDouble> <!-- KO -->
<myDouble>-INF</myDouble> <!-- KO -->
<myDouble>NaN</myDouble> <!-- KO -->
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can probably achieve this with a restriction
<xs:element name="myDouble">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="-INF"/>
<xs:maxExclusive value="INF"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Note : NaN seems to be also stopped by <xs:maxExclusive value="INF"/>
ERROR: Element 'myDouble': [facet 'maxExclusive'] The value 'NaN' must
be less than 'INF'.
I've tried it and it work with
<myDouble>123.456</myDouble> <!-- OK -->
<myDouble>+1234.456</myDouble> <!-- OK -->
<myDouble>-1.2344e56</myDouble> <!-- OK -->
<myDouble>-.45E-6</myDouble> <!-- OK -->
<myDouble>INF</myDouble> <!-- KO -->
<myDouble>-INF</myDouble> <!-- KO -->
<myDouble>NaN</myDouble> <!-- KO -->
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
add a comment |
up vote
1
down vote
accepted
You can probably achieve this with a restriction
<xs:element name="myDouble">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="-INF"/>
<xs:maxExclusive value="INF"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Note : NaN seems to be also stopped by <xs:maxExclusive value="INF"/>
ERROR: Element 'myDouble': [facet 'maxExclusive'] The value 'NaN' must
be less than 'INF'.
I've tried it and it work with
<myDouble>123.456</myDouble> <!-- OK -->
<myDouble>+1234.456</myDouble> <!-- OK -->
<myDouble>-1.2344e56</myDouble> <!-- OK -->
<myDouble>-.45E-6</myDouble> <!-- OK -->
<myDouble>INF</myDouble> <!-- KO -->
<myDouble>-INF</myDouble> <!-- KO -->
<myDouble>NaN</myDouble> <!-- KO -->
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can probably achieve this with a restriction
<xs:element name="myDouble">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="-INF"/>
<xs:maxExclusive value="INF"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Note : NaN seems to be also stopped by <xs:maxExclusive value="INF"/>
ERROR: Element 'myDouble': [facet 'maxExclusive'] The value 'NaN' must
be less than 'INF'.
I've tried it and it work with
<myDouble>123.456</myDouble> <!-- OK -->
<myDouble>+1234.456</myDouble> <!-- OK -->
<myDouble>-1.2344e56</myDouble> <!-- OK -->
<myDouble>-.45E-6</myDouble> <!-- OK -->
<myDouble>INF</myDouble> <!-- KO -->
<myDouble>-INF</myDouble> <!-- KO -->
<myDouble>NaN</myDouble> <!-- KO -->
You can probably achieve this with a restriction
<xs:element name="myDouble">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="-INF"/>
<xs:maxExclusive value="INF"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Note : NaN seems to be also stopped by <xs:maxExclusive value="INF"/>
ERROR: Element 'myDouble': [facet 'maxExclusive'] The value 'NaN' must
be less than 'INF'.
I've tried it and it work with
<myDouble>123.456</myDouble> <!-- OK -->
<myDouble>+1234.456</myDouble> <!-- OK -->
<myDouble>-1.2344e56</myDouble> <!-- OK -->
<myDouble>-.45E-6</myDouble> <!-- OK -->
<myDouble>INF</myDouble> <!-- KO -->
<myDouble>-INF</myDouble> <!-- KO -->
<myDouble>NaN</myDouble> <!-- KO -->
edited Nov 20 at 8:54
answered Nov 20 at 8:11
Nesku
268111
268111
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
add a comment |
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 at 10:22
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
I was wondering about that, from what I've seen it's only the max range (regardless of value) that excludes NaN.
– Nesku
Nov 20 at 10:36
1
1
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
XSD 1.1 is explicit: "NaN is ·incomparable· with any value in the ·value space· including itself." "Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·."
– Michael Kay
Nov 20 at 11:03
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
Thanks guys, looks like exactly what I was after. I will test this solution then hopefully accept this answer.
– MattG
Nov 20 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 at 22:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387744%2fhow-can-i-define-an-xml-xsd-type-to-describe-the-subset-of-double-excluding-n%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown