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