forked from FLAME-HPC/xparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmml.xsd
590 lines (530 loc) · 18.3 KB
/
xmml.xsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Description : XMML Schema for FLAME
Project URL : http://http://ccpforge.cse.rl.ac.uk/gf/project/xagents/
Schema Author : Shawn Chin (STFC Rutherford Appleton Laboratory)
SVN Revision : $Id$
</xs:documentation>
</xs:annotation>
<!-- TODO:
* check that "unit" is a valid base unit (xs:keyref?)
* check that "type" is a valid data type (xs:keyref)
(alas, the two items above cannot be achieved using XML Schema alone)
-->
<!-- DERIVED TYPES -->
<xs:simpleType name="trueFalseString">
<xs:restriction base="xs:string">
<xs:enumeration value="true" />
<xs:enumeration value="false" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="sortOrderString">
<xs:restriction base="xs:string">
<xs:enumeration value="ascend" />
<xs:enumeration value="descend" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CSourceFilename">
<xs:restriction base="xs:string">
<xs:pattern value=".+\.c" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="XMLFilename">
<xs:restriction base="xs:string">
<xs:pattern value=".+\.[xX][mM][lL]" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="opString">
<xs:restriction base="xs:string">
<xs:enumeration value="EQ" />
<xs:enumeration value="NEQ" />
<xs:enumeration value="LEQ" />
<xs:enumeration value="GEQ" />
<xs:enumeration value="LT" />
<xs:enumeration value="GT" />
<xs:enumeration value="IN" />
<xs:enumeration value="AND" />
<xs:enumeration value="OR" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="variableType">
<xs:all>
<xs:element name="name" type="xs:string" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="type" type="xs:string" />
</xs:all>
</xs:complexType>
<xs:complexType name="agentMemoryVariableType">
<xs:all>
<xs:element name="name" type="xs:string" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="constant" type="trueFalseString" minOccurs="0" />
<xs:element name="type" type="xs:string" />
</xs:all>
</xs:complexType>
<xs:complexType name="datatypeType">
<xs:all>
<xs:element name="name" type="xs:string" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="variables">
<xs:complexType>
<xs:sequence>
<xs:element name="variable" type="variableType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name="filterSegmentType">
<xs:choice>
<xs:element name="value" type="xs:string" />
<xs:group ref="filterParamGroup" />
<xs:element name="not">
<xs:complexType>
<xs:sequence>
<xs:group ref="filterParamGroup" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:group name="filterParamGroup">
<xs:sequence>
<xs:element name="lhs" type="filterSegmentType" />
<xs:element name="op" type="opString" />
<xs:element name="rhs" type="filterSegmentType" />
</xs:sequence>
</xs:group>
<xs:complexType name="conditionTimeType">
<xs:sequence>
<xs:element name="period" type="xs:string" />
<xs:element name="phase" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:group name="conditionChoiceGroup">
<xs:choice>
<xs:element name="time" type="conditionTimeType" />
<xs:group ref="conditionParamGroup" />
</xs:choice>
</xs:group>
<xs:complexType name="conditionSegmentType">
<xs:choice>
<xs:element name="value" type="xs:string" />
<xs:group ref="conditionChoiceGroup" />
<xs:element name="not">
<xs:complexType>
<xs:group ref="conditionChoiceGroup" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:group name="conditionParamGroup">
<xs:sequence>
<xs:element name="lhs" type="conditionSegmentType" />
<xs:element name="op" type="opString" />
<xs:element name="rhs" type="conditionSegmentType" />
</xs:sequence>
</xs:group>
<xs:complexType name="conditionType">
<xs:choice>
<xs:group ref="conditionChoiceGroup" />
<xs:element name="not">
<xs:complexType>
<xs:group ref="conditionChoiceGroup" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- LOW LEVEL ELEMENTS -->
<xs:element name="input">
<xs:complexType>
<xs:all>
<xs:element name="messageName" type="xs:string" />
<xs:element name="random" type="trueFalseString" minOccurs="0"/>
<xs:element name="filter" minOccurs="0">
<xs:complexType>
<xs:group ref="filterParamGroup" />
</xs:complexType>
</xs:element>
<xs:element name="sort" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="key" type="xs:string" />
<xs:element name="order" type="sortOrderString" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="output">
<xs:complexType>
<xs:sequence>
<xs:element name="messageName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="function">
<!-- used in agents/xagent/functions -->
<xs:complexType>
<xs:all>
<xs:element name="name" type="xs:string" />
<xs:element name="description" type="xs:string" minOccurs="0" />
<xs:element name="currentState" type="xs:string" />
<xs:element name="nextState" type="xs:string" />
<xs:element name="condition" type="conditionType" minOccurs="0" />
<xs:element name="inputs" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="input" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="outputs" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="output" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<!-- 3rd LEVEL ELEMENTS -->
<xs:element name="xagent">
<xs:complexType>
<xs:all>
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>Name of agent</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="description" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Description of agent</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="memory">
<xs:annotation>
<xs:documentation>List of agent memory variables</xs:documentation>
</xs:annotation>
<!-- possibly empty (memory defined in parent model) -->
<xs:complexType>
<xs:sequence>
<xs:element name="variable" type="agentMemoryVariableType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Memory variable for this agent</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="functions" minOccurs="0">
<xs:annotation>
<xs:documentation>List of agent transition functions</xs:documentation>
</xs:annotation>
<!-- can possibly be empty if agent functions defined in nested
model -->
<xs:complexType>
<xs:sequence>
<xs:element ref="function" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Transition function for this agent</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="constants">
<!-- used in environment -->
<xs:complexType>
<xs:sequence>
<xs:element name="variable" type="variableType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Environment constant</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="functionFiles">
<!-- used in environment -->
<xs:complexType>
<xs:sequence>
<xs:element name="file" type="CSourceFilename" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>
C source file that contains agent functions (use relative path)
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dataTypes">
<!-- used in environment -->
<xs:complexType>
<xs:sequence>
<xs:element name="dataType" type="datatypeType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Custom datatype</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="timeUnits">
<!-- used in environment -->
<xs:complexType>
<xs:sequence>
<xs:element name="timeUnit" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Custom time unit</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>Name of time unit</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="unit" type="xs:string">
<xs:annotation>
<xs:documentation>
Base unit - either "iteration" or name of another custom time unit
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="period" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>
Multiple of base unit represented by this custom time unit
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- 2nd LEVEL ELEMENTS -->
<xs:element name="models">
<xs:complexType>
<xs:sequence>
<xs:element name="model" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Link to nested model</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="file" type="XMLFilename">
<xs:annotation>
<xs:documentation>
XML file of nested model (use relative path)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="enabled" type="trueFalseString">
<xs:annotation>
<xs:documentation>
Is this nested model enabled? ("true" or "false")
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="environment">
<xs:complexType>
<xs:all>
<xs:element ref="constants" minOccurs="0">
<xs:annotation>
<xs:documentation>List of environment constants</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="functionFiles" minOccurs="0">
<xs:annotation>
<xs:documentation>
List of C source files where functions are defined
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="dataTypes" minOccurs="0">
<xs:annotation>
<xs:documentation>List of custom datatypes
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="timeUnits" minOccurs="0">
<xs:annotation>
<xs:documentation>List of custom time units
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="agents">
<xs:complexType>
<xs:sequence>
<xs:element ref="xagent" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Agent definition</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="messages">
<xs:complexType>
<xs:sequence>
<xs:element name="message" type="datatypeType" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Message definition</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- ROOT ELEMENT = xmodel -->
<xs:element name="xmodel">
<xs:complexType>
<xs:all>
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>Model name</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="version" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Model version</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="author" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Model author</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="description" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Model description</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="models" minOccurs="0">
<xs:annotation>
<xs:documentation>List of nested models</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="environment" minOccurs="0">
<xs:annotation>
<xs:documentation>Environment data</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="agents">
<xs:annotation>
<xs:documentation>List of agent types</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="messages" minOccurs="0">
<xs:annotation>
<xs:documentation>List of message types</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="version" type="xs:string" use="required"/>
</xs:complexType>
<!-- CONSTRAINTS -->
<xs:unique name="agentNameUnique">
<xs:annotation>
<xs:documentation>
Names of agents must be unique
</xs:documentation>
</xs:annotation>
<xs:selector xpath="agents/xagent" />
<xs:field xpath="name" />
</xs:unique>
<xs:unique name="envConstantNameUnique">
<xs:annotation>
<xs:documentation>
Names of environment constants must be unique
</xs:documentation>
</xs:annotation>
<xs:selector xpath="environment/constants/variable" />
<xs:field xpath="name" />
</xs:unique>
<xs:unique name="timeUnitNameUnique">
<xs:annotation>
<xs:documentation>
Names of custom time units must be unique
</xs:documentation>
</xs:annotation>
<xs:selector xpath="environment/timeUnits/timeUnit" />
<xs:field xpath="name" />
</xs:unique>
<xs:unique name="dataTypeNameUnique">
<xs:annotation>
<xs:documentation>
Names of custom datatypes must be unique
</xs:documentation>
</xs:annotation>
<xs:selector xpath="environment/dataTypes/dataType" />
<xs:field xpath="name" />
</xs:unique>
<xs:unique name="modelFileUnique">
<xs:annotation>
<xs:documentation>
Each nested model should only be referenced once
</xs:documentation>
</xs:annotation>
<xs:selector xpath="models/model" />
<xs:field xpath="file" />
</xs:unique>
<xs:unique name="functionFileUnique">
<xs:annotation>
<xs:documentation>
Each C source file should only be referenced once
</xs:documentation>
</xs:annotation>
<xs:selector xpath="environment/functionFiles/file" />
<xs:field xpath="." />
</xs:unique>
<xs:key name="messageNameKey">
<xs:annotation>
<xs:documentation>
Names of messages must be unique.
Referenced by other nodes in the model.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="messages/message" />
<xs:field xpath="name" />
</xs:key>
<xs:keyref name="outputMessageRef" refer="messageNameKey">
<xs:annotation>
<xs:documentation>
messageName must refer to a valid message
</xs:documentation>
</xs:annotation>
<xs:selector xpath="agents/xagent/functions/function/outputs/output" />
<xs:field xpath="messageName" />
</xs:keyref>
<xs:keyref name="inputMessageRef" refer="messageNameKey">
<xs:annotation>
<xs:documentation>
messageName must refere to a valid message
</xs:documentation>
</xs:annotation>
<xs:selector xpath="agents/xagent/functions/function/inputs/input" />
<xs:field xpath="messageName" />
</xs:keyref>
</xs:element>
</xs:schema>