Reputation: 75
I would like to define a XSD type which is a decimal (positive or negative) but it cannot be zero. How can I do it?
This is the body of definition:
<simpleType name="grossValueType">
<restriction base="decimal">
<!-- What put here? -->
</restriction>
</simpleType>
Upvotes: 3
Views: 2290
Reputation: 18002
Define two types, negativeDecimals and positiveDecimals, and then union them together to get what you want:
<xs:simpleType name="negativeDecimals">
<xs:restriction base="xs:decimal">
<xs:maxExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="positiveDecimals">
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="measure">
<xs:simpleType>
<xs:union memberTypes="negativeDecimals positiveDecimals"/>
</xs:simpleType>
</xs:element>
Since neither base type can accept 0, that value will be illegal; all other decimal values will be legal.
Upvotes: 5