-
Notifications
You must be signed in to change notification settings - Fork 2
/
swiML.xsl
1607 lines (1404 loc) · 81.6 KB
/
swiML.xsl
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
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"
xmlns:myData="http://www.bartneck.de" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:sw="https://github.com/bartneck/swiML">
<!-- version 2.3 -->
<!-- global variables for space calculation -->
<xsl:variable name="gloalRoot" select="/"/>
<!-- variable for length of distance tags in any instruction -->
<xsl:variable name="instLengths" as="element()*">
<!-- check if there are any distance tags present -->
<xsl:choose>
<xsl:when test="//sw:length/sw:lengthAsDistance[not(../../sw:excludeAlign[text() = 'true'])] or
//sw:length/sw:lengthAsLaps[not(../../sw:excludeAlign[text() = 'true'])] or
//sw:length/sw:lengthAsTime[not(../../sw:excludeAlign[text() = 'true'])]">
<!-- there are distance tags so the result is not 0 -->
<!-- select each type of tag and add data to array -->
<!-- this data is the length of the string, section of tag, what parents the tag has and, unique location of tag -->
<!-- for each type of distance tag this is repeated and added to resultant array -->
<!-- length as distance tags-->
<xsl:if test="//sw:length/sw:lengthAsDistance[not(../../sw:excludeAlign[text() = 'true'])]">
<xsl:for-each select="//sw:length/sw:lengthAsDistance[not(../../sw:excludeAlign[text() = 'true'])]">
<Item>
<Length><xsl:value-of select="string-length(myData:number(.))"/></Length>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:if>
<!-- length as laps tags -->
<xsl:if test="//sw:length/sw:lengthAsLaps[not(../../sw:excludeAlign[text() = 'true'])]">
<xsl:for-each select="//sw:length/sw:lengthAsLaps[not(../../sw:excludeAlign[text() = 'true'])]">
<Item>
<Length><xsl:value-of select="string-length(myData:number(.))"/></Length>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:if>
<!-- length as time tags -->
<xsl:if test="//sw:length/sw:lengthAsTime[not(../../sw:excludeAlign[text() = 'true'])]">
<xsl:for-each select="//sw:length/sw:lengthAsTime[not(../../sw:excludeAlign[text() = 'true'])]">
<Item>
<Length><xsl:value-of select="string-length(concat(myData:number(minutes-from-duration(.)), ':', myData:number(format-number(seconds-from-duration(.), '00'))))" /></Length>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:if>
</xsl:when>
<!-- if no distance tags present return 0 -->
<xsl:otherwise><Item>0</Item></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- this function is repeated four times when i only really need one -> fix it (instNodes, contNodes, simpNodes, repNodes are all identical) note > not >= in instNodes -->
<!-- helper function for returning lengths within groupings of 10 characters -->
<!-- given array of nodes from instLengths will return each location with length given as max length within it group of 10 characters -->
<xsl:template name="instNodes">
<!-- uneeded paramater? its unused -->
<xsl:param name="nodes"/>
<!-- array of nodes to adjust lengths -->
<xsl:param name="element"/>
<!-- only run function if there are still elements left in the array -->
<xsl:if test="$element">
<!-- for elements within 10 characters of the first element in the array -->
<xsl:for-each select="$element[./*[1] > max($element/*[1])-9 ]">
<!-- return location of element and the max length of node within 10 characters-->
<Item>
<Location><xsl:value-of select="./*[4]"/></Location>
<Length><xsl:value-of select="max($element/*[1])"/></Length>
</Item>
</xsl:for-each>
<!-- recursively call function with any elements that were more than 10 characters longer than the first in the elements array-->
<xsl:call-template name="instNodes">
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="element" select="$element[max($element/*[1]) > ./*[1]+9 ]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- variable for the lengths each instruction distance node needs to be -->
<!-- this variable is used for display -->
<xsl:variable name="maxInstLengths" as="element()*">
<!-- sort all distance nodes by what section they are in -->
<xsl:for-each-group select="$instLengths" group-by="./*[2]">
<xsl:sort select='./*[2]' order="ascending" data-type="number" />
<!-- sort all nodes again this time by what parents the have -->
<!-- this is stored as a numerical value so can be sorted so the nodes with the same parents will have the same lengths-->
<xsl:for-each-group select="$instLengths" group-by="./*[3][../Section = current-grouping-key()]">
<!-- call helper function for each set of nodes that have the same section and parents -->
<xsl:call-template name="instNodes">
<xsl:with-param name="nodes" select="."/>
<xsl:with-param name="element" select="current-group()"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:variable>
<!-- variable for length of continue tags -->
<xsl:variable name="contLengths" as="element()*">
<xsl:choose>
<!-- check if there are any continue tags in the program-->
<xsl:when test="//sw:continue[not(../sw:excludeAlign[text() = 'true'])]">
<!-- check if simplify tag is still needed here cos i dont think it is -->
<xsl:for-each select="//sw:continue[not(../sw:excludeAlign[text() = 'true'])]">
<!-- calculate sum of any inst tags that are top level in the continue -->
<xsl:variable name="contInstLength">
<xsl:call-template name="sumItems">
<xsl:with-param name="nodeSet" select="./*[not(name(.) = 'instruction')]"/>
</xsl:call-template>
</xsl:variable>
<!-- add data for each continue tag to the array -->
<!-- this data is the length of each continue, its section, its parents and its unique location -->
<Item>
<xsl:choose>
<!-- different length is given when continue is child of a repetition and only has 1 child instruction as it displays differently (extra addition of repetition count) this could change-->
<!-- length is the length of calculated length node, 3 characters for as, length of any top level instruction tags and the extra spaces they need -->
<xsl:when test="../../../sw:repetition/sw:simplify[text()='true']">
<Length><xsl:value-of select="4+$contInstLength+count(./*[not(name(.) = 'instruction' or name(.) = 'length' or name(.) = 'excludeAlignContinue' or name(.) = 'continueLength' )])"/></Length>
</xsl:when>
<xsl:when test="every $node in .//sw:length satisfies $node/sw:lengthAsLaps">
<Length><xsl:value-of select="string-length(string(myData:number(myData:contLength(.))))+7+$contInstLength+count(./*[not(name(.) = 'instruction' or name(.) = 'length' or name(.) = 'excludeAlignContinue' or name(.) = 'continueLength' )])"/> </Length>
</xsl:when>
<xsl:otherwise>
<Length><xsl:value-of select="string-length(string(myData:number(myData:contLength(.))))+3+$contInstLength+count(./*[not(name(.) = 'instruction' or name(.) = 'length' or name(.) = 'excludeAlignContinue' or name(.) = 'continueLength' )])"/> </Length>
</xsl:otherwise>
</xsl:choose>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:when>
<!-- return array with 0 if no continue tags in the program -->
<xsl:otherwise>
<Item>0</Item>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- helper function for returning lengths within groupings of 10 characters -->
<!-- given array of nodes from contLengths will return each location with length given as max length within it group of 10 characters -->
<xsl:template name="contNodes">
<!-- uneeded paramater? its unused -->
<xsl:param name="nodes"/>
<!-- array of nodes to adjust lengths -->
<xsl:param name="element"/>
<!-- only run function if there are still elements left in the array -->
<xsl:if test="$element">
<!-- for elements within 10 characters of the first element in the array -->
<xsl:for-each select="$element[./*[1] >= max($element/*[1])-9 ]">
<!-- return location of element and the max length of node within 10 characters-->
<Item>
<Location><xsl:value-of select="./*[4]"/></Location>
<Length><xsl:value-of select="max($element/*[1])"/></Length>
</Item>
</xsl:for-each>
<!-- recursively call function with any elements that were more than 10 characters longer than the first in the elements array-->
<xsl:call-template name="contNodes">
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="element" select="$element[max($element/*[1]) > ./*[1]+9 ]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- variable for the lengths each continue distance node needs to be -->
<!-- this variable is used for display -->
<xsl:variable name="maxContLengths" as="element()*">
<!-- sort all distance nodes by what section they are in -->
<xsl:for-each-group select="$contLengths" group-by="./*[2]">
<xsl:sort select='./*[2]' order="ascending" data-type="number" />
<!-- sort all nodes again this time by what parents the have -->
<!-- this is stored as a numerical value so can be sorted so the nodes with the same parents will have the same lengths-->
<xsl:for-each-group select="$contLengths" group-by="./*[3][../Section = current-grouping-key()]">
<!-- call helper function for each set of nodes that have the same section and parents -->
<xsl:call-template name="contNodes">
<xsl:with-param name="nodes" select="."/>
<xsl:with-param name="element" select="current-group()"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:variable>
<!-- variable for length of simplifying repetition tags -->
<xsl:variable name="simpLengths" as="element()*">
<xsl:choose>
<!-- check if there are any simplifying tags in the program-->
<xsl:when test=" //sw:repetition[./sw:simplify[text()='true'] and not(../sw:excludeAlign[text() = 'true'])]">
<xsl:for-each select="//sw:repetition[./sw:simplify[text()='true'] and not(../sw:excludeAlign[text() = 'true'])]">
<!-- calculate sum of any inst tags that are top level in the simplifying repetition -->
<xsl:variable name="simpInstLength">
<xsl:call-template name="sumItems">
<xsl:with-param name="nodeSet" select="./*[not(name(.) = 'instruction' or name(.) = 'simplify')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="isLaps">
<xsl:choose>
<xsl:when test="(./descendant-or-self::sw:lengthAsLaps)">5</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- add data for each simplifying tag to the array -->
<!-- this data is the length of each continue, its section, its parents and its unique location -->
<Item>
<!-- length is the length of calculated length node, 6 characters for as and multiplier symbol, length of any top level instruction tags and the extra spaces they need -->
<Length><xsl:value-of select="string-length(string(myData:number(myData:simpRep(.))))+string-length(string(myData:number(myData:firstInst(.))))+$isLaps+6+$simpInstLength+count(./*[not(name(.) = 'instruction' or name(.) = 'repetitionCount' or name(.) = 'simplify' or name(.) = 'length' or name(.) = 'excludeAlignRepetition' )])"/></Length>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:when>
<!-- return array with 0 if no simplifying repetititon tags in the program -->
<xsl:otherwise>
<Item>0</Item>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- helper function for returning lengths within groupings of 10 characters -->
<!-- given array of nodes from simpLengths will return each location with length given as max length within it group of 10 characters -->
<xsl:template name="simpNodes">
<!-- uneeded paramater? its unused -->
<xsl:param name="nodes"/>
<!-- array of nodes to adjust lengths -->
<xsl:param name="element"/>
<!-- only run function if there are still elements left in the array -->
<xsl:if test="$element">
<!-- for elements within 10 characters of the first element in the array -->
<xsl:for-each select="$element[./*[1] >= max($element/*[1])-9 ]">
<!-- return location of element and the max length of node within 10 characters-->
<Item>
<Location><xsl:value-of select="./*[4]"/></Location>
<Length><xsl:value-of select="max($element/*[1])"/></Length>
</Item>
</xsl:for-each>
<!-- recursively call function with any elements that were more than 10 characters longer than the first in the elements array-->
<xsl:call-template name="simpNodes">
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="element" select="$element[max($element/*[1]) > ./*[1]+9 ]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- variable for the lengths each simplifying repetition distance node needs to be -->
<!-- this variable is used for display -->
<xsl:variable name="maxSimpLengths" as="element()*">
<!-- sort all distance nodes by what section they are in -->
<xsl:for-each-group select="$simpLengths" group-by="./*[2]">
<xsl:sort select='./*[2]' order="ascending" data-type="number" />
<!-- sort all nodes again this time by what parents the have -->
<!-- this is stored as a numerical value so can be sorted so the nodes with the same parents will have the same lengths-->
<xsl:for-each-group select="$simpLengths" group-by="./*[3][../Section = current-grouping-key()]">
<!-- call helper function for each set of nodes that have the same section and parents -->
<xsl:call-template name="simpNodes">
<xsl:with-param name="nodes" select="."/>
<xsl:with-param name="element" select="current-group()"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:variable>
<!-- variable for length of repetition tags -->
<xsl:variable name="repLengths" as="element()*">
<xsl:choose>
<!-- check if there are any repetition tags in the program-->
<xsl:when test="//sw:repetition[not(./sw:simplify[text()='true']) and not(../sw:excludeAlign[text() = 'true'])]">
<xsl:for-each select="//sw:repetition[not(./sw:simplify[text()='true']) and not(../sw:excludeAlign[text() = 'true'])]">
<!-- calculate sum of any inst tags that are top level in the repetition -->
<xsl:variable name="repInstLength">
<xsl:call-template name="sumItems">
<xsl:with-param name="nodeSet" select="./*[not(name(.) = 'instruction' or name(.) = 'repetitionCount' or name(.) = 'simplify' )]"/>
</xsl:call-template>
</xsl:variable>
<!-- add data for each repetition tag to the array -->
<!-- this data is the length of each continue, its section, its parents and its unique location -->
<Item>
<!-- length is the length of calculated repetition count, 2 characters for multiplier symbol, length of any top level instruction tags and the extra spaces they need -->
<Length><xsl:value-of select="string-length(string(myData:number(number(./sw:repetitionCount))))+2+$repInstLength+count(./*[not(name(.) = 'instruction' or name(.) = 'repetitionCount' or name(.) = 'length' or name(.) = 'simplify' or name(.) = 'excludeAlignRepetition' )])"/></Length>
<Section><xsl:value-of select="myData:section(.)"/></Section>
<Parents><xsl:value-of select="myData:parents(.)"/></Parents>
<Location><xsl:value-of select="myData:location(.)"/></Location>
</Item>
</xsl:for-each>
</xsl:when>
<!-- return array with 0 if no simplifying repetititon tags in the program -->
<xsl:otherwise>
<Item>0</Item>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- helper function for returning lengths within groupings of 10 characters -->
<!-- given array of nodes from repLengths will return each location with length given as max length within it group of 10 characters -->
<xsl:template name="repNodes">
<!-- uneeded paramater? its unused -->
<xsl:param name="nodes"/>
<!-- array of nodes to adjust lengths -->
<xsl:param name="element"/>
<!-- only run function if there are still elements left in the array -->
<xsl:if test="$element">
<!-- for elements within 10 characters of the first element in the array -->
<xsl:for-each select="$element[./*[1] >= max($element/*[1])-9 ]">
<!-- return location of element and the max length of node within 10 characters-->
<Item>
<Location><xsl:value-of select="./*[4]"/></Location>
<Length><xsl:value-of select="max($element/*[1])"/></Length>
</Item>
</xsl:for-each>
<!-- recursively call function with any elements that were more than 10 characters longer than the first in the elements array-->
<xsl:call-template name="repNodes">
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="element" select="$element[max($element/*[1]) > ./*[1]+9 ]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- variable for the lengths each repetition node needs to be -->
<!-- this variable is used for display -->
<xsl:variable name="maxRepLengths" as="element()*">
<!-- sort all distance nodes by what section they are in -->
<xsl:for-each-group select="$repLengths" group-by="./*[2]">
<xsl:sort select='./*[2]' order="ascending" data-type="number" />
<!-- sort all nodes again this time by what parents the have -->
<!-- this is stored as a numerical value so can be sorted so the nodes with the same parents will have the same lengths-->
<xsl:for-each-group select="$repLengths" group-by="./*[3][../Section = current-grouping-key()]">
<!-- call helper function for each set of nodes that have the same section and parents -->
<xsl:call-template name="repNodes">
<xsl:with-param name="nodes" select="."/>
<xsl:with-param name="element" select="current-group()"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:variable>
<!-- helper function for adding length of instruction elements together -->
<!-- this works by adding the translation of each of the nodes to the total length and repeating recurtsively -->
<!-- some elements may still not work here as they have different formats, e.g drill or kick-->
<xsl:template name="sumExtras">
<!-- nodes param gives array of nodes to add lengths of-->
<xsl:param name="nodes"/>
<!-- sum of lengths, defaults to 0 when first called-->
<xsl:param name="tempSum" select="0" />
<xsl:choose>
<!-- checks to see if there is another node to add-->
<xsl:when test="not($nodes)">
<!-- no more nodes so return counting sum of lengths-->
<xsl:value-of select="$tempSum" />
</xsl:when>
<xsl:otherwise>
<!--more nodes do add so calculate length of the current node-->
<xsl:variable name="product">
<xsl:value-of select="string-length($thisDocument/xsl:stylesheet/myData:translation/term[@index = string($nodes[1])])"/>
</xsl:variable>
<!-- recursively call self with next node and current nodes length added to sum-->
<xsl:call-template name="sumExtras">
<xsl:with-param name="nodes" select="$nodes[position() > 1]" />
<xsl:with-param name="tempSum" select="$tempSum + $product" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- function returns length of all instruction element nodes given -->
<xsl:template name="sumItems">
<!-- nodeSet is an array of nodes which are all instruction elements-->
<xsl:param name="nodeSet" />
<!-- sum of lengths, defaults to 0 when first called-->
<xsl:param name="tempSum" select="0" />
<xsl:choose>
<!-- check to see if there is another node -->
<xsl:when test="not($nodeSet)">
<!-- no more nodes so return the running count-->
<xsl:value-of select="$tempSum" />
</xsl:when>
<xsl:otherwise>
<!-- there is another node so find its length-->
<!-- whatever is returned in this variable is the length of the current node-->
<xsl:variable name="product">
<xsl:choose>
<!-- is element type is rest return length based on pre-determined formatting -->
<xsl:when test="name($nodeSet[1]) = 'rest'">
<xsl:choose>
<!-- finding the type of rest given -->
<xsl:when test="$nodeSet[1]/sw:sinceStart">
<xsl:value-of select="2+string-length(concat(minutes-from-duration(./sw:sinceStart), ':', format-number(seconds-from-duration(./sw:sinceStart), '00')))"/>
</xsl:when>
<xsl:when test="$nodeSet[1]/sw:afterStop">
<xsl:value-of select="1+string-length(concat(minutes-from-duration(./sw:afterStop), ':', format-number(seconds-from-duration(./sw:afterStop), '00')))"/>
</xsl:when>
<xsl:when test="$nodeSet[1]/sw:sinceLastRest">
<xsl:value-of select="3+string-length(concat(minutes-from-duration(./sw:sinceLastRest), ':', format-number(seconds-from-duration(./sw:sinceLastRest), '00')))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="8+string-length(./sw:inOut)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- intensity elements have pre-determined formatting-->
<xsl:when test="name($nodeSet[1]) = 'intensity'">
<xsl:choose>
<xsl:when test="$nodeSet[1]/sw:stopIntensity">
<xsl:choose>
<!-- finding the type of rest given -->
<xsl:when test="$nodeSet[1]/sw:startIntensity/sw:percentageEffort">
<xsl:value-of select="2+string-length(string($nodeSet[1]/sw:startIntensity/*))+string-length(string($nodeSet[1]/sw:stopIntensity/*))"/>
</xsl:when>
<xsl:when test="$nodeSet[1]/sw:startIntensity/sw:percentageHeartRate">
<xsl:value-of select="3+string-length(string($nodeSet[1]/sw:startIntensity/*))+string-length(string($nodeSet[1]/sw:stopIntensity/*))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="1+string-length($thisDocument/xsl:stylesheet/myData:translation/term[@index = string($nodeSet[1]/*[1]/*[1])])+string-length($thisDocument/xsl:stylesheet/myData:translation/term[@index = string($nodeSet[1]/*[2]/*[1])])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- finding the type of rest given -->
<xsl:when test="$nodeSet[1]/sw:startIntensity/sw:percentageEffort">
<xsl:value-of select="1+string-length(string($nodeSet[1]/sw:startIntensity/*))"/>
</xsl:when>
<xsl:when test="$nodeSet[1]/sw:startIntensity/sw:percentageHeartRate">
<xsl:value-of select="2+string-length(string($nodeSet[1]/sw:startIntensity/*))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="1+string-length($thisDocument/xsl:stylesheet/myData:translation/term[@index = string($nodeSet[1]/*[1]/*[1])])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- check is remaining node is a stroke element-->
<xsl:when test="name($nodeSet[1]) = 'stroke'">
<xsl:choose>
<!--checking if stroke is kick/drill or standard-->
<xsl:when test="name($nodeSet[1]/*[1]) = 'kicking' or name($nodeSet[1]/*[1]) = 'drill'">
<!-- return length of kick/drill stroke-->
<xsl:variable name="strokeExtra">
<xsl:call-template name="sumExtras">
<xsl:with-param name="nodes" select="$nodeSet[1]//text()" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$strokeExtra+2"/>
</xsl:when>
<xsl:otherwise>
<!-- return length of standard stroke -->
<xsl:call-template name="sumExtras">
<xsl:with-param name="nodes" select="$nodeSet[1]//text()" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="name($nodeSet[1]) = 'repetitionDescription' or name($nodeSet[1]) = 'continueDescription' or name($nodeSet[1]) = 'instructionDescription' or name($nodeSet[1]) = 'pyramidDescription'">
<xsl:value-of select="string-length($nodeSet[1]//text())"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- check if element is length -->
<xsl:when test="name($nodeSet[1]) != 'length'">
<!-- for element types not above (not rest, intensity, stroke or length) return length of string translation-->
<xsl:call-template name="sumExtras">
<xsl:with-param name="nodes" select="$nodeSet[1]//text()" />
</xsl:call-template>
</xsl:when>
<!-- length elements dont appear in continues or repetition as the total length is calculated separately-->
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- recursively call function with next node and with addition to running count -->
<xsl:call-template name="sumItems">
<xsl:with-param name="nodeSet" select="$nodeSet[position() > 1]" />
<xsl:with-param name="tempSum" select="$tempSum + $product" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<!-- ============================== -->
<!-- HTML Document -->
<!-- ============================== -->
<html>
<head>
<script src="https://kit.fontawesome.com/7414123f18.js" crossorigin="anonymous"></script>
<meta charset="UTF-8"/>
<meta property="og:image" content="https://bartneck.github.io/swiML/swiMLLogoGradientFacebook.png"/>
<meta property="og:image:type" content="image/png"/>
<meta property="og:image:width" content="1200"/>
<meta property="og:image:height" content="630"/>
<!-- Main CSS -->
<link href="https://bartneck.github.io/swiML/swiML.css" rel="stylesheet" type="text/css"/>
<!-- Google fonts used to load from google.-->
<!-- The fonts are currently loaded directly from local font files -->
<!-- This can be reomved as soon as we are comofrtable with this approach -->
<!--
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous"/>
<link
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800"
rel="stylesheet"/>
-->
<xsl:apply-templates select="sw:program/sw:layoutWidth"/>
<!-- Favicon icons -->
<link rel="shortcut icon" href="/swiML/favicon/favicon.ico"/>
<link rel="icon" sizes="16x16 32x32 64x64" href="/swiML/favicon/favicon.ico"/>
<link rel="icon" type="image/png" sizes="196x196" href="/swiML/favicon/favicon-192.png"/>
<link rel="icon" type="image/png" sizes="160x160" href="/swiML/favicon/favicon-160.png"/>
<link rel="icon" type="image/png" sizes="96x96" href="/swiML/favicon/favicon-96.png"/>
<link rel="icon" type="image/png" sizes="64x64" href="/swiML/favicon/favicon-64.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="/swiML/favicon/favicon-32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="/swiML/favicon/favicon-16.png"/>
<link rel="apple-touch-icon" href="/swiML/favicon/favicon-57.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="/swiML/favicon/favicon-114.png"/>
<link rel="apple-touch-icon" sizes="72x72" href="/swiML/favicon/favicon-72.png"/>
<link rel="apple-touch-icon" sizes="144x144" href="/swiML/favicon/favicon-144.png"/>
<link rel="apple-touch-icon" sizes="60x60" href="/swiML/favicon/favicon-60.png"/>
<link rel="apple-touch-icon" sizes="120x120" href="/swiML/favicon/favicon-120.png"/>
<link rel="apple-touch-icon" sizes="76x76" href="/swiML/favicon/favicon-76.png"/>
<link rel="apple-touch-icon" sizes="152x152" href="/swiML/favicon/favicon-152.png"/>
<link rel="apple-touch-icon" sizes="180x180" href="/swiML/favicon/favicon-180.png"/>
<meta name="msapplication-TileColor" content="#FFFFFF"/>
<meta name="msapplication-TileImage" content="/swiML/favicon/favicon-144.png"/>
<meta name="msapplication-config" content="/swiML/favicon/browserconfig.xml"/>
<title>
<xsl:value-of select="sw:program/sw:title"/>
</title>
</head>
<body>
<xsl:choose>
<xsl:when test="sw:program/sw:hideIntro = 'true'"/>
<xsl:otherwise>
<div class="intro">
<h1>
<xsl:value-of select="sw:program/sw:title"/>
</h1>
<xsl:apply-templates select="sw:program/sw:author"/>
<p class="description">
<xsl:value-of select="sw:program/sw:programDescription"/>
</p>
<ul>
<li>
<span class="semiBoldTypeFace">Date:</span>
<xsl:value-of
select="format-date(sw:program/sw:creationDate, '[D01] [MNn] [Y0001]')"
/>
</li>
<li>
<span class="semiBoldTypeFace">Pool Size:</span>
<xsl:value-of select="myData:number(sw:program/sw:poolLength)"/>
</li>
<li>
<span class="semiBoldTypeFace">Units:</span>
<xsl:value-of select="sw:program/sw:lengthUnit"/>
</li>
<li>
<span class="semiBoldTypeFace">Length:</span>
<xsl:value-of select="myData:number(myData:showLength(sw:program))"/>
<xsl:text> </xsl:text>
<xsl:value-of select="sw:program/sw:lengthUnit"/>
<xsl:text> / </xsl:text>
<xsl:value-of select="myData:number(myData:showLength(sw:program) div (sw:program/sw:poolLength))"/>
<xsl:text> Laps</xsl:text>
</li>
</ul>
</div>
</xsl:otherwise>
</xsl:choose>
<!-- The recursive instructions -->
<div class="program">
<xsl:apply-templates select="sw:program/sw:instruction"/>
<!--<xsl:value-of select="$instLengths"/>
c
<xsl:value-of select="$maxInstLengths"/>
c
<xsl:value-of select="$simpLengths"/>
c
<xsl:value-of select="$maxSimpLengths"/>
<xsl:value-of select="$contLengths"/>
c
<xsl:value-of select="$maxContLengths"/>-->
</div>
<!-- footer -->
<xsl:choose>
<xsl:when test="sw:program/sw:hideIntro = 'true'"/>
<xsl:otherwise>
<div class="bottom">
<div class="footnote">made with: </div>
<div class="logo">
<a href="https://github.com/bartneck/swiML">
<svg class='logoSvg' id="Layer_1" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 1219.33 460.35" >
<defs>
<style>
.cls-1 {
fill: #231f20;
}</style>
</defs>
<path class="cls-1"
d="M209,360.8c0,58.3-51.7,99.55-104.5,99.55C39.6,460.35,0,419.65,0,362.45c0-14.3,12.1-26.4,26.4-26.4h39.6c18.7,0,26.4,11.55,26.4,25.85,0,6.6,5.5,12.1,12.1,12.1s12.1-5.5,12.1-12.1v-9.35c0-17.6-6.05-25.85-24.75-33.55l-22.55-9.9C41.25,297,0,279.95,0,225.5v-20.35c0-58.3,44.55-101.75,104.5-101.75,66.55,0,104.5,45.65,104.5,97.35,0,14.3-12.1,26.4-26.4,26.4h-39.6c-15.95,0-26.4-7.7-26.4-25.3,0-6.6-5.5-12.1-12.1-12.1s-12.1,5.5-12.1,12.1v7.7c0,17.05,7.7,27.5,24.2,34.65l23.1,9.9c29.15,12.65,69.3,29.15,69.3,83.6v23.1Z"/>
<path class="cls-1"
d="M556.59,354.2c0,72.05-51.7,106.15-96.25,106.15-19.25,0-35.75-3.3-49.5-12.65l-7.15-4.4c-3.85-2.75-5.5-4.4-9.9-4.4-3.3,0-5.5,1.1-9.9,4.4l-6.6,4.4c-13.75,9.35-30.8,12.65-49.5,12.65-52.25,0-96.8-40.7-96.8-106.15V133.65c0-14.3,12.1-26.4,26.4-26.4h39.6c14.3,0,26.4,13.75,26.4,26.4v233.75c0,6.6,5.5,12.1,12.1,12.1s12.1-5.5,12.1-12.1V133.65c0-14.3,12.1-26.4,26.4-26.4h39.6c14.3,0,26.4,13.75,26.4,26.4v233.75c0,6.6,5.5,12.1,12.1,12.1s12.1-5.5,12.1-12.1V133.65c0-14.3,12.1-26.4,26.4-26.4h40.15c14.3,0,25.85,12.1,25.85,26.4v220.55Z"/>
<path class="cls-1"
d="M672.64,58.85c0,14.3-12.1,26.4-26.4,26.4h-39.6c-14.3,0-26.4-12.1-26.4-26.4V29.15c0-14.3,12.1-26.4,26.4-26.4h39.6c14.3,0,26.4,13.75,26.4,26.4v29.7Zm0,371.25c0,14.3-12.1,26.4-26.4,26.4h-39.6c-14.3,0-26.4-12.1-26.4-26.4V133.65c0-14.3,12.1-26.4,26.4-26.4h39.6c14.3,0,26.4,13.75,26.4,26.4V430.1Z"/>
<path class="cls-1"
d="M1033.99,116.05V430.1c0,14.3-12.1,26.4-26.4,26.4h-43.45c-14.3,0-26.4-13.75-26.4-26.4V105.05c0-6.6-5.5-12.1-12.1-12.1s-12.1,5.5-12.1,12.1V430.1c0,14.3-12.1,26.4-26.4,26.4h-43.45c-14.3,0-26.4-13.75-26.4-26.4V105.05c0-6.6-5.5-12.1-12.1-12.1s-12.1,5.5-12.1,12.1V430.1c0,14.3-12.1,26.4-26.4,26.4h-43.45c-14.3,0-26.4-12.1-26.4-26.4V31.35c0-17.05,13.2-31.35,32.45-31.35,6.6,0,14.3,2.75,19.25,4.95l2.75,1.1c6.05,2.2,8.8,3.85,15.95,3.85,6.05,0,14.85-2.75,22-4.95,7.15-2.2,19.25-4.95,32.45-4.95s23.1,2.75,31.9,5.5c7.15,2.2,15.4,4.4,20.35,4.4s13.2-2.2,20.35-4.4c8.8-2.75,21.45-5.5,34.65-5.5,73.7,0,105.05,43.45,105.05,116.05Z"/>
<path class="cls-1"
d="M1154.43,347.6c0,7.15,4.95,12.65,12.1,12.65h26.4c14.3,0,26.4,12.1,26.4,26.4v43.45c0,14.3-12.1,26.4-26.4,26.4h-108.35c-14.3,0-26.4-12.1-26.4-26.4V29.15c0-14.3,12.1-26.4,26.4-26.4h43.45c14.3,0,26.4,12.1,26.4,26.4V347.6Z"
/>
</svg>
</a>
</div>
</div>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
<!-- ============================== -->
<!-- Main Templates -->
<!-- ============================== -->
<!-- Author Template -->
<xsl:template match="sw:author">
<p class="authorName">
<xsl:value-of separator=" " select="sw:firstName, sw:lastName"/>
</p>
<p class="authorEmail">
<xsl:value-of select="sw:email"/>
</p>
</xsl:template>
<!-- Instruction Template -->
<xsl:template match="sw:instruction">
<xsl:choose>
<xsl:when test="sw:segmentName or sw:repetition or sw:continue">
<xsl:apply-templates select="sw:segmentName"/>
<xsl:apply-templates select="sw:repetition"/>
<xsl:apply-templates select="sw:continue"/>
</xsl:when>
<xsl:otherwise>
<div class="instruction">
<xsl:call-template name="displayInst"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- First segment template -->
<xsl:template match="sw:instruction[1]/sw:segmentName">
<div class="firstSegmentName">
<xsl:value-of select="."/>
</div>
</xsl:template>
<!-- Segment name template -->
<xsl:template match="sw:segmentName">
<div class="segmentName">
<xsl:value-of select="."/>
</div>
</xsl:template>
<!-- Repetition Template -->
<xsl:template match="sw:repetition">
<!-- gets location int for repetition-->
<xsl:variable name="location">
<xsl:value-of select="myData:location(.)"/>
</xsl:variable>
<div class="repetition">
<!-- seperate template for simplifying repetition and for non-simplifying-->
<xsl:choose>
<xsl:when test="./sw:simplify[text() = 'true']">
<div class="repetitionCount">
<!-- check if aligning repetition or not-->
<xsl:choose>
<xsl:when test="./sw:excludeAlignRepetition[text() = 'true'] or ./ancestor-or-self::sw:program//sw:programAlign[text() = 'false']">
<xsl:attribute name="style">
<xsl:text>text-align:center;</xsl:text>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">
<xsl:text>min-width:</xsl:text>
<xsl:value-of select="$maxSimpLengths[./*[../Location = $location]]/Length"/>
<xsl:text>ch; text-align:center</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<span>
<xsl:attribute name="style">
<xsl:text>margin-left: auto; </xsl:text>
</xsl:attribute>
<xsl:call-template name="simplifyLength"/>
<xsl:text> × </xsl:text>
</span>
<!-- only display distance if one isnt defined at the repetitions level REMOVED i did this twice so it wouldnt display anything -->
<span>
<xsl:attribute name="class">
<xsl:text>extraBoldTypeFaceCenter</xsl:text>
</xsl:attribute>
<xsl:value-of select="myData:firstInst(.)"/>
</span>
<xsl:if test="(./descendant-or-self::sw:lengthAsLaps)"><xsl:text> Laps</xsl:text></xsl:if>
<xsl:if test=".//sw:repetitionDescription">
<xsl:value-of select="concat(' ',sw:repetitionDescription)"/>
</xsl:if>
<xsl:call-template name="displayInst"/>
<xsl:text> as</xsl:text>
</div>
<!-- only display repetition symbol if more than one child instruction-->
<xsl:choose>
<xsl:when test="count(./sw:instruction) > 1">
<div class="repetitionSymbol"><xsl:text> </xsl:text></div>
</xsl:when>
<xsl:otherwise>
<xsl:if test="(count(.//sw:instruction) > 1) or not(./sw:simplify[text()='true']) ">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<div class="repetitionContent">
<xsl:apply-templates select="sw:instruction"/>
</div>
</xsl:when>
<xsl:otherwise>
<!-- display inner if not in a continue with only one child instruction -->
<!-- this if statment may be outdated i need to check -->
<xsl:if test="not(count(../../../sw:continue) = 1 and count(.//sw:instruction) = 1 and not(../../sw:simplify[text()='true']))">
<span class="repetitionCount">
<!-- might be another counter intuitive if statement as its kinda already done is the one above-->
<xsl:if test="(count(.//sw:instruction) > 1) or not(../../sw:simplify[text()='true'])">
<!-- check for excluding alignment-->
<xsl:choose>
<xsl:when test="./sw:excludeAlignRepetition[text() = 'true'] or ./ancestor-or-self::sw:program//sw:programAlign[text() = 'false']">
<xsl:attribute name="style">
<xsl:text>text-align:center;</xsl:text>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">
<xsl:text>min-width:</xsl:text>
<xsl:value-of select="$maxRepLengths[./*[../Location = $location]]/Length"/>
<xsl:text>ch;</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<span>
<xsl:attribute name="style">margin-left:auto</xsl:attribute>
<xsl:choose>
<xsl:when test="(count(.//sw:instruction) > 1) or not(../../sw:simplify[text()='true']) ">
<xsl:if test="count(./sw:instruction) = 1">
<xsl:attribute name="class">
<xsl:text>extraBoldTypeFaceCenter</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="concat(myData:number(sw:repetitionCount),' ','×')"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="count(./sw:instruction) = 1">
<xsl:attribute name="class">
<xsl:text>extraBoldTypeFaceCenter</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="myData:number(sw:repetitionCount)"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:if test=".//sw:repetitionDescription">
<xsl:value-of select="concat(' ',sw:repetitionDescription)"/>
</xsl:if>
<xsl:call-template name="displayInst"/>
</span>
<!-- only use repetition symbol for more than one child instruction-->
<xsl:choose>
<xsl:when test="count(./sw:instruction) > 1">
<div class="repetitionSymbol"><xsl:text> </xsl:text></div>
</xsl:when>
<xsl:otherwise>
<xsl:if test="(count(.//sw:instruction) > 1) or not(../../sw:simplify[text()='true']) ">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<div class="repetitionContent">
<xsl:apply-templates select="sw:instruction"/>
</div>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
<!-- Continuation Template -->
<xsl:template match="sw:continue">
<!-- gets location int for continue-->
<xsl:variable name="location">
<xsl:value-of select="myData:location(.)"/>
</xsl:variable>
<div class="continue">
<div class="continueLength">
<!-- check for alingment exclusion-->
<xsl:choose>
<xsl:when test="./sw:excludeAlignContinue[text() = 'true']or ./ancestor-or-self::sw:program//sw:programAlign[text() = 'false']">
<xsl:attribute name="style">
<xsl:text>text-align:center;</xsl:text>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">
<xsl:text>min-width:</xsl:text>
<xsl:value-of select="$maxContLengths[./*[../Location = $location]]/Length"/>
<xsl:text>ch; text-align:center</xsl:text>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<span>
<xsl:attribute name="class">
<xsl:text>extraBoldTypeFaceMarginLeft</xsl:text>
</xsl:attribute>
<xsl:choose>
<xsl:when test="../../../sw:repetition/sw:simplify[text()='true']"><xsl:value-of select="myData:number(1)"/></xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="every $node in .//sw:length satisfies $node/sw:lengthAsLaps"><xsl:value-of select="myData:number(myData:contLength(.) div ./ancestor-or-self::sw:program/sw:poolLength )"/></xsl:when>
<xsl:otherwise><xsl:value-of select="myData:number(myData:contLength(.))"/></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:if test="every $node in .//sw:length satisfies $node/sw:lengthAsLaps"><xsl:text> Laps</xsl:text></xsl:if>
<xsl:call-template name="displayInst"/>
<xsl:text> as</xsl:text>
</div>
<div class="continueSymbol"><xsl:text> </xsl:text></div>
<div class="continueContent">
<xsl:apply-templates select="sw:instruction"/>
</div>
</div>
</xsl:template>
<!-- Instruction Template -->
<xsl:template name="displayInst">
<!-- check inst is not a child of a simplifying repetition-->
<!-- display 1 as length when in a simplifying repetition and it has siblings -->
<!-- this should be fine as base level instructions can only be 1 set of a repetition but this needs to be checked -->
<xsl:choose>
<xsl:when test="../../sw:repetition/sw:simplify[text()='true']">
<xsl:choose>
<xsl:when test="count(..//sw:instruction) > 1">
<span>
<xsl:attribute name="class">
<xsl:text>extraBoldTypeFaceRight</xsl:text>
</xsl:attribute>
<xsl:value-of select="myData:number(1)"/>
</span>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="../../../sw:simplify[text() = 'true'] and (../../sw:repetition and count(..//sw:instruction) = 1)"></xsl:when>
<xsl:otherwise>
<!-- check if grandchild of continue, child of repetition and has no siblings -->
<!-- this means the length needs to be multiplied by repetition count as it isnt displayed in the repetition part-->