December 2003
Intermediate to advanced
506 pages
12h 26m
English
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.
Read now
Unlock full access