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)'.










share|improve this question




























    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)'.










    share|improve this question


























      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)'.










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 6:31

























      asked Nov 20 at 6:57









      MattG

      1,05721121




      1,05721121
























          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 -->





          share|improve this answer























          • 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











          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',
          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
          });


          }
          });














          draft saved

          draft discarded


















          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








          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 -->





          share|improve this answer























          • 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















          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 -->





          share|improve this answer























          • 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













          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 -->





          share|improve this answer














          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 -->






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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


















          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'