Suppose we have some .xml files containing, amongst other things, MIDI note data.
Since MIDI note values must be bounded integers (they cannot be negative and must be less than or equal to some maximum value, e.g. 108) we want to set up some .xsd files to help validate the files while enforcing our bounded integer rule.
Is there any mechanism available that would allow me to enforce the bounds of 0 and 108, or perhaps even a midi “type”, but in such a way so that I only have to type it out once, and only once?
Including the code snippet below for every MIDI element in every schema file is bad for all the obvious reasons – it’s tiresome, error-prone, difficult to maintain, etc.
<xs:element name="note">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="108"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
I’m afraid I’m missing some basic understanding / terminology to be able to get an answer to this question from Mr Google.
Yes, declare a named type, then refer to it:
You can refer to
NoteTypeas many times as you need.