-
Notifications
You must be signed in to change notification settings - Fork 0
/
tpl-apparatus.xsl
1763 lines (1694 loc) · 92.1 KB
/
tpl-apparatus.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:t="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="t" version="2.0">
<!-- Generates the apparatus from the edition -->
<!--
Adding to Apparatus:
1. Add to apparatus: [htm | txt]-tpl-apparatus.xsl add case to the ifs and for-each (3 places)
- NOTE the app-link 'if' is checking for nested cases, therefore looking for ancestors.
2. Indicator in text: [htm | txt]-element.xsl to add call-template to [htm | txt]-tpl-apparatus.xsl for links and/or stars.
3. Add to ddbdp-app template below using local-name() to define context
-->
<!-- Defines the output of individual elements in apparatus -->
<xsl:template name="ddbdp-app">
<xsl:param name="apptype"/>
<xsl:variable name="childtype">
<xsl:choose>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice[child::t:orig and child::t:reg]">
<xsl:text>origreg</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice[child::t:sic and child::t:corr]">
<xsl:text>siccorr</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:subst">
<xsl:text>subst</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='alternative']">
<xsl:text>appalt</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='editorial'][starts-with(@resp,'BL ')]">
<xsl:text>appbl</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='editorial'][starts-with(@resp,'PN ')]">
<xsl:text>apppn</xsl:text>
</xsl:when>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='editorial']">
<xsl:text>apped</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="div-loc">
<xsl:for-each select="ancestor::t:div[@type='textpart'][@n]">
<xsl:value-of select="@n"/>
<xsl:text>.</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="not(ancestor::t:choice or ancestor::t:subst or ancestor::t:app or
ancestor::t:hi[@rend=('diaeresis','grave','acute','asper','lenis','circumflex')])">
<!-- either <br/> in htm-tpl-apparatus or \r\n in txt-tpl-apparatus -->
<xsl:call-template name="lbrk-app"/>
<!-- in htm-tpl-apparatus.xsl or txt-tpl-apparatus.xsl -->
<xsl:call-template name="app-link">
<xsl:with-param name="location" select="'apparatus-link-back'"/>
</xsl:call-template>
<xsl:value-of select="$div-loc"/>
<xsl:value-of select="preceding::t:*[local-name() = 'lb'][1]/@n"/>
<xsl:if test="descendant::t:lb">
<xsl:variable name="cnum">
<xsl:value-of select="preceding::t:*[local-name() = 'lb'][1]/@n"/>
</xsl:variable>
<xsl:if test="descendant::t:lb[position() = last()]/@n != $cnum">
<xsl:text>-</xsl:text>
<xsl:value-of select="descendant::t:lb[position() = last()]/@n"/>
</xsl:if>
</xsl:if>
<xsl:text>. </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> : </xsl:text>
</xsl:otherwise>
</xsl:choose>
<span>
<xsl:choose>
<xsl:when test="local-name()=('choice','subst','app')">
<!-- if there are more app elements inside the text part of the element, deal with them here -->
<xsl:variable name="part1">
<xsl:if
test="child::t:*[local-name()=('orig','sic','add','lem')]/t:*[local-name()=('choice','subst','app')]">
<!-- <xsl:call-template name="txPtchild"> -->
<xsl:call-template name="appcontent">
<!-- template txPtchild below -->
<xsl:with-param name="apptype" select="$apptype"/>
<xsl:with-param name="childtype" select="$childtype" />
</xsl:call-template>
</xsl:if>
</xsl:variable>
<xsl:variable name="part2">
<xsl:if
test="child::t:*[local-name()=('orig','sic','add','lem')]/t:*[local-name()=('choice','subst','app')]">
<xsl:call-template name="nonTxPtchild">
<!-- template nonTxPtchild below -->
<xsl:with-param name="apptype" select="$apptype"/>
<xsl:with-param name="childtype" select="$childtype" />
</xsl:call-template>
</xsl:if>
</xsl:variable>
<!-- generate the main content of the app here -->
<xsl:variable name="part3">
<xsl:call-template name="appcontent">
<xsl:with-param name="apptype" select="$apptype"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="part4">
<xsl:call-template name="nonTxPtchild">
<xsl:with-param name="apptype" select="$apptype"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="titleagg">
<xsl:choose>
<xsl:when test="$apptype=('appbl','apppn','apped')">
<xsl:choose>
<xsl:when test="($childtype = '' and normalize-space($part4) = '') or ($childtype != '' and normalize-space($part2) = '')"><xsl:call-template name="fnord-seperator">
<xsl:with-param name="part"><xsl:value-of select="$part3" /></xsl:with-param>
<xsl:with-param name="pos">first</xsl:with-param>
</xsl:call-template></xsl:when>
<xsl:when test="contains($part3, ' : ') and lem/@resp"><xsl:value-of select="substring-before($part3, ' :')"/></xsl:when>
<xsl:otherwise>Current edition</xsl:otherwise>
</xsl:choose>
<!-- <xsl:if test="starts-with(normalize-space($part3), 'cf.')"> which</xsl:if> -->
<xsl:choose>
<xsl:when test="$childtype='subst'"> reports </xsl:when>
<xsl:otherwise> gives </xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$childtype = 'subst'"><xsl:value-of select="normalize-space($part1)" />, then changed to <xsl:value-of select="normalize-space($part2)" /></xsl:when>
<xsl:when test="$childtype != ''"><xsl:value-of select="normalize-space($part2)" /><xsl:text>, </xsl:text><xsl:value-of select="normalize-space($part1)" /></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part4)"/></xsl:otherwise>
</xsl:choose><xsl:call-template name="fnord-seperator">
<xsl:with-param name="part"><xsl:value-of select="$part3" /></xsl:with-param>
<xsl:with-param name="pos">second</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$apptype = 'subst'">
<xsl:choose>
<xsl:when test="count(tokenize($part3, 'corr. ex')) > 2">
<xsl:variable name="bracketed" select="normalize-space(substring-before(substring-after($part3, '('), ')'))" />
Scribe wrote <xsl:value-of select="substring-after($bracketed, 'corr. ex ')" /> <xsl:value-of select="normalize-space(replace(substring-before($part3, '('), 'corr. ex', ', then changed to'))" />
</xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part3)"/></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$childtype != ''"><xsl:value-of select="normalize-space($part2)" /><xsl:if test="(not(ends-with(normalize-space($part2), ',')))">,</xsl:if><xsl:text> </xsl:text><xsl:value-of select="normalize-space($part1)" /></xsl:when>
<xsl:otherwise><xsl:if test="(not(ends-with(normalize-space($part3), ',')))">,</xsl:if> then changed to <xsl:value-of select="normalize-space($part4)"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($part3, 'FNORD-SPLIT') and contains($part1, 'FNORD-SPLIT') and $childtype != ''">
<xsl:call-template name="childpart">
<xsl:with-param name="childtype"><xsl:value-of select="$childtype" /></xsl:with-param>
<xsl:with-param name="apptype"><xsl:value-of select="$apptype" /></xsl:with-param>
<xsl:with-param name="part1"><xsl:value-of select="$part1" /></xsl:with-param>
<xsl:with-param name="part2"><xsl:value-of select="$part2" /></xsl:with-param>
</xsl:call-template><xsl:call-template name="fnord-seperator">
<xsl:with-param name="part"><xsl:value-of select="$part3" /></xsl:with-param>
<xsl:with-param name="pos">second</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($part3, 'FNORD-SPLIT')">
<xsl:choose>
<xsl:when test="$childtype != ''"><xsl:value-of select="normalize-space($part2)" /><xsl:text> </xsl:text><xsl:value-of select="normalize-space($part1)" /><xsl:if test="not(ends-with(normalize-space($part1), ',')) and not($apptype = 'appalt' and $childtype = '')">,</xsl:if></xsl:when>
<xsl:otherwise><xsl:if test="$apptype = 'appalt' and $childtype = ''">Scribe wrote</xsl:if> <xsl:value-of select="normalize-space($part4)"/><xsl:if test="not(ends-with(normalize-space($part4), ',')) and not($apptype = 'appalt' and $childtype = '')">,</xsl:if></xsl:otherwise>
</xsl:choose><xsl:text> </xsl:text>
<xsl:variable name="pt3">
<xsl:call-template name="fnord-seperator">
<xsl:with-param name="part"><xsl:value-of select="$part3" /></xsl:with-param>
<xsl:with-param name="pos">first</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$apptype = 'appalt'">
<xsl:choose>
<xsl:when test="contains($part3, 'l.')"><xsl:text>, </xsl:text><xsl:value-of select="normalize-space(substring-after(substring-before($part3, ')'), ' ('))"/><xsl:text> </xsl:text><xsl:value-of select="normalize-space(substring-before($part3, ' ('))"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part3)"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:if test="$apptype='origreg'">for which </xsl:if><xsl:value-of select="$pt3" /></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="contains($part1, 'FNORD-SPLIT')">
<xsl:call-template name="childpart">
<xsl:with-param name="childtype"><xsl:value-of select="$childtype" /></xsl:with-param>
<xsl:with-param name="apptype"><xsl:value-of select="$apptype" /></xsl:with-param>
<xsl:with-param name="part1"><xsl:value-of select="$part1" /></xsl:with-param>
<xsl:with-param name="part2"><xsl:value-of select="$part2" /></xsl:with-param>
</xsl:call-template>
<xsl:choose>
<xsl:when test="contains($part3, 'l.') and $apptype = 'appalt'"><xsl:text>, </xsl:text>
<xsl:value-of select="normalize-space(substring-after(substring-before($part3, ')'), ' ('))"/><xsl:text> </xsl:text><xsl:value-of select="normalize-space(substring-before($part3, ' ('))"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part3)"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:if test="($apptype = ('appalt') and $childtype = '') or $childtype = ('appalt')">Scribe wrote </xsl:if>
<xsl:choose>
<xsl:when test="$childtype='subst'"><xsl:value-of select="normalize-space($part1)" />, then changed to <xsl:value-of select="normalize-space($part2)" /><xsl:if test="(not(ends-with(normalize-space($part2), ',')))">,</xsl:if></xsl:when>
<xsl:when test="$childtype != ''"><xsl:value-of select="normalize-space($part2)" /><xsl:text> </xsl:text><xsl:value-of select="normalize-space($part1)" /><xsl:if test="(not(ends-with(normalize-space($part1), ',')) and $apptype != 'appalt')">,</xsl:if></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part4)"/><xsl:if test="(not(ends-with(normalize-space($part4), ',')) and $apptype != 'appalt')">,</xsl:if></xsl:otherwise>
</xsl:choose><xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="contains($part3, 'l.') and ($apptype = 'appalt' and $childtype != '')"><xsl:text>, </xsl:text><xsl:value-of select="normalize-space(substring-before($part3, ' ('))"/><xsl:text> </xsl:text><xsl:value-of select="normalize-space(substring-after(substring-before($part3, ')'), ' ('))"/></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space($part3)"/></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<!-- </xsl:if> -->
</xsl:variable>
<xsl:variable name="title">
<xsl:call-template name="title-convert">
<xsl:with-param name="apptype" select="$apptype"/>
<xsl:with-param name="childtype" select="$childtype"/>
<xsl:with-param name="obf" select="normalize-space($titleagg)"/>
</xsl:call-template>
</xsl:variable>
<xsl:attribute name="title"><xsl:apply-templates select="$title" mode="sqbrackets"/></xsl:attribute>
<!-- Parse app content to include html elements see: https://github.com/DCLP/dclpxsltbox/issues/137 -->
<xsl:call-template name="parse-app-parts"><xsl:with-param name="part" select="$part1"/></xsl:call-template><xsl:if test="normalize-space($part1) != '' and (not(ends-with(normalize-space($part1), ','))) and (not(ends-with(normalize-space($part1), '.')))">,</xsl:if><!-- --><xsl:text> </xsl:text><xsl:call-template name="parse-app-parts"><xsl:with-param name="part" select="$part3"/></xsl:call-template>
</xsl:when>
<!-- hi -->
<xsl:when test="local-name() = 'hi'">
<xsl:call-template name="hirend"/>
</xsl:when>
<!-- g -->
<xsl:when test="local-name() = 'g'">
<xsl:call-template name="grend"/>
</xsl:when>
<!-- del -->
<xsl:when test="local-name() = 'del'">
<xsl:choose>
<xsl:when test="@rend = 'slashes'">
<xsl:text>Text canceled with slashes</xsl:text>
</xsl:when>
<xsl:when test="@rend = 'cross-strokes'">
<xsl:text>Text canceled with cross-strokes</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="local-name() = 'milestone'">
<xsl:if test="@rend = 'box'">
<xsl:text>Text in box.</xsl:text>
</xsl:if>
</xsl:when>
</xsl:choose>
</span>
</xsl:template>
<!-- Parse app content to include html elements see: https://github.com/DCLP/dclpxsltbox/issues/137 -->
<xsl:template name="parse-app-parts">
<xsl:param name="part" xml:space="preserve"/>
<xsl:choose>
<xsl:when test="matches(normalize-space($part),'FNORD(\S)*')"><xsl:value-of select="normalize-space(replace(replace($part, 'FNORD(\S)*', ''), '\(\*\)', ''))"/></xsl:when>
<xsl:otherwise>
<xsl:for-each select="$part/node() | $part/text()">
<xsl:choose>
<xsl:when test="matches(normalize-space(.),'FNORD(\S)*')"><xsl:value-of select="normalize-space(replace(replace(., 'FNORD(\S)*', ''), '\(\*\)', ''))"/></xsl:when>
<xsl:when test="position() = last()">
<xsl:for-each select=".">
<xsl:choose>
<xsl:when test="self::text()">
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:value-of select="replace(.,'\s+$','')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy xml:space="preserve"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="name(.)='span'">
<xsl:element name="{name(.)}">
<xsl:copy-of select="@*"/>
<xsl:call-template name="parse-app-parts">
<xsl:with-param name="part" select="." xml:space="preserve"/>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="parse-app-parts">
<xsl:with-param name="part" select="." xml:space="preserve"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:when test="name(.)='span'">
<xsl:element name="{name(.)}">
<xsl:copy-of select="@*"/>
<xsl:call-template name="parse-app-parts">
<xsl:with-param name="part" select="." xml:space="preserve"/>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:when test="self::text()">
<xsl:copy xml:space="preserve"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="parse-app-parts">
<xsl:with-param name="part" select="." xml:space="preserve"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="nonTxPtchild">
<!-- prints the other bit of apparatus content for apps nested in the part of an app not normally printed in edition -->
<xsl:param name="apptype"/>
<xsl:param name="childtype"/>
<xsl:choose>
<!-- *APPED* -->
<xsl:when test="$apptype=('appbl','apppn','apped')">
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
<!-- *ORIG* (repeatable) -->
<xsl:when test="$childtype='origreg' or ($apptype='origreg' and $childtype='')">
<xsl:text>for which read </xsl:text>
<xsl:if test="$childtype != ''">
<xsl:for-each select="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/t:orig">
<xsl:sort select="position()" order="descending"/>
<!-- <xsl:value-of select="."/> -->
<xsl:apply-templates>
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:if>
<xsl:if test="$childtype = ''">
<xsl:for-each select="t:orig">
<xsl:sort select="position()" order="descending"/>
<!-- <xsl:value-of select="."/> -->
<xsl:apply-templates>
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:if>
</xsl:when>
<!-- *SIC* -->
<xsl:when test="$childtype=('siccorr') or $apptype=('siccorr')">
<xsl:text>((for which read)) </xsl:text>
<xsl:choose>
<xsl:when test="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/t:sic/node()">
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/t:sic/node()">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- *SUBST* -->
<xsl:when test="$childtype=('subst') or $apptype=('subst')">
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
<!-- *APPALT* -->
<xsl:when test="$childtype=('appalt') or $apptype=('appalt')">
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
<!-- *APPED* -->
<xsl:when test="$childtype=('appbl','apppn','apped')">
<xsl:apply-templates select="child::t:*[local-name()=('orig','sic','add','lem')]">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
<xsl:text> </xsl:text> <!---->
</xsl:template>
<xsl:template name="resolvesubst">
<!-- Deals with old/new encoding of subst -->
<!-- Used by: txPtchild, appcontent, teiaddanddel.xsl#t:add -->
<xsl:param name="addpath" select="''"/>
<xsl:param name="location" tunnel="yes" required="no"/>
<xsl:param name="delpath"/><xsl:choose>
<!-- Old encoding: (still supported) -->
<xsl:when test="(
not(preceding-sibling::node())
or matches(preceding-sibling::node()[1][self::text()], '[\s\n\r\t]')
or preceding-sibling::node()[1][self::t:lb]
)
and
(
not(following-sibling::node())
or matches(following-sibling::node()[1][self::text()], '[\s\n\r\t]')
)
and(child::t:*[local-name()=('orig','sic','add','lem')])
"><xsl:text>corr. ex </xsl:text>
<xsl:apply-templates select="$delpath"/>
</xsl:when>
<!-- New encoding (introduced in Nov/Dec 2011) -->
<!-- get full word -->
<xsl:otherwise>
<xsl:variable name="fullword">
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="preceding-sibling::node()[1]"/>
</xsl:call-template>
<xsl:apply-templates select="t:add/node()"/>
<xsl:call-template name="recurse_forward">
<xsl:with-param name="step" select="following-sibling::node()[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$fullword"/>
<!-- <xsl:text> </xsl:text> -->
<!-- Check that $addpath has been passed (might be excluded, see template matching t:add in teiaddanddel.xsl-->
<xsl:choose>
<xsl:when test="$addpath=''"/>
<xsl:otherwise><xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:apply-templates select="$addpath"/>
</xsl:with-param>
</xsl:call-template><xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose><xsl:text>corr. ex </xsl:text>
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:apply-templates select="$delpath"/>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose></xsl:template>
<xsl:template name="appcontent">
<!-- prints the content of apparatus; called by ddb-apparatus or by individual elements if nested -->
<xsl:param name="apptype"/>
<xsl:param name="childtype"/>
<xsl:variable name="path">
<xsl:choose>
<xsl:when test="$childtype='origreg' or $childtype=('siccorr')">
<xsl:copy-of select="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/child::*"/>
</xsl:when>
<xsl:when test="$childtype='subst'">
<xsl:copy-of select="child::t:*[local-name()=('orig','sic','add','lem')]/t:subst/child::*"/>
</xsl:when>
<xsl:when test="$childtype='appalt'">
<xsl:copy-of select="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='alternative']/child::*"/>
</xsl:when>
<xsl:when test="$childtype=('appbl','apppn','apped')">
<xsl:copy-of select="child::t:*[local-name()=('orig','sic','add','lem')]/t:app[@type='editorial']/child::*"/>
</xsl:when>
<!-- <xsl:when test="$apptype=('siccorr')"><xsl:value-of select="t:corr/node()"/></xsl:when> -->
<xsl:otherwise>
<xsl:copy-of select="node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--*!'<xsl:value-of select="$path"/>' - Childtype: '<xsl:value-of select="$childtype"/>' - Apptype: '<xsl:value-of select="$apptype"/>'
<xsl:for-each select="$path/*">
<xsl:value-of select="name()" />:
<xsl:for-each select="child::*">
'<xsl:value-of select="name()" /> - <xsl:value-of select="." />'
</xsl:for-each>
</xsl:for-each>-->
<!-- !*
**<xsl:value-of select="$apptype"/> - <xsl:value-of select="$childtype"/>**-->
<xsl:variable name="parent-lang">
<xsl:if test="(child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/child::t:reg[@xml:lang] and $childtype = 'origreg') or (child::t:reg[@xml:lang] and $apptype = 'origreg')">
<xsl:if test="$childtype = 'origreg'">
<xsl:value-of select="child::t:*[local-name()=('orig','sic','add','lem')]/t:choice/child::t:reg/ancestor::t:*[@xml:lang][1]/@xml:lang" />
</xsl:if>
<xsl:if test="$apptype = 'origreg'">
<xsl:value-of select="child::t:reg/ancestor::t:*[@xml:lang][1]/@xml:lang" />
</xsl:if>
</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="$childtype != '' and $apptype != $childtype">
<xsl:call-template name="appchoice">
<xsl:with-param name="apptype"><xsl:value-of select="$childtype"/></xsl:with-param>
<xsl:with-param name="path"><xsl:copy-of select="$path"/></xsl:with-param>
<xsl:with-param name="parent-lang"><xsl:value-of select="$parent-lang" /></xsl:with-param>
</xsl:call-template><xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="appchoice">
<xsl:with-param name="apptype"><xsl:value-of select="$apptype"/></xsl:with-param>
<xsl:with-param name="child"><xsl:if test="$childtype != ''">true</xsl:if></xsl:with-param>
<xsl:with-param name="path"><xsl:copy-of select="$path"/></xsl:with-param>
<xsl:with-param name="parent-lang"><xsl:value-of select="$parent-lang" /></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!--
<xsl:if test="$childtype != '' and $apptype != $childtype">
{*{<xsl:call-template name="appchoice">
<xsl:with-param name="apptype"><xsl:value-of select="$childtype"/></xsl:with-param>
<xsl:with-param name="path"><xsl:copy-of select="$path"/></xsl:with-param>
</xsl:call-template><xsl:text>, </xsl:text>}}
</xsl:if>
{'{<xsl:call-template name="appchoice">
<xsl:with-param name="apptype"><xsl:value-of select="$apptype"/></xsl:with-param>
<xsl:with-param name="child"><xsl:if test="$childtype != ''">true</xsl:if></xsl:with-param>
<xsl:with-param name="path"><xsl:copy-of select="$path"/></xsl:with-param>
</xsl:call-template>}}
-->
<!--
-->
<!-- <xsl:choose> -->
<!-- *REG* (repeatable) -->
<!-- <xsl:when test="($apptype='origreg' and $childtype='') or $childtype='origreg'"> -->
<!--**REG - <xsl:value-of select="$path/t:reg"/>** -->
<!-- <xsl:for-each select="$path/t:reg">
<xsl:sort select="position()" order="descending"/>
<xsl:call-template name="multreg"/>
</xsl:for-each>
<xsl:if test="$childtype != ''">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:when> -->
<!-- *CORR* -->
<!-- <xsl:when test="$apptype=('siccorr')"> -->
<!-- **CORR - <xsl:value-of select="$path/t:corr/node()"/>** -->
<!-- <xsl:text>l. </xsl:text>
<xsl:apply-templates select="$path/t:corr/node()"/>
<xsl:text> (corr)</xsl:text>
</xsl:when> -->
<!-- *SUBST* -->
<!-- <xsl:when test="($apptype='subst' and $childtype='') or $childtype='subst'"> -->
<!-- **SUBST - <xsl:value-of select="$path/t:del/node()"/>/<xsl:value-of select="$path/t:add/node()"/>** -->
<!-- <xsl:call-template name="resolvesubst">
<xsl:with-param name="delpath" select="$path/t:del/node()"/>
<xsl:with-param name="addpath" select="$path/t:add/node()"/>
</xsl:call-template>
</xsl:when> -->
<!-- *ALT* (repeatable) -->
<!-- <xsl:when test="$apptype='appalt'"> -->
<!-- **ALT - <xsl:value-of select="$path/t:rdg"/>** -->
<!-- <xsl:for-each select="$path/t:rdg">
<xsl:if test="position()!=1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:text> or </xsl:text>
<xsl:if test="not(.//text())">
<xsl:text>not </xsl:text>
<xsl:apply-templates select="preceding-sibling::t:lem"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:when> -->
<!-- *ED* (repeatable) -->
<!-- <xsl:when test="$apptype=('appbl','apppn','apped')">
<xsl:if test="starts-with(t:lem/@resp,'BL ')">
<xsl:if test="starts-with(substring-after(t:lem/@resp,'BL '),'cf.')">
<xsl:text> cf.</xsl:text>
</xsl:if>
<xsl:text> BL </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="starts-with(substring-after(t:lem/@resp,'BL '),'cf.')">
<xsl:value-of select="substring-after(t:lem/@resp,'cf.')"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:when test="starts-with(t:lem/@resp,'BL ')">
<xsl:value-of select="substring-after(t:lem/@resp,'BL ')"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:when test="starts-with(t:lem/@resp,'PN ')">
<xsl:value-of select="substring-after(t:lem/@resp,'PN ')"/>
<xsl:text> (via PN) : </xsl:text>
</xsl:when>
<xsl:when test="t:lem/@resp">
<xsl:value-of select="t:lem/@resp"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
<xsl:for-each select="t:rdg"> -->
<!-- found below -->
<!-- <xsl:call-template name="app-ed-mult-with-param">
<xsl:with-param name="check">fnord</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
</xsl:choose> -->
</xsl:template>
<xsl:template name="appchoice">
<xsl:param name="apptype" />
<xsl:param name="child" />
<xsl:param name="path" />
<xsl:param name="parent-lang" />
<!-- **<xsl:value-of select="$apptype"/> - <xsl:value-of select="$child"/>** -->
<!-- {{ (<xsl:value-of select="$path/*" />)
<xsl:for-each select="$path/*">
<xsl:value-of select="name()" />:
{<xsl:for-each select="child::*">
'<xsl:value-of select="name()" /> - <xsl:value-of select="." />'
</xsl:for-each>}
</xsl:for-each>}}-->
<xsl:choose>
<!-- *REG* (repeatable) -->
<xsl:when test="$apptype='origreg'">
<!-- **REG - <xsl:value-of select="$path/t:reg"/>** -->
<xsl:for-each select="$path/t:reg">
<xsl:sort select="position()" order="descending"/>
<!-- <xsl:value-of select="."/> -->
<xsl:call-template name="multreg">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
<xsl:with-param name="parent-lang"><xsl:value-of select="$parent-lang" /></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:if test="$child != ''">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:when>
<!-- *CORR* -->
<xsl:when test="$apptype=('siccorr')">
<!-- **CORR - <xsl:value-of select="$path/t:corr/node()"/>** -->
<xsl:text>l. </xsl:text>
<xsl:apply-templates select="$path/t:corr/node()">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
<xsl:text> (corr)</xsl:text>
</xsl:when>
<!-- *SUBST* -->
<xsl:when test="$apptype='subst'">
<!--**SUBST - <xsl:value-of select="$path/t:del/node()"/>/<xsl:value-of select="$path/t:add/node()"/>** -->
<xsl:call-template name="resolvesubst">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
<xsl:with-param name="delpath" select="$path/t:del/node()"/>
<xsl:with-param name="addpath" select="$path/t:add/node()"/>
</xsl:call-template>
</xsl:when>
<!-- *ALT* (repeatable) -->
<xsl:when test="$apptype='appalt'">
<!-- **ALT - <xsl:value-of select="$path/t:rdg"/>** -->
<xsl:for-each select="$path/t:rdg">
<xsl:if test="position()!=1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:text> or </xsl:text>
<xsl:if test="(not(.//text())) and (not(.//t:gap))">
<xsl:text>not </xsl:text>
<xsl:apply-templates select="preceding-sibling::t:lem">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select=".">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:when>
<!-- *ED* (repeatable) -->
<xsl:when test="$apptype=('appbl','apppn','apped')">
<xsl:if test="starts-with($path/t:lem/@resp,'BL ')">
<xsl:if test="starts-with(substring-after($path/t:lem/@resp,'BL '),'cf.')">
<xsl:text> cf.</xsl:text>
</xsl:if>
<xsl:text> BL </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="starts-with(substring-after($path/t:lem/@resp,'BL '),'cf.')">
<xsl:value-of select="substring-after($path/t:lem/@resp,'cf.')"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:when test="starts-with($path/t:lem/@resp,'BL ')">
<xsl:value-of select="substring-after($path/t:lem/@resp,'BL ')"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:when test="starts-with($path/t:lem/@resp,'PN ')">
<xsl:value-of select="substring-after($path/t:lem/@resp,'PN ')"/>
<xsl:text> (via PN) : </xsl:text>
</xsl:when>
<xsl:when test="$path/t:lem/@resp">
<xsl:value-of select="$path/t:lem/@resp"/>
<xsl:text> : </xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
<xsl:for-each select="$path/t:rdg">
<!-- found below -->
<xsl:call-template name="app-ed-mult-with-param">
<xsl:with-param name="check">fnord</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- The recurse_* templates handle isolating the piece of text that will be printed in the apparatus,
by finding the word breaks before and after it.-->
<xsl:template name="recurse_back">
<!-- Recurse through preceding sibling nodes until a space or carriage return is found -->
<!-- Used by hirend, appcontent -->
<!-- When used by hirend ($origin='hi'), will strip diacritics -->
<xsl:param name="step"/>
<xsl:param name="buildup"/>
<xsl:variable name="origin" select="name()"/>
<xsl:variable name="origin_id" select="generate-id()"/>
<xsl:choose>
<xsl:when test="$step[self::t:lb[not(@break='no')]]">
<xsl:copy-of select="$buildup"/>
</xsl:when>
<xsl:when test="$step[self::text()]">
<xsl:choose>
<xsl:when test="matches($step, '[\s\n\r\t]')">
<xsl:choose>
<xsl:when test="string-length($buildup) = 0">
<xsl:choose>
<xsl:when test="$origin='hi'">
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:copy-of select="$buildup"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- if the text node is a first child and a space hasn't been located yet... -->
<xsl:when test="not($step/preceding-sibling::node()[1])">
<xsl:variable name="temp-buildup">
<xsl:choose>
<xsl:when test="$origin='hi'">
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="$buildup"/>
</xsl:variable>
<xsl:for-each select="$step/ancestor::*[preceding-sibling::node()][1]">
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="preceding-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="$temp-buildup"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="temp-buildup">
<xsl:choose>
<xsl:when test="$origin='hi'">
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="$buildup"/>
</xsl:variable>
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="$step/preceding-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="$temp-buildup"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- if the element is nested and a space hasn't been located yet... -->
<xsl:when test="not($step/preceding-sibling::node()[1])">
<xsl:for-each select="$step/ancestor::*[preceding-sibling::node()][1]">
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="preceding-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="$buildup"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:when test="$step/preceding-sibling::node()[1][self::t:lb][not(@break='no')]"/>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$step[self::t:hi]">
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="$step/preceding-sibling::node()[1]"/>
</xsl:call-template>
<xsl:for-each select="$step">
<xsl:call-template name="hirend_print"/>
</xsl:for-each>
<xsl:copy-of select="$buildup"/>
</xsl:when>
<xsl:when test="$step[self::t:subst]">
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="$step/preceding-sibling::node()[1]"/>
</xsl:call-template>
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:apply-templates select="$step//t:add/node()"/>
</xsl:with-param>
</xsl:call-template>
<xsl:copy-of select="$buildup"/>
</xsl:when>
<xsl:when test="($step[self::text] or $step[self::*]) and matches($step, '[\s\n\r\t]')">
<xsl:variable name="builddown">
<xsl:call-template name="recurse_down_back">
<xsl:with-param name="step" select="$step"/>
<xsl:with-param name="buildup" select="$buildup"/>
<xsl:with-param name="origin" select="$origin"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="$builddown/node()"/>
<xsl:copy-of select="$buildup"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="temp-buildup">
<xsl:choose>
<xsl:when test="$step/t:hi[generate-id()=$origin_id]"/>
<xsl:when test="$step/t:hi">
<xsl:for-each select="$step/t:hi">
<xsl:call-template name="hirend_print"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$step">
<xsl:with-param name="location" select="'apparatus'" tunnel="yes"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="$buildup"/>
</xsl:variable>
<xsl:call-template name="recurse_back">
<xsl:with-param name="step" select="$step/preceding-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="$temp-buildup"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="recurse_down_back">
<!-- Recurse through child nodes until a space or carriage return is found. Re-create elements when necessary -->
<!-- Used by recurse_back -->
<!-- Handles buildup for right-to-left space/return search -->
<xsl:param name="step"/>
<xsl:param name="buildup"/>
<xsl:param name="origin"/>
<xsl:choose>
<xsl:when test="$step[self::text()]">
<xsl:choose>
<xsl:when test="$origin='hi'">
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="buildup"/>
</xsl:when>
<xsl:when test="$step[self::t:hi]">
<xsl:for-each select="$step">
<xsl:call-template name="hirend_print"/>
</xsl:for-each>
<xsl:copy-of select="$buildup"/>
</xsl:when>
<!-- Special handling for t:orig -->
<xsl:when test="$step[self::t:orig[parent::t:choice]]">
<xsl:for-each select="$step/node()">
<xsl:variable name="curstep-id" select="generate-id($step)"/>
<xsl:choose>
<xsl:when test="matches(., '[\s\n\r\t]')"/>
<xsl:when test="following::text()[generate-id(ancestor::node()[1])=$curstep-id and matches(., '[\s\n\r\t]')]">
<xsl:call-template name="recurse_down_back">
<xsl:with-param name="step" select="following-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="buildup"/>
<xsl:with-param name="origin" select="$origin"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="recurse_down_back">
<xsl:with-param name="step" select="."/>
<xsl:with-param name="buildup" select="buildup"/>
<xsl:with-param name="origin" select="$origin"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$step/name()}" xmlns="http://www.tei-c.org/ns/1.0">
<xsl:sequence select="$step/@*"/>
<xsl:choose>
<xsl:when test="$step/text() and not($step/*)">
<xsl:choose>
<xsl:when test="$origin='hi'">
<xsl:call-template name="trans-string">
<xsl:with-param name="trans-text">
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step/text()"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="string-after-space">
<xsl:with-param name="test-string" select="$step/text()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="buildup"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$step/node()">
<xsl:variable name="curstep-id" select="generate-id($step)"/>
<xsl:choose>
<xsl:when test="matches(., '[\s\n\r\t]')"/>
<xsl:when test="following::text()[generate-id(ancestor::node()[1])=$curstep-id and matches(., '[\s\n\r\t]')]">
<xsl:call-template name="recurse_down_back">
<xsl:with-param name="step" select="following-sibling::node()[1]"/>
<xsl:with-param name="buildup" select="buildup"/>
<xsl:with-param name="origin" select="$origin"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="recurse_down_back">
<xsl:with-param name="step" select="."/>
<xsl:with-param name="buildup" select="buildup"/>
<xsl:with-param name="origin" select="$origin"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="recurse_forward">
<!-- Recurse through following sibling nodes until a space or carriage return is found -->
<!-- Used by hirend, appcontent -->
<xsl:param name="step"/>
<xsl:variable name="origin" select="name()"/>
<xsl:variable name="origin_id" select="generate-id()"/>
<xsl:choose>
<xsl:when test="$step[self::t:lb[not(@break='no')]]"/>
<xsl:when test="$step[self::text()]">
<xsl:choose>