You can create your own type, like so:
<xs:simpleType name="rangedInt">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxInclusive value="3" />
</xs:restriction>
</xs:simpleType>
And then use it like this
<xs:attribute name="code" type="rangedInt" />
See also
W3Schools[
^]
This will create an integer type that allows the values 1, 2 and 3.
The type of your attribute should then be rangedInt, instead of a regular integer like it is now (probably).