by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)
In our previous schema, we were required to define the type for each value pattern:
attribute available {string "available"|string "checked out"|string "on hold"} |
This example doesn't show all that RELAX NG is capable of. There is no rule that keeps you from using attributes that have different datatypes in an enumeration. Thus, although this example shows an enumeration with datatypes that are all the same, you aren't restricted to using attributes with all the same datatype in an enumeration.
This will become more interesting after Chapter 8 (when there will be more simple datatypes to work with), but you can write:
<attribute name="available"> <choice> <value type="string">available</value> <value type="token">checked out</value> <value type="string">on hold</value> </choice> </attribute> |
or, in the compact syntax:
attribute available { string "available"| token "checked out"| string "on hold"} |
This schema normalizes whitespace to check the value checked out, defined as token, but doesn't do any normalization when examining the other two values (available and on hold) defined as string.
This text is released under the Free Software Foundation GFDL.