xcb-schema: add listelement-ref
[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:sequence>
166             <xsd:group ref="expression" minOccurs="0" maxOccurs="1"/>
167           </xsd:sequence>
168           <xsd:attribute name="ref" use="required" type="xsd:string" />
169         </xsd:complexType>
170       </xsd:element>
171       <xsd:element name="listelement-ref" />
172       <xsd:element name="value" type="xsd:integer" />
173       <xsd:element name="bit" type="bitType" />
174     </xsd:choice>
175   </xsd:group>
176   
177   <!-- Fields in requests that are calculated from other information, not
178        supplied by the caller. -->
179   <xsd:element name="exprfield" >
180     <xsd:complexType>
181       <xsd:complexContent>
182         <xsd:extension base="var">
183           <xsd:group ref="expression" />
184         </xsd:extension>
185       </xsd:complexContent>
186     </xsd:complexType>
187   </xsd:element>
188
189   <!-- BITMASK/LISTofVALUE parameter pairs. -->
190   <xsd:element name="valueparam">
191     <xsd:complexType>
192       <xsd:attribute name="value-mask-type" type="xsd:string" use="required" />
193       <xsd:attribute name="value-mask-name" type="xsd:string" use="required" />
194       <xsd:attribute name="value-list-name" type="xsd:string" use="required" />
195     </xsd:complexType>
196   </xsd:element>
197
198   <xsd:group name="fields">
199     <xsd:choice>
200       <xsd:element ref="pad" />
201       <xsd:element ref="field" />
202       <xsd:element ref="list" />
203       <xsd:element ref="fd" />
204     </xsd:choice>
205   </xsd:group>
206
207   <!-- Type for a structure -->
208   <xsd:complexType name="struct">
209     <xsd:sequence>
210       <xsd:group ref="fields" minOccurs="1" maxOccurs="unbounded" />
211       <xsd:choice minOccurs="0" maxOccurs="1">
212         <xsd:element ref="switch" />
213       </xsd:choice>
214     </xsd:sequence>
215     <xsd:attribute name="name" type="xsd:string" use="required" />
216   </xsd:complexType>
217
218   <!-- Type for a packet structure -->
219   <xsd:complexType name="packet-struct">
220     <xsd:sequence>
221       <xsd:group ref="fields" minOccurs="0" maxOccurs="unbounded" />
222     </xsd:sequence>
223     <xsd:attribute name="name" type="xsd:string" use="required" />
224     <xsd:attribute name="number" type="xsd:integer" use="required" />
225   </xsd:complexType>
226
227   <!-- Type for a packet structure copy -->
228   <xsd:complexType name="packet-struct-copy">
229     <xsd:attribute name="name" type="xsd:string" use="required" />
230     <xsd:attribute name="number" type="xsd:integer" use="required" />
231     <xsd:attribute name="ref" type="xsd:string" use="required" />
232   </xsd:complexType>
233
234   <!-- Type for bit values -->
235   <xsd:simpleType name="bitType">
236     <xsd:restriction base="xsd:integer">
237       <xsd:minInclusive value="0" />
238       <xsd:maxExclusive value="32" />
239     </xsd:restriction>
240   </xsd:simpleType>
241
242   <!-- Type for documentation -->
243   <xsd:group name="doc-fields">
244     <xsd:sequence>
245       <xsd:element name="field">
246         <xsd:complexType>
247           <xsd:simpleContent>
248             <xsd:extension base="xsd:string">
249               <xsd:attribute name="name" type="xsd:string" />
250             </xsd:extension>
251           </xsd:simpleContent>
252         </xsd:complexType>
253       </xsd:element>
254     </xsd:sequence>
255   </xsd:group>
256
257   <xsd:group name="error-fields">
258     <xsd:sequence>
259       <xsd:element name="error">
260         <xsd:complexType>
261           <xsd:simpleContent>
262             <xsd:extension base="xsd:string">
263               <xsd:attribute name="type" type="xsd:string" />
264             </xsd:extension>
265           </xsd:simpleContent>
266         </xsd:complexType>
267       </xsd:element>
268     </xsd:sequence>
269   </xsd:group>
270
271   <xsd:group name="see-fields">
272     <xsd:sequence>
273       <xsd:element name="see">
274         <xsd:complexType>
275           <xsd:attribute name="name" type="xsd:string" />
276           <xsd:attribute name="type" type="xsd:string" />
277         </xsd:complexType>
278       </xsd:element>
279     </xsd:sequence>
280   </xsd:group>
281
282   <xsd:element name="doc">
283     <xsd:complexType mixed="true">
284       <xsd:sequence>
285         <xsd:element name="brief" type="xsd:string" minOccurs="0" maxOccurs="1" />
286         <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1" />
287         <xsd:element name="example" type="xsd:string" minOccurs="0" maxOccurs="1" />
288         <xsd:group ref="doc-fields" minOccurs="0" maxOccurs="unbounded" />
289         <xsd:group ref="error-fields" minOccurs="0" maxOccurs="unbounded" />
290         <xsd:group ref="see-fields" minOccurs="0" maxOccurs="unbounded" />
291       </xsd:sequence>
292     </xsd:complexType>
293   </xsd:element>
294
295   <xsd:group name="macro">
296     <xsd:choice>
297       <xsd:element name="request">
298         <xsd:complexType>
299           <xsd:sequence>
300             <xsd:choice minOccurs="0" maxOccurs="unbounded">
301               <xsd:group ref="fields" />
302               <xsd:element ref="exprfield" />
303               <xsd:element ref="valueparam" />
304             </xsd:choice>
305             <xsd:choice minOccurs="0" maxOccurs="1">
306               <xsd:element ref="switch" />
307             </xsd:choice>
308             <xsd:element name="reply" minOccurs="0" maxOccurs="1">
309               <xsd:complexType>
310                 <xsd:sequence>
311                   <xsd:choice minOccurs="1" maxOccurs="unbounded">
312                     <xsd:group ref="fields" />
313                     <xsd:element ref="valueparam" />
314                   </xsd:choice>
315                   <xsd:choice minOccurs="0" maxOccurs="1">
316                     <xsd:element ref="switch" />
317                   </xsd:choice>
318                   <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
319                 </xsd:sequence>
320               </xsd:complexType>
321             </xsd:element>
322             <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
323           </xsd:sequence>
324           <xsd:attribute name="name" type="xsd:string" use="required" />
325           <xsd:attribute name="opcode" type="xsd:integer" use="required" />
326           <xsd:attribute name="combine-adjacent" type="xsd:boolean"
327                          use="optional" default="false" />
328         </xsd:complexType>
329       </xsd:element>
330       <xsd:element name="event">
331         <xsd:complexType>
332           <xsd:complexContent>
333             <xsd:extension base="packet-struct">
334               <xsd:sequence>
335                 <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
336               </xsd:sequence>
337               <xsd:attribute name="no-sequence-number" type="xsd:boolean"
338                              use="optional" default="false" />
339               <xsd:attribute name="xge" type="xsd:boolean"
340                              use="optional" default="false" />
341             </xsd:extension>
342           </xsd:complexContent>
343         </xsd:complexType>
344       </xsd:element>
345       <xsd:element name="eventcopy" type="packet-struct-copy" />
346       <xsd:element name="error" type="packet-struct" />
347       <xsd:element name="errorcopy" type="packet-struct-copy" />
348       <xsd:element name="struct" type="struct" />
349       <xsd:element name="union" type="struct" />
350       <xsd:element name="xidtype">
351         <xsd:complexType>
352           <xsd:attribute name="name" type="xsd:string" use="required" />
353         </xsd:complexType>
354       </xsd:element>
355       <xsd:element name="xidunion">
356         <xsd:complexType>
357           <xsd:sequence>
358             <xsd:element name="type" type="xsd:string"
359                          minOccurs="1" maxOccurs="unbounded" />
360           </xsd:sequence>
361           <xsd:attribute name="name" type="xsd:string" use="required" />
362         </xsd:complexType>
363       </xsd:element>
364       <xsd:element name="enum">
365         <xsd:complexType>
366           <xsd:sequence minOccurs="1" maxOccurs="unbounded">
367             <xsd:element name="item">
368               <xsd:complexType>
369                 <xsd:choice minOccurs="1" maxOccurs="1">
370                   <xsd:element name="value" type="xsd:unsignedInt" />
371                   <xsd:element name="bit" type="bitType" />
372                 </xsd:choice>
373                 <xsd:attribute name="name" type="xsd:string" use="required" />
374               </xsd:complexType>
375             </xsd:element>
376             <xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
377           </xsd:sequence>
378           <xsd:attribute name="name" type="xsd:string" use="required" />
379         </xsd:complexType>
380       </xsd:element>
381       <xsd:element name="typedef">
382         <xsd:complexType>
383           <xsd:attribute name="oldname" type="xsd:string" use="required" />
384           <xsd:attribute name="newname" type="xsd:string" use="required" />
385         </xsd:complexType>
386       </xsd:element>
387       <!-- The import element allows a protocol description to reference the
388            declarations of another protocol description. -->
389       <xsd:element name="import" type="xsd:string" />
390     </xsd:choice>
391   </xsd:group>
392 </xsd:schema>