Mixing mininclusive and enum in xml
I have an xml element whose value range is (essentially) 1-20, so I can use:
minInclusive=1
and maxInclusive=20
to constrain the inline set.
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="20"/>
</xs:restriction>
However, I also want to set an external value of -4, which has a specific value: "Unknown"
Is it possible? That is, 1-20 and -4 (not -4-20).
I thought I could get away with adding the enum value = -4, but that doesn't seem to work.
<xs:restriction base="xs:integer">
<xs:enumeration value="-4"/>
<xs:minInclusive value="1"/>
<xs:maxInclusive value="20"/>
</xs:restriction>
+3
source to share
1 answer
I think what you need xs:union
is that will allow you to combine the two types of constraints together, for example
<xs:simpleType name="numbersOnetoTwenty">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="justMinusFour">
<xs:restriction base="xs:integer">
<xs:enumeration value="-4"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="mySet">
<xs:union memberTypes="numbersOnetoTwenty justMinusFour" />
</xs:simpleType>
+3
source to share