d144882f06c146061b223aaed366b1d62afd5a5e
[moodle.git] / lib / xmldb / xmldb.xsd
1 <?xml version="1.0" encoding="UTF-8" ?>
3 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
4   <xs:simpleType name="trueFalse" >
5     <xs:restriction base="xs:NMTOKEN" >
6      <xs:enumeration value="true" />
7      <xs:enumeration value="false" />
8     </xs:restriction >
9   </xs:simpleType >
11   <xs:simpleType name="tableName" >
12     <xs:restriction base="xs:string" >
13      <xs:pattern value='[0-9a-z_]{1,28}'/>
14     </xs:restriction >
15   </xs:simpleType >
17   <xs:simpleType name="fieldName" >
18     <xs:restriction base="xs:string" >
19      <xs:pattern value='[0-9a-z_]{1,30}'/>
20     </xs:restriction >
21   </xs:simpleType >
23   <xs:simpleType name="fieldType">
24     <xs:restriction base="xs:NMTOKEN">
25       <xs:enumeration value="int" />
26       <xs:enumeration value="number" />
27       <xs:enumeration value="float" />
28       <xs:enumeration value="char" />
29       <xs:enumeration value="text" />
30       <xs:enumeration value="binary" />
31       <xs:enumeration value="datetime" />
32     </xs:restriction>
33   </xs:simpleType>
35   <xs:simpleType name="fieldLength" >
36     <xs:restriction base="xs:string" >
37     <!-- TODO: Moodle 2.5 - Drop LOB sizes, keep only numbers -->
38      <xs:pattern value='(\d+)|(small|medium|big)'/>
39     </xs:restriction >
40   </xs:simpleType >
42   <xs:simpleType name="fieldsList" >
43     <xs:restriction base="xs:string" >
44      <xs:pattern value='[0-9a-z_, ]+'/>
45     </xs:restriction >
46   </xs:simpleType >
48   <xs:simpleType name="keyType">
49     <xs:restriction base="xs:NMTOKEN">
50       <xs:enumeration value="primary" />
51       <xs:enumeration value="unique" />
52       <xs:enumeration value="foreign" />
53       <xs:enumeration value="foreign-unique" />
54     </xs:restriction>
55   </xs:simpleType>
58   <xs:element name="FIELD">
59     <xs:complexType>
60       <xs:attribute name="NAME"       type="fieldName"   use="required" />
61       <xs:attribute name="SEQUENCE"   type="trueFalse"   use="required" />
62       <xs:attribute name="TYPE"       type="fieldType"   use="required" />
63       <xs:attribute name="LENGTH"     type="fieldLength" use="optional" />
64       <xs:attribute name="NOTNULL"    type="trueFalse"   use="required" />
65       <xs:attribute name="DECIMALS"   type="xs:positiveInteger" use="optional" />
66       <!-- TODO: Moodle 2.4 - Drop ignored UNSIGNED attribute -->
67       <xs:attribute name="UNSIGNED"   type="trueFalse"   use="optional" />
68       <xs:attribute name="DEFAULT"    type="xs:string"   use="optional" />
69       <xs:attribute name="COMMENT"    type="xs:string"   use="optional" />
70       <xs:attribute name="PREVIOUS"   type="fieldName"   use="optional" />
71       <xs:attribute name="NEXT"       type="fieldName"   use="optional" />
72     </xs:complexType>
73   </xs:element>
75   <xs:element name="FIELDS">
76     <xs:complexType>
77       <xs:sequence>
78         <xs:element ref="FIELD" maxOccurs="unbounded" />
79       </xs:sequence>
80     </xs:complexType>
81   </xs:element>
83   <xs:element name="INDEX">
84     <xs:complexType>
85       <xs:attribute name="NAME"     type="xs:NMTOKEN" use="required" />
86       <xs:attribute name="UNIQUE"   type="trueFalse"  use="required" />
87       <xs:attribute name="FIELDS"   type="fieldsList" use="required" />
88       <xs:attribute name="HINTS"    type="xs:string"  use="optional" />
89       <xs:attribute name="COMMENT"  type="xs:string"  use="optional" />
90       <xs:attribute name="PREVIOUS" type="xs:NMTOKEN" use="optional" />
91       <xs:attribute name="NEXT"     type="xs:NMTOKEN" use="optional" />
92     </xs:complexType>
93   </xs:element>
95   <xs:element name="INDEXES">
96     <xs:complexType>
97       <xs:sequence>
98         <xs:element ref="INDEX" maxOccurs="unbounded" />
99       </xs:sequence>
100     </xs:complexType>
101   </xs:element>
103   <xs:element name="KEY">
104     <xs:complexType>
105       <xs:attribute name="NAME"      type="xs:NMTOKEN" use="required" />
106       <xs:attribute name="TYPE"      type="keyType"    use="required" />
107       <xs:attribute name="FIELDS"    type="fieldsList" use="required" />
108       <xs:attribute name="REFTABLE"  type="tableName"  use="optional" />
109       <xs:attribute name="REFFIELDS" type="fieldsList" use="optional" />
110       <xs:attribute name="COMMENT"   type="xs:string"  use="optional" />
111       <xs:attribute name="PREVIOUS"  type="xs:NMTOKEN" use="optional" />
112       <xs:attribute name="NEXT"      type="xs:NMTOKEN" use="optional" />
113     </xs:complexType>
114   </xs:element>
116   <xs:element name="KEYS">
117     <xs:complexType>
118       <xs:sequence>
119         <xs:element ref="KEY" maxOccurs="unbounded" />
120       </xs:sequence>
121     </xs:complexType>
122   </xs:element>
124   <xs:element name="SENTENCE">
125     <xs:complexType>
126       <xs:attribute name="TEXT" type="xs:string" use="required" />
127     </xs:complexType>
128   </xs:element>
130   <xs:element name="SENTENCES">
131     <xs:complexType>
132       <xs:sequence>
133         <xs:element ref="SENTENCE" maxOccurs="unbounded" />
134       </xs:sequence>
135     </xs:complexType>
136   </xs:element>
138   <xs:element name="TABLE">
139     <xs:complexType>
140       <xs:sequence>
141         <xs:element ref="FIELDS" />
142         <xs:element ref="KEYS"    minOccurs="0" />
143         <xs:element ref="INDEXES" minOccurs="0" />
144       </xs:sequence>
145       <xs:attribute name="NAME"     type="tableName" use="required" />
146       <xs:attribute name="COMMENT"  type="xs:string" use="optional" />
147       <xs:attribute name="PREVIOUS" type="tableName" use="optional" />
148       <xs:attribute name="NEXT"     type="tableName" use="optional" />
149     </xs:complexType>
150   </xs:element>
152   <xs:element name="TABLES">
153     <xs:complexType>
154       <xs:sequence>
155         <xs:element ref="TABLE" maxOccurs="unbounded" />
156       </xs:sequence>
157     </xs:complexType>
158   </xs:element>
160   <xs:element name="XMLDB">
161     <xs:complexType>
162       <xs:sequence>
163         <xs:element ref="TABLES"     minOccurs="0" />
164       </xs:sequence>
165       <xs:attribute name="PATH"    type="xs:string" use="required" />
166       <xs:attribute name="VERSION" type="xs:string" use="required" />
167       <xs:attribute name="COMMENT" type="xs:string" use="optional" />
168     </xs:complexType>
169   </xs:element>
171 </xs:schema>