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="http://www.w3.org/2001/XMLSchema-datatypes".
I have this so far:
<define name="DT.Unit">
<a:documentation>Data Type Unit: A fixed set of strings</a:documentation>
<data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
type="normalizedString">
<!-- how to define the set of strings allowed? -->
</data>
</define>
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
normalizedStringworking, I droppend the idea of using<data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" type="normalizedString">.Instead I used
<choice>and a list of<value type="string">elements. This is the solution that worked for me: