How can I define an XML XSD type to describe the subset of “double” excluding “NaN”...
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 |
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 |
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 '18 at 6:31
MattG
asked Nov 20 '18 at 6:57
MattGMattG
1,08521122
1,08521122
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
add a comment |
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 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
add a comment |
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 '18 at 8:54
answered Nov 20 '18 at 8:11
NeskuNesku
3861211
3861211
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
add a comment |
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 '18 at 10:22
In fact, any range facet, regardless of value, excludes NaN from the value space.
– Michael Kay
Nov 20 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 21:34
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 at 22:15
This solution did exactly what I was after, worked perfectly, thanks.
– MattG
Nov 20 '18 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.
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