How to define a type with enumerated strings in RELAX NG?

Still learning RELAX NG (wondering whether I should learn XSD instead), I got my element hierarchy mostly right, so I'm working on contents:

One element (Unit) uses an enumeration type (a fixed set of strings), like this

Byte | KiloByte | MegaByte | GigaByte | TeraByte

So I'd like to define the corresponding type in RELAX NG, but fail to apply the rules from datatypeLibrary="". I have this so far:

  <define name="DT.Unit">
    <a:documentation>Data Type Unit: A fixed set of strings</a:documentation>
    <data datatypeLibrary=""
      <!-- how to define the set of strings allowed? -->

Should I use a pattern, or is it possible to enumerate the strings in another way?

I don't know how to apply the XSD definition to RELAX NG.


  • As I couldn't get an enumeration based on normalizedString working, I droppend the idea of using <data datatypeLibrary="" type="normalizedString">.

    Instead I used <choice> and a list of <value type="string"> elements. This is the solution that worked for me:

    <define name="C.Size">
      <a:documentation>Choice: Size, a fixed set of strings</a:documentation>
        <value type="string">Byte</value>
        <value type="string">KiloByte</value>
        <value type="string">MegaByte</value>
        <value type="string">GigaByte</value>
        <value type="string">TeraByte</value>