RELAX NG by Eric van der Vlist will be published by O'Reilly & Associates (ISBN: 0596004214)

You are welcome to use our annotation system to give your feedback.


Using different types in each value

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 us from using attributes that have different datatypes in an enumeration. Thus, although this example shows an enumeration with datatypes that are all the same, we aren't restricted to using attributes with all the same datatype in an enumeration.

This will become more interesting after next chapter (when we will have more simple datatypes to work with), but we could 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 would normalise namespaces to check the value "checked out", defined as "token", but wouldn't do any normalization when examining the other two values ("available" and "on hold") defined as "string".


You are welcome to use our annotation system to give your feedback.
[Annotations for this page]
All text is copyright Eric van der Vlist, Dyomedea. During development, I give permission for non-commercial copying for educational and review purposes. After publication, all text will be released under the Free Software Foundation GFDL.