schema: add switch-case
[free-sw/xcb/proto] / src / xcb.xsd
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 Copyright (C) 2004 Josh Triplett.  All Rights Reserved.
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the names of the authors or their
23 institutions shall not be used in advertising or otherwise to promote the
24 sale, use or other dealings in this Software without prior written
25 authorization from the authors.
26 -->
27 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
28
29   <!-- The root element -->
30   <xsd:element name="xcb">
31     <xsd:complexType>
32       <xsd:group ref="macro" minOccurs="0" maxOccurs="unbounded" />
33       <xsd:attribute name="header" type="xsd:string" use="required" />
34       <xsd:attribute name="extension-xname" type="xsd:string" use="optional" />
35       <xsd:attribute name="extension-name"  type="xsd:string" use="optional" />
36       <xsd:attribute name="extension-multiword" type="xsd:boolean" use="optional" default="false" />
37       <xsd:attribute name="major-version"   type="xsd:integer" use="optional" />
38       <xsd:attribute name="minor-version"   type="xsd:integer" use="optional" />
39     </xsd:complexType>
40   </xsd:element>
41
42   <!-- Padding -->
43   <xsd:element name="pad">
44     <xsd:complexType>
45       <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
46       <xsd:attribute name="align" type="xsd:integer" use="optional" />
47     </xsd:complexType>
48   </xsd:element>
49
50   <!-- Type for fields or parameters with attributes "name" and "type" -->
51   <xsd:complexType name="var">
52     <xsd:attribute name="name" type="xsd:string" use="required" />
53     <xsd:attribute name="type" type="xsd:string" use="required" />
54     <xsd:attribute name="enum" type="xsd:string" use="optional" />
55     <xsd:attribute name="altenum" type="xsd:string" use="optional" />
56     <xsd:attribute name="mask" type="xsd:string" use="optional" />
57     <xsd:attribute name="altmask" type="xsd:string" use="optional" />
58   </xsd:complexType>
59
60   <!-- case expression -->
61   <xsd:complexType name="caseexpr">
62     <xsd:sequence>
63       <!-- case expression: -->
64       <xsd:group ref="expression" minOccurs="1" maxOccurs="unbounded" />
65       <!-- match -->
66       <xsd:group ref="fields" minOccurs="1" maxOccurs="unbounded" />
67       <xsd:choice>
68         <xsd:element ref="switch" minOccurs="0" maxOccurs="unbounded" />
69       </xsd:choice>
70     </xsd:sequence>
71     <xsd:attribute name="name" type="xsd:string" use="optional" />
72   </xsd:complexType>
73
74   <!-- switch expression -->
75   <xsd:complexType name="switchexpr">
76     <xsd:sequence>
77       <!-- switch(expression) -->
78       <xsd:group ref="expression" minOccurs="1" maxOccurs="1" />
79       <xsd:choice>
80         <!-- bitcase expression - bit test -->
81         <xsd:element name="bitcase" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
82         <!-- case expression - value test -->
83         <xsd:element name="case" type="caseexpr" minOccurs="0" maxOccurs="unbounded" />
84       </xsd:choice>
85       <!-- default: -->
86       <xsd:group ref="fields" minOccurs="0" maxOccurs="1" />
87     </xsd:sequence>
88     <xsd:attribute name="name" type="xsd:string" use="required" />
89   </xsd:complexType>
90
91   <xsd:element name="switch" type="switchexpr" />
92
93   <!-- field replaces FIELD, PARAM, and REPLY. -->
94   <xsd:element name="field" type="var" />
95
96   <!-- fd passing parameter -->
97   <xsd:element name="fd">
98     <xsd:complexType>
99       <xsd:attribute name="name" type="xsd:string" use="required" />
100     </xsd:complexType>
101   </xsd:element>
102
103   <!-- list replaces ARRAYFIELD, LISTPARAM, and ARRAYREPLY.  The name and type
104        are specified as attributes.  The content is an expression giving the
105        length. -->
106   <xsd:element name="list">
107     <xsd:complexType>
108       <xsd:complexContent>
109         <xsd:extension base="var">
110           <xsd:group ref="expression" minOccurs="0" maxOccurs="1" />
111         </xsd:extension>
112       </xsd:complexContent>
113     </xsd:complexType>
114   </xsd:element>
115
116   <!-- Expressions -->
117   <xsd:group name="expression">
118     <xsd:choice>
119       <xsd:element name="op">
120         <xsd:complexType>
121           <xsd:sequence>
122             <xsd:group ref="expression" />
123             <xsd:group ref="expression" />
124           </xsd:sequence>
125           <xsd:attribute name="op" use="required">
126             <xsd:simpleType>
127               <xsd:restriction base="xsd:string">
128                 <xsd:pattern value="\+|-|\*|/|&amp;|&lt;&lt;" />
129               </xsd:restriction>
130             </xsd:simpleType>
131           </xsd:attribute>
132         </xsd:complexType>
133       </xsd:element>
134       <xsd:element name="unop">
135          <xsd:complexType>
136             <xsd:sequence>
137               <xsd:group ref="expression" />
138             </xsd:sequence>
139             <xsd:attribute name="op" use="required">
140               <xsd:simpleType>
141                 <xsd:restriction base="xsd:string">
142                   <xsd:pattern value="~" />
143                 </xsd:restriction>
144               </xsd:simpleType>
145             </xsd:attribute>
146          </xsd:complexType>
147       </xsd:element>
148       <xsd:element name="fieldref" type="xsd:string" />
149       <xsd:element name="enumref">
150         <xsd:complexType>
151           <xsd:simpleContent>
152             <xsd:extension base="xsd:string">
153               <xsd:attribute name="ref" use="required" type="xsd:string" />
154             </xsd:extension>
155           </xsd:simpleContent>
156         </xsd:complexType>
157       </xsd:element>
158       <xsd:element name="popcount">
159         <xsd:complexType>
160           <xsd:group ref="expression" />
161         </xsd:complexType>
162       </xsd:element>
163       <xsd:element name="sumof">
164         <xsd:complexType>
165           <xsd:attribute name="ref" use="required" type="xsd:string" />
166         </xsd:complexType>
167       </xsd:element>
168       <xsd:element name="value" type="xsd:integer" />
169       <xsd:element name="bit" type="bitType" />
170     </xsd:choice>
171   </xsd:group>
172   
173   <!-- Fields in requests that are calculated from other information, not
174        supplied by the caller. -->
175   <xsd:element name="exprfield" >
176     <xsd:complexType>
177       <xsd:complexContent>
178         <xsd:extension base="var">
179           <xsd:group ref="expression" />
180         </xsd:extension>
181       </xsd:complexContent>
182     </xsd:complexType>
183   </xsd:element>
184
185   <!-- BITMASK/LISTofVALUE parameter pairs. -->
186   <xsd:element name="valueparam">
187     <xsd:complexType>
188       <xsd:attribute name="value-mask-type" type="xsd:string" use="required" />
189       <xsd:attribute name="value-mask-name" type="xsd:string" use="required" />
190       <xsd:attribute name="value-list-name" type="xsd:string" use="required" />
191     </xsd:complexType>
192   </xsd:element>
193
194   <xsd:group name="fields">
195     <xsd:choice>
196       <xsd:element ref="pad" />
197       <xsd:element ref="field" />
198       <xsd:element ref="list" />
199       <xsd:element ref="fd" />
200     </xsd:choice>
201   </xsd:group>
202
203   <!-- Type for a structure -->
204   <xsd:complexType name="struct">
205     <xsd:sequence>
206       <xsd:group ref="fields" minOccurs="1" maxOccurs="unbounded" />
207       <xsd:choice minOccurs="0" maxOccurs="1">
208         <xsd:element ref="switch" />
209       </xsd:choice>
210     </xsd:sequence>
211     <xsd:attribute name="name" type="xsd:string" use="required" />
212   </xsd:complexType>
213
214   <!-- Type for a packet structure -->
215   <xsd:complexType name="packet-struct">
216     <xsd:sequence>
217       <xsd:group ref="fields" minOccurs="0" maxOccurs="unbounded" />
218     </xsd:sequence>
219     <xsd:attribute name="name" type="xsd:string" use="required" />
220     <xsd:attribute name="number" type="xsd:integer" use="required" />
221   </xsd:complexType>
222
223   <!-- Type for a packet structure copy -->
224   <xsd:complexType name="packet-struct-copy">
225     <xsd:attribute name="name" type="xsd:string" use="required" />
226     <xsd:attribute name="number" type="xsd:integer" use="required" />
227     <xsd:attribute name="ref" type="xsd:string" use="required" />
228   </xsd:complexType>
229
230   <!-- Type for bit values -->
231   <xsd:simpleType name="bitType">
232     <xsd:restriction base="xsd:integer">
233       <xsd:minInclusive value="0" />
234       <xsd:maxExclusive value="32" />
235     </xsd:restriction>
236   </xsd:simpleType>
237
238   <!-- Type for documentation -->
239   <xsd:group name="doc-fields">
240     <xsd:sequence>
241       <xsd:element name="field">
242         <xsd:complexType>
243           <xsd:simpleContent>
244             <xsd:extension base="xsd:string">
245               <xsd:attribute name="name" type="xsd:string" />
246             </xsd:extension>
247           </xsd:simpleContent>
248         </xsd:complexType>
249       </xsd:element>
250     </xsd:sequence>
251   </xsd:group>
252
253   <xsd:group name="error-fields">
254     <xsd:sequence>
255       <xsd:element name="error">
256         <xsd:complexType>
257           <xsd:simpleContent>
258             <xsd:extension base="xsd:string">
259               <xsd:attribute name="type" type="xsd:string" />
260             </xsd:extension>
261           </xsd:simpleContent>
262         </xsd:complexType>
263       </xsd:element>
264     </xsd:sequence>
265   </xsd:group>
266
267   <xsd:group name="see-fields">
268     <xsd:sequence>
269       <xsd:element name="see">
270         <xsd:complexType>
271           <xsd:attribute name="name" type="xsd:string" />
272           <xsd:attribute name="type" type="xsd:string" />
273         </xsd:complexType>
274       </xsd:element>
275     </xsd:sequence>
276   </xsd:group>
277
278   <xsd:element name="doc">
279     <xsd:complexType mixed="true">
280       <xsd:sequence>
281         <xsd:element name="brief" type="xsd:string" minOccurs="0" maxOccurs="1" />
282         <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1" />
283         <xsd:element name="example" type="xsd:string" minOccurs="0" maxOccurs="1" />
284         <xsd:group ref="doc-fields" minOccurs="0" maxOccurs="unbounded" />
285         <xsd:group ref="error-fields" minOccurs="0" maxOccurs="unbounded" />
286         <xsd:group ref="see-fields" minOccurs="0" maxOccurs="unbounded" />
287       </xsd:sequence>
288     </xsd:complexType>
289   </xsd:element>
290
291   <xsd:group name="macro">
292     <xsd:choice>
293       <xsd:element name="request">
294         <xsd:complexType>
295           <xsd:sequence>
296             <xsd:choice minOccurs="0" maxOccurs="unbounded">
297               <xsd:group ref="fields" />
298               <xsd:element ref="exprfield" />
299               <xsd:element ref="valueparam" />
300             </xsd:choice>
301             <xsd:choice minOccurs="0" maxOccurs="1">
302               <xsd:element ref="switch" />
303             </xsd:choice>
304             <xsd:element name="reply" minOccurs="0" maxOccurs="1">
305               <xsd:complexType>
306                 <xsd:sequence>
307                   <xsd:choice minOccurs="1" maxOccurs="unbounded">
308                     <xsd:group ref="fields" />
309                     <xsd:element ref="valueparam" />
310                   </xsd:choice>
311                   <xsd:choice minOccurs="0" maxOccurs="1">
312                     <xsd:element ref="switch" />
313                   </xsd:choice>
314                   <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
315                 </xsd:sequence>
316               </xsd:complexType>
317             </xsd:element>
318             <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
319           </xsd:sequence>
320           <xsd:attribute name="name" type="xsd:string" use="required" />
321           <xsd:attribute name="opcode" type="xsd:integer" use="required" />
322           <xsd:attribute name="combine-adjacent" type="xsd:boolean"
323                          use="optional" default="false" />
324         </xsd:complexType>
325       </xsd:element>
326       <xsd:element name="event">
327         <xsd:complexType>
328           <xsd:complexContent>
329             <xsd:extension base="packet-struct">
330               <xsd:sequence>
331                 <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
332               </xsd:sequence>
333               <xsd:attribute name="no-sequence-number" type="xsd:boolean"
334                              use="optional" default="false" />
335               <xsd:attribute name="xge" type="xsd:boolean"
336                              use="optional" default="false" />
337             </xsd:extension>
338           </xsd:complexContent>
339         </xsd:complexType>
340       </xsd:element>
341       <xsd:element name="eventcopy" type="packet-struct-copy" />
342       <xsd:element name="error" type="packet-struct" />
343       <xsd:element name="errorcopy" type="packet-struct-copy" />
344       <xsd:element name="struct" type="struct" />
345       <xsd:element name="union" type="struct" />
346       <xsd:element name="xidtype">
347         <xsd:complexType>
348           <xsd:attribute name="name" type="xsd:string" use="required" />
349         </xsd:complexType>
350       </xsd:element>
351       <xsd:element name="xidunion">
352         <xsd:complexType>
353           <xsd:sequence>
354             <xsd:element name="type" type="xsd:string"
355                          minOccurs="1" maxOccurs="unbounded" />
356           </xsd:sequence>
357           <xsd:attribute name="name" type="xsd:string" use="required" />
358         </xsd:complexType>
359       </xsd:element>
360       <xsd:element name="enum">
361         <xsd:complexType>
362           <xsd:sequence minOccurs="1" maxOccurs="unbounded">
363             <xsd:element name="item">
364               <xsd:complexType>
365                 <xsd:choice minOccurs="1" maxOccurs="1">
366                   <xsd:element name="value" type="xsd:unsignedInt" />
367                   <xsd:element name="bit" type="bitType" />
368                 </xsd:choice>
369                 <xsd:attribute name="name" type="xsd:string" use="required" />
370               </xsd:complexType>
371             </xsd:element>
372             <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
373           </xsd:sequence>
374           <xsd:attribute name="name" type="xsd:string" use="required" />
375         </xsd:complexType>
376       </xsd:element>
377       <xsd:element name="typedef">
378         <xsd:complexType>
379           <xsd:attribute name="oldname" type="xsd:string" use="required" />
380           <xsd:attribute name="newname" type="xsd:string" use="required" />
381         </xsd:complexType>
382       </xsd:element>
383       <!-- The import element allows a protocol description to reference the
384            declarations of another protocol description. -->
385       <xsd:element name="import" type="xsd:string" />
386     </xsd:choice>
387   </xsd:group>
388 </xsd:schema>