How to define your own data type in xsd?

I want to check if a field has a type in my XML positive double/decimal. There is a data type in XSD type="xs:positiveInteger", but not a positive double or decimal. Is there a way to achieve this, either by defining a custom data type, or in some other way?

+3
source share
2 answers
<xs:element name="data">
  <xs:simpleType>
    <xs:restriction base="xs:float">
      <xs:minInclusive value="0"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

I think this should do it. Maybe a shorter way I'm still learning xsd.

+4
source

You can achieve this by specifying a decimal data type with a restriction, as follows.

<xs:simpleType name="positiveDecimal">
  <xs:restriction base="xs:decimal">
    <xs:minInclusive value="0"/>
  </xs:restriction>
</xs:simpleType>
+3
source

Source: https://habr.com/ru/post/1767832/


All Articles