by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)


Enumerations

An enumeration is a choice between several values. Enumerations are thus written in RELAX NG by combining the choice pattern with the value pattern. In our library, a good candidate for an enumeration is the available attribute, which can be defined as:

<attribute name="available">
 <choice>
  <value>available</value>
  <value>checked out</value>
  <value>on hold</value>
 </choice>
</attribute>

or:

attribute available {"available"|"checked out"|"on hold"}

This definition validates values such as "available", "checked out", and "on hold". It also validates values such as " available ", "checked out ", or even " on hold " with multiple spaces, tabs or carriage returns between "on" and "hold" or "checked" and "out". You will see the reason for this behavior—and how to change it if needed—in the next section.


This text is released under the Free Software Foundation GFDL.