-
Notifications
You must be signed in to change notification settings - Fork 2
/
swiML.xsd
981 lines (914 loc) · 48.2 KB
/
swiML.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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified"
vc:minVersion="1.1" xmlns:sw="https://github.com/bartneck/swiML"
targetNamespace="https://github.com/bartneck/swiML" xmlns="https://github.com/bartneck/swiML"
version="2.1">
<!-- version 2.3 -->
<xs:element name="program">
<!-- ====================================================== -->
<!-- The meta information for each program -->
<!-- ====================================================== -->
<xs:complexType>
<xs:sequence>
<!-- The title of the program -->
<xs:element name="title" type="titleString" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>A short title of the program.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- The author(s) of the program -->
<xs:element maxOccurs="unbounded" minOccurs="0" name="author">
<xs:annotation>
<xs:documentation>Each program can have one or more
authors.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" minOccurs="1" type="xs:string">
<xs:annotation>
<xs:documentation>The first name of the author. Can contain
middle names if necessary.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lastName" minOccurs="1" type="xs:string">
<xs:annotation>
<xs:documentation>The last name of the
author.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="email" type="emailAddress">
<xs:annotation>
<xs:documentation>The email address of the author
(optional).</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- The description of the program -->
<xs:element name="programDescription" type="descriptionString" minOccurs="0"
maxOccurs="1">
<xs:annotation>
<xs:documentation>A short description for the program.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- The date -->
<xs:element minOccurs="0" name="creationDate" type="xs:date" maxOccurs="1"
default="2022-02-22">
<xs:annotation>
<xs:documentation>The date on which the program was
created.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="poolLength" minOccurs="1" maxOccurs="1" type="xs:nonNegativeInteger" default="25">
<xs:annotation>
<xs:documentation>The length of pool</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lengthUnit" minOccurs="1" maxOccurs="1" type="lengthUnits" default="meters">
<xs:annotation>
<xs:documentation>The length of pool requires a measurement
unit.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="programAlign" minOccurs="0" maxOccurs="1" type="xs:boolean" >
<xs:annotation>
<xs:documentation>When set to False all elements in the program will not align</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="numeralSystem" minOccurs="0" maxOccurs="1" type="numeralSystems">
<xs:annotation>
<xs:documentation>Can set to different numeral systems to display</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Element to hide the intro text -->
<xs:element name="hideIntro" minOccurs="0" maxOccurs="1" type="xs:boolean">
<xs:annotation>
<xs:documentation>True if intro should be hidden in
output.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Element to set the width of the program in HTML -->
<!-- The unit is characters. 50ch are 11cm wide -->
<xs:element name="layoutWidth" minOccurs="0" maxOccurs="1" type="xs:nonNegativeInteger" default="50">
<xs:annotation>
<xs:documentation>The width of the program on the HTML page. The unit is characters. 50ch are 11cm wide.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ====================================================== -->
<!-- The main element(s) for each program. Each instruction can contain instructions. This is recursion. -->
<!-- This is the main recursive element for a program -->
<!-- ====================================================== -->
<xs:element name="instruction" type="instructionType" minOccurs="1"
maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>The basic elements for programs. Each instruction defines
what to swim.</xs:documentation>
</xs:annotation>
<xs:unique name="mainEquipmentUnique">
<xs:annotation>
<xs:documentation>Ensures all equipment values in an instruction are
unique</xs:documentation>
</xs:annotation>
<xs:selector xpath="./sw:equipment"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
<xs:assert test="
every $inst in .//sw:instruction
satisfies (
($inst/ancestor-or-self::*/sw:stroke
and $inst/ancestor-or-self::*/sw:length)
or $inst/sw:repetition
or $inst/sw:continue
or $inst/sw:pyramid
or $inst/sw:segmentName)
">
<xs:annotation>
<xs:documentation>checks every instruction has stroke, rest and length defined
any other element in an instruction doesnt have to be defined</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
</xs:element>
<!-- ====================================================== -->
<!-- The types used for the meta information -->
<!-- ====================================================== -->
<!-- The definition of the valid email address -->
<xs:simpleType name="emailAddress">
<xs:annotation>
<xs:documentation>The pattern checks for valid email addresses.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[^@]+@[^\.]+\..+"/>
</xs:restriction>
</xs:simpleType>
<!-- The definition of the program title restriction in length -->
<xs:simpleType name="titleString">
<xs:annotation>
<xs:documentation>The length of the title is constraint in length.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
<!-- The definition of the program description restriction in length -->
<xs:simpleType name="descriptionString">
<xs:annotation>
<xs:documentation>The length of the description text is constraint in
length.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="400"/>
</xs:restriction>
</xs:simpleType>
<!-- Units of measurement for pool length -->
<xs:simpleType name="lengthUnits">
<xs:annotation>
<xs:documentation>The unit of measurement for the length of the target pool (meter or
yards).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="meters"/>
<xs:enumeration value="kilometers"/>
<xs:enumeration value="miles"/>
<xs:enumeration value="yards"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="numeralSystems">
<xs:annotation>
<xs:documentation>Numeral system type to be used for displaying the document</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="decimal"/>
<xs:enumeration value="roman"/>
</xs:restriction>
</xs:simpleType>
<!-- ====================================================== -->
<!-- The basic type for all instructions. It can be either a -->
<!-- process element or a direction instruction on what to swim -->
<!-- ====================================================== -->
<!-- The fundamental building block of all swimmming programs -->
<xs:complexType name="instructionType" mixed="true">
<xs:annotation>
<xs:documentation>An instruction can consists of process or a direct instruction on what
to swim.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice>
<xs:annotation>
<xs:documentation>The different types of instructions,</xs:documentation>
</xs:annotation>
<!-- ====================================================== -->
<!-- Process based elements for instructions -->
<xs:element name="segmentName" minOccurs="0" maxOccurs="1" type="segmentNameType"/>
<xs:element name="repetition" type="repetitionType">
<xs:annotation>
<xs:documentation>Instruction process element to repeat enclosed
instructions.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="pyramid" type="pyramidType">
<xs:annotation>
<xs:documentation>Instruction process element to swim a
pyramid.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="continue" type="continueType">
<xs:annotation>
<xs:documentation>Instruction process element to denote a continuosly swum block
of instructions.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- ====================================================== -->
<!-- Direct instruction on what to swim -->
<xs:group ref="instructionGroup"/>
</xs:choice>
<xs:element name="excludeAlign" type="xs:boolean" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>If true xslt will exclude from alignment
process</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<!-- checks every instruction has stroke, rest and length defined
any other element in an instruction doesnt have to be defined-->
<xs:assert test="
(./ancestor-or-self::*/sw:stroke
and ./ancestor-or-self::*/sw:length)
or ./sw:repetition
or ./sw:continue
or ./sw:pyramid
or ./sw:segmentName
">
<xs:annotation>
<xs:documentation>
checks every instruction has stroke, rest and length defined
any other element in an instruction doesnt have to be defined
</xs:documentation>
</xs:annotation>
</xs:assert>
<!-- checks every instruction doesnt have repetitions of elements defined and cannot be extended -->
<xs:assert test="
if (not(./sw:repetition
or ./sw:continue
or ./sw:pyramid
or ./sw:segmentName))
then
(
every $element in ./*
satisfies (
every $match in ./ancestor::*[name() = 'instruction' or name() = 'repetition' or name() = 'continue' or name() = 'pyramid'][not(./sw:repetition or ./sw:continue or ./sw:pyramid or ./sw:segmentName)]/*[name() = 'length' or name() = 'stroke' or name() = 'rest' or name() = 'intensity' or name() = 'breath' or name() = 'underwater']
satisfies
not(name($element) = name($match))
))
else
(true())
">
<xs:annotation>
<xs:documentation>
returns false if any instruction has a repeating element, e.g two different defined lengths
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="
if (not(./sw:repetition
or ./sw:continue
or ./sw:pyramid
or ./sw:segmentName))
then
(
every $element in ./*[name() = 'equipment']
satisfies (
every $match in ./ancestor::*[name() = 'instruction' or name() = 'repetition' or name() = 'continue' or name() = 'pyramid'][not(./sw:repetition or ./sw:continue or ./sw:pyramid or ./sw:segmentName)]/*[name() = 'equipment']
satisfies
not($element/text() = $match/text())
))
else
(true())
">
<xs:annotation>
<xs:documentation>
returns false if any instruction has a repeating equipment, e.g two seperate equipment elements both containing fins
</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="
if (count(./sw:segmentName) > 0)
then
(count(./sw:segmentName/../../ancestor::*) = 0)
else
(true())
">
<xs:annotation>
<xs:documentation>
returns false if any segmentName element is not at the top level e.g. it is nested within a repetition
</xs:documentation>
</xs:annotation>
</xs:assert>
<!-- work out a way to divide contlength by the sum of its children so it actually works, cos it doesnt atm -->
<xs:assert test="
every $stroke in ./sw:stroke
satisfies
if ($stroke/sw:standardStroke = 'individualMedleyOrder' or $stroke/sw:standardStroke = 'reverseIndividualMedleyOrder'
or $stroke/sw:kicking/sw:standardKick = 'individualMedleyOrder' or $stroke/sw:kicking/sw:standardKick = 'reverseIndividualMedleyOrder'
or $stroke/sw:drill/sw:drillStroke = 'individualMedleyOrder' or $stroke/sw:drill/sw:drillStroke = 'reverseIndividualMedleyOrder')
then
(sum($stroke/ancestor::*/sw:repetition/sw:repetitionCount[not(ancestor::sw:continue)]) > 0 and
((sum(for $n in $stroke/ancestor::*/sw:repetition/sw:repetitionCount[not(ancestor::sw:continue)] return if ($n mod 4 = 0) then 1 else 0) > 0)or(sum(for $n in $stroke/ancestor::*/sw:repetition/sw:repetitionCount return if ($n mod 2 = 0) then 1 else 0) > 1)))
or
($stroke/ancestor::*/sw:continue/sw:continueLength and
(every $cont in $stroke/ancestor::*/sw:continue satisfies ($cont/sw:continueLength mod 4 = 0)))
else
($stroke/parent::*)
">
<xs:annotation>
<xs:documentation>checks all strokes to make sure medley order are only
used in a repetition or continue that is divisible by 4</xs:documentation>
</xs:annotation>
</xs:assert>
<!-- may need to make 2 different types for every 2: flbk bkbr brfr or 3: flbkbr bkbrfr
Also may need to denote if you include the others like frfl or brfrfl, frflbk cos sometimes you do -->
<xs:assert test="
every $stroke in ./sw:stroke
satisfies
if ($stroke/sw:standardStroke = 'individualMedleyOverlap'
or $stroke/sw:kicking/sw:standardKick = 'individualMedleyOverlap'
or $stroke/sw:drill/sw:drillStroke = 'individualMedleyOverlap' )
then
(sum($stroke/ancestor::*/sw:repetition/sw:repetitionCount) > 0 and (sum($stroke/ancestor::*/sw:repetition/sw:repetitionCount) mod 3 = 0 or sum($stroke/ancestor::*/sw:repetition/sw:repetitionCount) mod 2 = 0))
else
($stroke/parent::*)
">
<xs:annotation>
<xs:documentation>checks all strokes to make sure medley overlap is only
used in a repetition or continue that is divisible by 2 or 3</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
<!-- ====================================================== -->
<!-- Group of elements for instruction types and process -->
<!-- instruction types. -->
<!-- ====================================================== -->
<xs:group name="instructionGroup">
<xs:sequence>
<xs:annotation>
<xs:documentation>Sequence of basic elements for an
instruction.</xs:documentation>
</xs:annotation>
<xs:element name="length" minOccurs="0" maxOccurs="1" type="lengthType">
<xs:annotation>
<xs:documentation>The length of the instruction.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="stroke" minOccurs="0" maxOccurs="1" type="strokeType">
<xs:annotation>
<xs:documentation>The stroke to swim. This includes basic strokes, kicking and
drills.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="rest" minOccurs="0" maxOccurs="1" type="restType">
<xs:annotation>
<xs:documentation>The rest period after the instruction.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="intensity" minOccurs="0" maxOccurs="1" type="intensityProfile">
<xs:annotation>
<xs:documentation>The intensity at which to swim the
instruction.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="breath" minOccurs="0" maxOccurs="1" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>Number of arm strokes per breath.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="underwater" minOccurs="0" maxOccurs="1" type="xs:boolean">
<xs:annotation>
<xs:documentation>True if swimming under water.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="equipment" minOccurs="0" maxOccurs="unbounded" type="equipmentType">
<xs:annotation>
<xs:documentation>Equipment to be used, such as board or
pads.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="instructionDescription" type="instructionDescriptionType"
minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Short description to modify the instrution.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:group>
<!-- ====================================================== -->
<!-- Process instruction types -->
<!-- These types control the structural flow of the -->
<!-- instructions. -->
<!-- ====================================================== -->
<!-- The repetitionType is one of the major process elements -->
<xs:complexType name="repetitionType">
<xs:annotation>
<xs:documentation/>
</xs:annotation>
<xs:sequence>
<xs:element name="repetitionCount" type="xs:nonNegativeInteger" minOccurs="0"
maxOccurs="1">
<xs:annotation>
<xs:documentation>Count of repetition.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="simplify" minOccurs="0" maxOccurs="1" type="xs:boolean">
<xs:annotation>
<xs:documentation>true -> repetition tag is simplifying a larger set of
repetitions false -> normal repetition </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="repetitionDescription" minOccurs="0" maxOccurs="1"
type="instructionDescriptionType">
<xs:annotation>
<xs:documentation>Additional information for the repetition. This can be used to
customise the repetition.</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Common elements for instructions -->
<xs:group ref="instructionGroup"/>
<!-- This is the main recursion statement. Every repetition contains instructions. -->
<!-- Every instruction can contain a repetition -->
<xs:element name="instruction" minOccurs="1" maxOccurs="unbounded"
type="instructionType">
<xs:annotation>
<xs:documentation>A repetition can include any number of instructions, which in
turn can contain repetitions or continues.</xs:documentation>
</xs:annotation>
<xs:unique name="repEquipmentUnique">
<xs:annotation>
<xs:documentation>Ensures all equipment values in an instruction are
unique</xs:documentation>
</xs:annotation>
<xs:selector xpath="./sw:equipment"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
<!-- ====================================================== -->
<!-- Assertions -->
<xs:assert test="
if(./sw:simplify = true())then(
(
every $instruction in ./sw:instruction[not(./sw:pyramid or ./sw:segmentName)] satisfies(
(if($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)]) then(
if(count($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)]) = 1) then(
number(
($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsDistance
)
) else(
sum(
($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsDistance
)
)
) else(
0
)+(
if($instruction/descendant-or-self::sw:continueLength) then(
number($instruction/descendant-or-self::sw:continueLength)
) else(
0
)
)) = number(
(
(
(./descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsDistance
) | (
./descendant-or-self::sw:continueLength
)
)[1]
)
)
)or(
every $instruction in ./sw:instruction[not(./sw:pyramid or ./sw:segmentName)] satisfies(
(if($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)]) then(
if(count($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)]) = 1) then(
number(
($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsLaps
)
) else(
sum(
($instruction/descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsLaps
)
)
) else(
0
)+(
if($instruction/descendant-or-self::sw:continueLength) then(
number(
$instruction/descendant-or-self::sw:continueLength
)
) else(
0
)
)) = number(
(
(
(./descendant-or-self::sw:instruction[not(ancestor::sw:continue/sw:continueLength) and not(./sw:continue/sw:continueLength) and not(./sw:repetition)][1])//(preceding-sibling::sw:length | ancestor-or-self::*/sw:length)[last()]/sw:lengthAsLaps
) | (
./descendant-or-self::sw:continueLength
)
)[1]
)
)
)
)else(
true()
)
">
<xs:annotation>
<xs:documentation>checks all lengths within simplified repetition are the same
Does this by using two seperate statments so that either all lengthAsDistances are the same or all lengthAsLaps
checks that every instruction, repetition and continue has the same base length e.g. 100m , 4x100m and 50,50 swim as 100 ; these are all of length 100 so can be simplified in the same repetition
has to choose whether to use continueLength or add up all instructions within a continue
</xs:documentation>
</xs:annotation>
</xs:assert>
<!-- Explain what this assertion does -->
<!-- removed and not(./sw:simplify[text() = 'true'] and ./sw:repetitionCount) not sure if needed, will have to test more -->
<xs:assert
test="./sw:simplify[text() = 'true'] or ./sw:repetitionCount "/>
</xs:complexType>
<!-- A pyramid is a common structure element for programs. -->
<xs:complexType name="pyramidType">
<xs:annotation>
<xs:documentation>Pyramids start with short instructions (e.g. 50) and increase to their
stop length (e.g. 200). They then decrease back to the start
length.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="startLength" minOccurs="1" maxOccurs="1" type="lengthType">
<xs:annotation>
<xs:documentation>The start length of the pyramid.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="stopLength" minOccurs="1" maxOccurs="1" type="lengthType">
<xs:annotation>
<xs:documentation>The stop length of the pyramid. This is the highest point of
the pyramid.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="increment" minOccurs="1" maxOccurs="1" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>The increment at which the pyramid increases. This defines the
slope.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="incremenentLengthUnit" type="lengthUnits" minOccurs="0"
maxOccurs="1"/>
<xs:element name="isPointy" minOccurs="1" maxOccurs="1" type="xs:boolean">
<xs:annotation>
<xs:documentation>A pointy pyramid swims the stop length only once. A non-pointy
pyramid swims the stop length twice.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:group ref="instructionGroup"/>
</xs:sequence>
<xs:assert test="
(./sw:startLength/sw:lengthAsDistance and ./sw:stopLength/sw:lengthAsDistance)
or (./sw:startLength/sw:lengthAsLaps and ./sw:stopLength/sw:lengthAsLaps)
or (./sw:startLength/sw:lengthAsTime and ./sw:stopLength/sw:lengthAsTime)
"></xs:assert>
</xs:complexType>
<!-- A continue represents a continuous block of swimming -->
<xs:complexType name="continueType">
<xs:annotation>
<xs:documentation> Continues for when different strokes, equipment or styles need to be
swum continuously </xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="continueLength" minOccurs="0" maxOccurs="1" type="lengthType">
<xs:annotation>
<xs:documentation>total length to swim continuously or total number of
repetitions May or may not be defined but if not it will automatically
calculated from given instructions</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Common elements for instructions -->
<xs:group ref="instructionGroup"/>
<xs:element name="instruction" minOccurs="1" maxOccurs="unbounded"
type="instructionType">
<xs:annotation>
<xs:documentation>A continue can include any number of instructions, which in
turn can contain repetitions or any other complex instruction
type.</xs:documentation>
</xs:annotation>
<xs:unique name="contEquipmentUnique">
<xs:annotation>
<xs:documentation>Ensures all equipment values in an instruction are
unique</xs:documentation>
</xs:annotation>
<xs:selector xpath="./sw:equipment"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:sequence>
<!-- ====================================================== -->
<!-- Assertions -->
<!-- Explain what this assertion does -->
<xs:assert test="(count(.//sw:instruction/sw:rest) = 0)">
<xs:annotation>
<xs:documentation>ensures no rest tags occur within the instructions of a continue
only at top level</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="
if (./sw:continueLength) then (number(sw:continueLength) mod (
(for $con in . return
sum(.//sw:length[not(ancestor::sw:repetition[count(./ancestor::*) > count($con/ancestor::*)])][not(ancestor::sw:continue/sw:continueLength[count(./ancestor::*) > count($con/sw:continueLength/ancestor::*)])]))
+ (for $con in . return sum(./*//sw:continueLength[not(../ancestor::sw:continue/sw:continueLength[count(./ancestor::*) > count($con/sw:continueLength/ancestor::*)])]))
+ (for $con in . return( if (.//sw:length[ancestor::sw:repetition[count(./ancestor::*) > count($con/ancestor::*)]]) then (for $inst in .//sw:length[ancestor::sw:repetition[count(./ancestor::*) > count($con/ancestor::*)]] return (number($inst) * sum($inst/ancestor::sw:repetition/sw:repetitionCount[count(./ancestor::*) > count($con/ancestor::*)]))) else (0)
))
) = 0 ) else (true())
">
<xs:annotation>
<xs:documentation>check that if continue length is defined it is divisible by the contents of the continue</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
<!-- ====================================================== -->
<!-- The types used for the instructions -->
<!-- ====================================================== -->
<!-- Swimming instructions can be given in these units -->
<!-- this is currently not used. It would force the unit to be -->
<!-- explicit with any lenth. Using a default length is better -->
<!-- Swimming instructions can be given in these units -->
<!-- this is currently not used. It would force the unit to be -->
<!-- explicit with any lenth. Using a default length is better -->
<xs:complexType name="lengthType" mixed="true">
<xs:annotation>
<xs:documentation>The length for a swimming instruction.</xs:documentation>
</xs:annotation>
<!-- Length as either distance, laps or time -->
<xs:choice>
<xs:annotation>
<xs:documentation>Length can be descriped as distance or time.</xs:documentation>
</xs:annotation>
<xs:element name="lengthAsDistance" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>Length of instruction as distance.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lengthAsTime" type="xs:duration">
<xs:annotation>
<xs:documentation>Duration starts with PT followed by int M and int S. For
example PT1M30S for 1:30.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lengthAsLaps" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>Length of instruction in number of laps.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- Rest can be given in these ways -->
<xs:complexType name="restType" mixed="true">
<xs:annotation>
<xs:documentation>The length units for a rest after a swimming
instruction.</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="afterStop" type="xs:duration">
<xs:annotation>
<xs:documentation>Duration of rest after stopping a swimming instruction.
Example: 20 seconds means that the swimmer will rest for 20 seconds after
stopping the current instructions.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="sinceStart" type="xs:duration">
<xs:annotation>
<xs:documentation>The interval on which swimming instructions start. Example: on
1:30 means that the next instructions starts after 1:30 from starting the
current instruction.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="sinceLastRest" type="xs:duration">
<xs:annotation>
<xs:documentation>The time since the end of the last rest. This is useful when
several instructions without a rest period are swum, followed by a since
start type rest.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="inOut" type="xs:nonNegativeInteger">
<xs:annotation>
<xs:documentation>Number of swimmers arriving. Example: 3rd in: Once the 3rd
swimmer in the lane arrives, the 1st swimmer starts.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- Intensity at which an instruction is swum -->
<xs:complexType name="intensityType">
<xs:annotation>
<xs:documentation>The intensity of the instructions.</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="percentageEffort" type="percentType">
<xs:annotation>
<xs:documentation>Effort in percentage. Example: 100 means maximum
effort.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="zone" type="zoneType">
<xs:annotation>
<xs:documentation>Effort in training zone.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="percentageHeartRate" type="percentType">
<xs:annotation>
<xs:documentation>Heart rate in percentage of maximum heart
rate.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
<!-- Working out the build option -->
<xs:complexType name="intensityProfile" mixed="true">
<xs:annotation>
<xs:documentation>The intensity of the instruction. When given at the lowest level just
start intensity indicates a constant intensity if the stop intensity is given then
it is a build within the instruction If the intensity is given at a higher level
(repetition or continue) just start intensity is the same constant for all child
instructions given a stop intensity then it is descending/ascending over the child
instructions</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="startIntensity" minOccurs="1" maxOccurs="1" type="intensityType"/>
<xs:element name="stopIntensity" minOccurs="0" maxOccurs="1" type="intensityType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="segmentNameType">
<xs:restriction base="xs:string">
<xs:maxLength value=" 50"/>
</xs:restriction>
</xs:simpleType>
<!-- Swimming instructions can be given in these units -->
<xs:simpleType name="zoneType">
<xs:annotation>
<xs:documentation>The intensity zone.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="easy"/>
<xs:enumeration value="threshold"/>
<xs:enumeration value="endurance"/>
<xs:enumeration value="racePace"/>
<xs:enumeration value="max"/>
</xs:restriction>
</xs:simpleType>
<!-- Percentage as an interger from 0-100 -->
<xs:simpleType name="percentType">
<xs:annotation>
<xs:documentation>The percent type specifies a value from 0 to 100.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<!-- Swimming instructions use these stroke types-->
<xs:complexType name="strokeType" mixed="true">
<xs:annotation>
<xs:documentation>Stroke types.</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="standardStroke" type="standardStrokeType"/>
<xs:element name="kicking" type="kickStyle"/>
<xs:element name="drill" type="drillType"/>
</xs:choice>
</xs:complexType>
<xs:simpleType name="standardStrokeType">
<xs:restriction base="xs:string">
<xs:enumeration value="butterfly"/>
<xs:enumeration value="backstroke"/>
<xs:enumeration value="breaststroke"/>
<xs:enumeration value="freestyle"/>
<xs:enumeration value="individualMedley"/>
<xs:enumeration value="reverseIndividualMedley"/>
<xs:enumeration value="individualMedleyOverlap"/>
<xs:enumeration value="individualMedleyOrder"/>
<xs:enumeration value="reverseIndividualMedleyOrder"/>
<xs:enumeration value="any"/>
<xs:enumeration value="nr1"/>
<xs:enumeration value="nr2"/>
<xs:enumeration value="nr3"/>
<xs:enumeration value="nr4"/>
<xs:enumeration value="notButterfly"/>
<xs:enumeration value="notBackstroke"/>
<xs:enumeration value="notBreaststroke"/>
<xs:enumeration value="notFreestyle"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="kickStyle">
<xs:choice>
<xs:sequence>
<xs:element name="orientation" type="orientationType" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>The orientation of the swimmers body.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="legMovement" type="legMovementType" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>The style of the leg movements.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:element name="standardKick" minOccurs="1" maxOccurs="1" type="standardStrokeType"/>
</xs:choice>
</xs:complexType>
<xs:simpleType name="legMovementType">
<xs:restriction base="xs:string">
<xs:enumeration value="flutter"/>
<xs:enumeration value="dolphin"/>
<xs:enumeration value="scissor"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="orientationType">
<xs:restriction base="xs:string">
<xs:enumeration value="front"/>
<xs:enumeration value="back"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
<xs:enumeration value="side"/>
<xs:enumeration value="vertical"/>
<xs:enumeration value="waka"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="equipmentType">
<xs:restriction base="xs:string">
<xs:enumeration value="board"/>
<xs:enumeration value="pads"/>
<xs:enumeration value="pullBuoy"/>
<xs:enumeration value="fins"/>
<xs:enumeration value="snorkle"/>
<xs:enumeration value="chute"/>
<xs:enumeration value="stretchCord"/>
</xs:restriction>
</xs:simpleType>
<!-- The equipment list allows for multiple equiopments, but only one of each type -->
<xs:simpleType name="equipmentList">
<xs:list itemType="equipmentType"/>
</xs:simpleType>
<xs:complexType name="drillType">
<xs:annotation>
<xs:documentation>Drill type consists of a drill name and a stroke. For example, this
could mean 6 kick drill freestyle.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="drillName" minOccurs="0" maxOccurs="1" type="drillNameType"/>
<xs:element name="drillStroke" type="standardStrokeType" maxOccurs="1" minOccurs="1">
<xs:annotation>
<xs:documentation>Drills are based on stroke types. For example, the drill 123
can be swum with freestyle or backstroke.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="drillNameType">
<xs:annotation>
<xs:documentation>Drill names.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="6KickDrill"/>
<xs:enumeration value="8KickDrill"/>
<xs:enumeration value="10KickDrill"/>
<xs:enumeration value="12KickDrill"/>
<xs:enumeration value="fingerTrails"/>
<xs:enumeration value="123"/>
<xs:enumeration value="bigDog"/>
<xs:enumeration value="scull"/>
<xs:enumeration value="singleArm"/>
<xs:enumeration value="any"/>
<xs:enumeration value="technic"/>
<xs:enumeration value="dogPaddle"/>
<xs:enumeration value="tarzan"/>
<xs:enumeration value="fist"/>
<xs:enumeration value="2Kick1Pull"/>
<xs:enumeration value="3Kick1Pull"/>
<xs:enumeration value="2Pull1Kick"/>
<xs:enumeration value="3Pull1Kick"/>
<xs:enumeration value="3Right3Left"/>
<xs:enumeration value="2Right2Left"/>
<xs:enumeration value="other"/>
</xs:restriction>
</xs:simpleType>
<!-- The definition of the instructions description restriction in length -->
<xs:simpleType name="instructionDescriptionType">
<xs:annotation>
<xs:documentation>The length of the description text is constraint in
length.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>