forked from dita-ot/dita-ot
/
tables.xsl
1060 lines (1004 loc) · 46 KB
/
tables.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" ?>
<!--
This file is part of the DITA Open Toolkit project.
Copyright 2004, 2005 IBM Corporation
See the accompanying LICENSE file for applicable license.
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
exclude-result-prefixes="xs dita-ot dita2html ditamsg">
<!-- =========== CALS (OASIS) TABLE =========== -->
<!-- XML Exchange Table Model Document Type Definition default is all -->
<xsl:variable name="table.frame-default" select="'all'"/>
<!-- XML Exchange Table Model Document Type Definition default is 1 -->
<xsl:variable name="table.rowsep-default" select="'0'"/>
<!-- XML Exchange Table Model Document Type Definition default is 1 -->
<xsl:variable name="table.colsep-default" select="'0'"/>
<xsl:template match="*[contains(@class, ' topic/table ')]" mode="generate-table-summary-attribute">
<!-- Override this to use a local convention for setting table's @summary attribute,
until OASIS provides a standard mechanism for setting. -->
</xsl:template>
<xsl:template match="*[contains(@class,' topic/table ')]
[empty(*[contains(@class,' topic/tgroup ')]/*[contains(@class,' topic/tbody ')]/*[contains(@class,' topic/row ')])]" priority="10"/>
<xsl:template match="*[contains(@class,' topic/tgroup ')]
[empty(*[contains(@class,' topic/tbody ')]/*[contains(@class,' topic/row ')])]" priority="10"/>
<xsl:template match="*[contains(@class, ' topic/table ')]" name="topic.table">
<xsl:value-of select="$newline"/>
<!-- special case for IE & NS for frame & no rules - needs to be a double table -->
<xsl:variable name="colsep">
<xsl:choose>
<xsl:when test="*[contains(@class, ' topic/tgroup ')]/@colsep">
<xsl:value-of select="*[contains(@class, ' topic/tgroup ')]/@colsep"/>
</xsl:when>
<xsl:when test="@colsep">
<xsl:value-of select="@colsep"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowsep">
<xsl:choose>
<xsl:when test="*[contains(@class, ' topic/tgroup ')]/@rowsep">
<xsl:value-of select="*[contains(@class, ' topic/tgroup ')]/@rowsep"/>
</xsl:when>
<xsl:when test="@rowsep">
<xsl:value-of select="@rowsep"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@frame = 'all' and $colsep = '0' and $rowsep = '0'">
<table cellpadding="4" cellspacing="0" border="1" class="tableborder">
<tr>
<td>
<xsl:value-of select="$newline"/>
<xsl:call-template name="dotable"/>
</td>
</tr>
</table>
</xsl:when>
<xsl:when test="@frame = 'top' and $colsep = '0' and $rowsep = '0'">
<hr />
<xsl:value-of select="$newline"/>
<xsl:call-template name="dotable"/>
</xsl:when>
<xsl:when test="@frame = 'bot' and $colsep = '0' and $rowsep = '0'">
<xsl:call-template name="dotable"/>
<hr />
<xsl:value-of select="$newline"/>
</xsl:when>
<xsl:when test="@frame = 'topbot' and $colsep = '0' and $rowsep = '0'">
<hr />
<xsl:value-of select="$newline"/>
<xsl:call-template name="dotable"/>
<hr />
<xsl:value-of select="$newline"/>
</xsl:when>
<xsl:when test="not(@frame) and $colsep = '0' and $rowsep = '0'">
<table cellpadding="4" cellspacing="0" border="1" class="tableborder">
<tr>
<td>
<xsl:value-of select="$newline"/>
<xsl:call-template name="dotable"/>
</td>
</tr>
</table>
</xsl:when>
<xsl:otherwise>
<div class="tablenoborder">
<xsl:call-template name="dotable"/>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template name="dotable">
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:call-template name="setaname"/>
<table cellpadding="4" cellspacing="0" summary="">
<xsl:variable name="colsep">
<xsl:choose>
<xsl:when test="*[contains(@class, ' topic/tgroup ')]/@colsep"><xsl:value-of select="*[contains(@class, ' topic/tgroup ')]/@colsep"/></xsl:when>
<xsl:when test="@colsep"><xsl:value-of select="@colsep"/></xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowsep">
<xsl:choose>
<xsl:when test="*[contains(@class, ' topic/tgroup ')]/@rowsep"><xsl:value-of select="*[contains(@class, ' topic/tgroup ')]/@rowsep"/></xsl:when>
<xsl:when test="@rowsep"><xsl:value-of select="@rowsep"/></xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="setid"/>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="." mode="generate-table-summary-attribute"/>
<xsl:call-template name="setscale"/>
<!-- When a table's width is set to page or column, force it's width to 100%. If it's in a list, use 90%.
Otherwise, the table flows to the content -->
<xsl:choose>
<xsl:when test="(@expanse = 'page' or @pgwide = '1')and (ancestor::*[contains(@class, ' topic/li ')] or ancestor::*[contains(@class, ' topic/dd ')] )">
<xsl:attribute name="width">90%</xsl:attribute>
</xsl:when>
<xsl:when test="(@expanse = 'column' or @pgwide = '0') and (ancestor::*[contains(@class, ' topic/li ')] or ancestor::*[contains(@class, ' topic/dd ')] )">
<xsl:attribute name="width">90%</xsl:attribute>
</xsl:when>
<xsl:when test="(@expanse = 'page' or @pgwide = '1')">
<xsl:attribute name="width">100%</xsl:attribute>
</xsl:when>
<xsl:when test="(@expanse = 'column' or @pgwide = '0')">
<xsl:attribute name="width">100%</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="@frame = 'all' and $colsep = '0' and $rowsep = '0'">
<xsl:attribute name="border">0</xsl:attribute>
</xsl:when>
<xsl:when test="not(@frame) and $colsep = '0' and $rowsep = '0'">
<xsl:attribute name="border">0</xsl:attribute>
</xsl:when>
<xsl:when test="@frame = 'sides'">
<xsl:attribute name="frame">vsides</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:when>
<xsl:when test="@frame = 'top'">
<xsl:attribute name="frame">above</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:when>
<xsl:when test="@frame = 'bottom'">
<xsl:attribute name="frame">below</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:when>
<xsl:when test="@frame = 'topbot'">
<xsl:attribute name="frame">hsides</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:when>
<xsl:when test="@frame = 'none'">
<xsl:attribute name="frame">void</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="frame">border</xsl:attribute>
<xsl:attribute name="border">1</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@frame = 'all' and $colsep = '0' and $rowsep = '0'">
<xsl:attribute name="border">0</xsl:attribute>
</xsl:when>
<xsl:when test="not(@frame) and $colsep = '0' and $rowsep = '0'">
<xsl:attribute name="border">0</xsl:attribute>
</xsl:when>
<xsl:when test="$colsep = '0' and $rowsep = '0'">
<xsl:attribute name="rules">none</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</xsl:when>
<xsl:when test="$colsep = '0'">
<xsl:attribute name="rules">rows</xsl:attribute>
</xsl:when>
<xsl:when test="$rowsep = '0'">
<xsl:attribute name="rules">cols</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="rules">all</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="place-tbl-lbl"/>
<!-- title and desc are processed elsewhere -->
<xsl:apply-templates select="*[contains(@class, ' topic/tgroup ')]"/>
</table><xsl:value-of select="$newline"/>
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/tgroup ')]" name="topic.tgroup">
<xsl:variable name="totalwidth" as="xs:double">
<xsl:variable name="relative-widths" as="xs:double*">
<xsl:for-each select="*[contains(@class, ' topic/colspec ')][contains(@colwidth, '*')]">
<xsl:sequence select="xs:double(translate(@colwidth, '*', ''))"/>
</xsl:for-each>
</xsl:variable>
<xsl:sequence select="sum($relative-widths)"/>
</xsl:variable>
<xsl:if test="exists(*[contains(@class, ' topic/colspec ')])">
<colgroup>
<xsl:apply-templates select="*[contains(@class, ' topic/colspec ')]">
<xsl:with-param name="totalwidth" select="$totalwidth"/>
</xsl:apply-templates>
</colgroup>
</xsl:if>
<xsl:apply-templates select="* except *[contains(@class, ' topic/colspec ')]">
<xsl:with-param name="totalwidth" select="$totalwidth"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/colspec ')]">
<xsl:param name="totalwidth" as="xs:double"/>
<xsl:variable name="width" as="xs:string?">
<xsl:choose>
<xsl:when test="empty(@colwidth)"/>
<xsl:when test="contains(@colwidth, '*')">
<xsl:value-of select="concat((xs:double(translate(@colwidth, '*', '')) div $totalwidth) * 100, '%')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@colwidth"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<col>
<xsl:if test="exists($width)">
<xsl:attribute name="style" select="concat('width:', $width)"/>
</xsl:if>
</col>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/thead ')]" name="topic.thead">
<thead>
<!-- Get style from parent tgroup, then override with thead if specified locally -->
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:choose>
<xsl:when test="@align">
<xsl:text>text-align:</xsl:text>
<xsl:value-of select="@align"/>
<xsl:text>;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="th-align"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@valign">
<xsl:text>vertical-align:</xsl:text>
<xsl:value-of select="@valign"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:if test="@char">
<xsl:attribute name="char" select="@char"/>
</xsl:if>
<xsl:if test="@charoff">
<xsl:attribute name="charoff" select="@charoff"/>
</xsl:if>
<xsl:apply-templates/>
</thead><xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/tbody ')]" name="topic.tbody">
<tbody>
<!-- Get style from parent tgroup, then override with thead if specified locally -->
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:if test="@align">
<xsl:text>text-align:</xsl:text>
<xsl:value-of select="@align"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="@valign">
<xsl:text>vertical-align:</xsl:text>
<xsl:value-of select="@valign"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:if test="@char">
<xsl:attribute name="char" select="@char"/>
</xsl:if>
<xsl:if test="@charoff">
<xsl:attribute name="charoff" select="@charoff"/>
</xsl:if>
<xsl:apply-templates/>
</tbody><xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/row ')]" name="topic.row">
<tr>
<xsl:call-template name="setid"/>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:if test="@align">
<xsl:text>text-align:</xsl:text>
<xsl:value-of select="@align"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="@valign">
<xsl:text>vertical-align:</xsl:text>
<xsl:value-of select="@valign"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:if test="@char">
<xsl:attribute name="char" select="@char"/>
</xsl:if>
<xsl:if test="@charoff">
<xsl:attribute name="charoff" select="@charoff"/>
</xsl:if>
<xsl:apply-templates/>
</tr><xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/entry ')]" name="topic.entry">
<xsl:choose>
<xsl:when test="parent::*/parent::*[contains(@class, ' topic/thead ')]">
<xsl:call-template name="topic.thead_entry"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="topic.tbody_entry"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- do header entries -->
<xsl:template name="topic.thead_entry">
<th>
<xsl:call-template name="doentry"/>
</th><xsl:value-of select="$newline"/>
</xsl:template>
<!-- do body entries -->
<xsl:template name="topic.tbody_entry">
<xsl:choose>
<xsl:when test="../../../../@rowheader = 'firstcol' and @dita-ot:x = 1">
<th><xsl:call-template name="doentry"/></th>
</xsl:when>
<xsl:otherwise>
<td><xsl:call-template name="doentry"/></td>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template name="doentry">
<xsl:variable name="this-colname" select="@colname"/>
<!-- Rowsep/colsep: Skip if the last row or column. Only check the entry and colsep;
if set higher, will already apply to the whole table. -->
<xsl:variable name="row" select=".." as="element()"/>
<xsl:variable name="body" select="../.." as="element()"/>
<xsl:variable name="group" select="../../.." as="element()"/>
<xsl:variable name="colspec" select="../../../*[contains(@class, ' topic/colspec ')][@colname and @colname = $this-colname]" as="element()?"/>
<xsl:variable name="table" select="../../../.." as="element()"/>
<xsl:variable name="framevalue">
<xsl:choose>
<xsl:when test="$table/@frame and $table/@frame != ''">
<xsl:value-of select="$table/@frame"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$table.frame-default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rowsep" as="xs:integer">
<xsl:variable name="last-row" select="(../../../*/*[contains(@class, ' topic/row ')])[last()]" as="element()"/>
<xsl:choose>
<!-- If there are more rows, keep rows on -->
<xsl:when test="not(. << $last-row)">
<xsl:choose>
<xsl:when test="$framevalue = 'all' or $framevalue = 'bottom' or $framevalue = 'topbot'">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@rowsep"><xsl:value-of select="@rowsep"/></xsl:when>
<xsl:when test="$row/@rowsep"><xsl:value-of select="$row/@rowsep"/></xsl:when>
<xsl:when test="$colspec/@rowsep"><xsl:value-of select="$colspec/@rowsep"/></xsl:when>
<xsl:when test="$table/@rowsep"><xsl:value-of select="$table/@rowsep"/></xsl:when>
<xsl:otherwise>
<xsl:value-of select="$table.rowsep-default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="colsep" as="xs:integer">
<xsl:choose>
<!-- If there are more columns, keep rows on -->
<xsl:when test="empty(following-sibling::*)">
<xsl:choose>
<xsl:when test="$framevalue = 'all' or $framevalue = 'sides'">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@colsep"><xsl:value-of select="@colsep"/></xsl:when>
<xsl:when test="$colspec/@colsep"><xsl:value-of select="$colspec/@colsep"/></xsl:when>
<xsl:when test="$table/@colsep"><xsl:value-of select="$table/@colsep"/></xsl:when>
<xsl:otherwise>
<xsl:value-of select="$table.colsep-default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="firstcol" as="xs:boolean" select="$table/@rowheader = 'firstcol' and @dita-ot:x = '1'"/>
<xsl:call-template name="commonattributes">
<xsl:with-param name="default-output-class">
<xsl:if test="$firstcol">firstcol </xsl:if>
<xsl:choose>
<xsl:when test="$rowsep = 0 and $colsep = 0">nocellnorowborder</xsl:when>
<xsl:when test="$rowsep = 1 and $colsep = 0">row-nocellborder</xsl:when>
<xsl:when test="$rowsep = 0 and $colsep = 1">cell-norowborder</xsl:when>
<xsl:when test="$rowsep = 1 and $colsep = 1">cellrowborder</xsl:when>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
<xsl:choose>
<xsl:when test="@id">
<xsl:call-template name="setid"/>
</xsl:when>
<xsl:when test="$firstcol">
<xsl:attribute name="id" select="generate-id(.)"/>
</xsl:when>
</xsl:choose>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan"> <!-- set the number of rows to span -->
<xsl:value-of select="@morerows + 1"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@dita-ot:morecols"> <!-- get the number of columns to span from the specified named column values -->
<xsl:attribute name="colspan" select="@dita-ot:morecols + 1"/>
</xsl:if>
<!-- If align is specified on a colspec, that takes priority over tgroup -->
<!-- If align is locally specified, that takes priority over all -->
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:variable name="align" as="xs:string?">
<xsl:choose>
<xsl:when test="@align">
<xsl:value-of select="@align"/>
</xsl:when>
<xsl:when test="$group/@align">
<xsl:value-of select="$group/@align"/>
</xsl:when>
<xsl:when test="$colspec/@align">
<xsl:value-of select="$colspec/@align"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="exists($align)">
<xsl:text>text-align:</xsl:text>
<xsl:value-of select="$align"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:variable name="valign" as="xs:string?">
<xsl:choose>
<xsl:when test="@valign">
<xsl:value-of select="@valign"/>
</xsl:when>
<xsl:when test="$row/@valign">
<xsl:value-of select="$row/@valign"/>
</xsl:when>
<xsl:when test="$body/@valign">
<xsl:value-of select="$body/@valign"/>
</xsl:when>
<xsl:otherwise>top</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="exists($valign)">
<xsl:text>vertical-align:</xsl:text>
<xsl:value-of select="$valign"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:variable name="char" as="xs:string?">
<xsl:choose>
<xsl:when test="@char">
<xsl:value-of select="@char"/>
</xsl:when>
<xsl:when test="$colspec/@char">
<xsl:value-of select="$colspec/@char"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$char">
<xsl:attribute name="char" select="$char"/>
</xsl:if>
<xsl:variable name="charoff" as="xs:string?">
<xsl:choose>
<xsl:when test="@charoff">
<xsl:value-of select="@charoff"/>
</xsl:when>
<xsl:when test="$colspec/@charoff">
<xsl:value-of select="$colspec/@charoff"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$charoff">
<xsl:attribute name="charoff" select="$charoff"/>
</xsl:if>
<xsl:choose>
<!-- When entry is in a thead, output the ID -->
<xsl:when test="$body/self::*[contains(@class, ' topic/thead ')]">
<xsl:attribute name="id" select="dita-ot:generate-html-id(.)"/>
</xsl:when>
<!-- otherwise, add @headers if needed -->
<xsl:otherwise>
<xsl:call-template name="add-headers-attribute"/>
</xsl:otherwise>
</xsl:choose>
<!-- Add any flags from tgroup, thead or tbody, and row -->
<xsl:apply-templates select="$group/*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:apply-templates select="$body/*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:apply-templates select="$row/*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:choose>
<!-- When entry is empty, output a blank -->
<xsl:when test="not(*|text()|processing-instruction())">
<xsl:text> </xsl:text> <!-- nbsp -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="$row/*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
<xsl:apply-templates select="$body/*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
<xsl:apply-templates select="$group/*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
</xsl:template>
<!-- Find the end column of a cell. If the cell does not span any columns,
the end position is the same as the start position. -->
<xsl:template name="find-entry-end-position">
<xsl:param name="startposition" select="0"/>
<xsl:choose>
<xsl:when test="@nameend">
<xsl:value-of select="number(count(../../../*[contains(@class, ' topic/colspec ')][@colname = current()/@nameend]/preceding-sibling::*[contains(@class, ' topic/colspec ')])+1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$startposition"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Check <thead> entries, and return IDs for those which match the desired column -->
<xsl:template match="*[contains(@class, ' topic/thead ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]" mode="findmatch">
<xsl:param name="startmatch" select="1"/> <!-- start column of the tbody cell -->
<xsl:param name="endmatch" select="1"/> <!-- end column of the tbody cell -->
<xsl:variable name="entrystartpos" select="@dita-ot:x"/> <!-- start column of this thead cell -->
<xsl:variable name="entryendpos"> <!-- end column of this thead cell -->
<xsl:call-template name="find-entry-end-position">
<xsl:with-param name="startposition" select="$entrystartpos"/>
</xsl:call-template>
</xsl:variable>
<!-- The test cell can be any of the following:
* completely before the header range (ignore id)
* completely after the header range (ignore id)
* completely within the header range (save id)
* partially before, partially within (save id)
* partially within, partially after (save id)
* completely surrounding the header range (save id) -->
<xsl:choose>
<!-- Ignore this header cell if it starts after the tbody cell we are testing -->
<xsl:when test="number($endmatch) < number($entrystartpos)"/>
<!-- Ignore this header cell if it ends before the tbody cell we are testing -->
<xsl:when test="number($startmatch) > number($entryendpos)"/>
<!-- Otherwise, this header lines up with the tbody cell, so use the ID -->
<xsl:otherwise>
<xsl:value-of select="dita-ot:generate-html-id(.)"/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Check the first column for entries that line up with the test row.
Any entries that line up need to have the header saved. This template is first
called with the first entry of the first row in <tbody>. It is called from here
on the next cell in column one. -->
<xsl:template match="*[contains(@class, ' topic/entry ')]" mode="check-first-column">
<xsl:param name="startMatchRow" select="1"/> <!-- First row of the tbody cell we are matching -->
<xsl:param name="endMatchRow" select="1"/> <!-- Last row of the tbody cell we are matching -->
<xsl:param name="startCurrentRow" select="1"/> <!-- First row of the column-1 cell we are testing -->
<xsl:variable name="endCurrentRow"> <!-- Last row of the column-1 cell we are testing -->
<xsl:choose>
<!-- If @morerows, the cell ends at startCurrentRow + @morerows. Otherise, start=end. -->
<xsl:when test="@morerows"><xsl:value-of select="number($startCurrentRow)+number(@morerows)"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$startCurrentRow"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<!-- When the current column-1 cell ends before the tbody cell we are matching -->
<xsl:when test="number($endCurrentRow) < number($startMatchRow)">
<!-- Call this template again with the next entry in column one -->
<xsl:if test="parent::*/parent::*/*[contains(@class, ' topic/row ')][number($endCurrentRow)+1]">
<xsl:apply-templates select="parent::*/parent::*/*[contains(@class, ' topic/row ')][number($endCurrentRow)+1]/*[contains(@class, ' topic/entry ')][1]" mode="check-first-column">
<xsl:with-param name="startMatchRow" select="$startMatchRow"/>
<xsl:with-param name="endMatchRow" select="$endMatchRow"/>
<xsl:with-param name="startCurrentRow" select="number($endCurrentRow)+1"/>
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<!-- If this column-1 cell starts after the tbody cell we are matching, jump out of recursive loop -->
<xsl:when test="number($startCurrentRow) > number($endMatchRow)"/>
<!-- Otherwise, the column-1 cell is aligned with the tbody cell, so save the ID and continue -->
<xsl:otherwise>
<xsl:value-of select="generate-id(.)"/><xsl:text> </xsl:text>
<!-- If we are not at the end of the tbody cell, and more rows exist, continue testing column 1 -->
<xsl:if test="number($endCurrentRow) < number($endMatchRow) and
parent::*/parent::*/*[contains(@class, ' topic/row ')][number($endCurrentRow)+1]">
<xsl:apply-templates select="parent::*/parent::*/*[contains(@class, ' topic/row ')][number($endCurrentRow)+1]/*[contains(@class, ' topic/entry ')][1]" mode="check-first-column">
<xsl:with-param name="startMatchRow" select="$startMatchRow"/>
<xsl:with-param name="endMatchRow" select="$endMatchRow"/>
<xsl:with-param name="startCurrentRow" select="number($endCurrentRow)+1"/>
</xsl:apply-templates>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Add @headers to cells in the body of a table. -->
<xsl:template name="add-headers-attribute">
<!-- Determine the start column for the current cell -->
<xsl:variable name="entrystartpos" select="@dita-ot:x">
</xsl:variable>
<!-- Determine the end column for the current cell -->
<xsl:variable name="entryendpos">
<xsl:call-template name="find-entry-end-position">
<xsl:with-param name="startposition" select="$entrystartpos"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the IDs of headers that are aligned above this cell. This is done by applying
templates on all headers, using mode=findmatch; matching IDs are returned. -->
<xsl:variable name="hdrattr">
<xsl:apply-templates select="../../../*[contains(@class, ' topic/thead ')]/
*[contains(@class, ' topic/row ')]/
*[contains(@class, ' topic/entry ')]" mode="findmatch">
<xsl:with-param name="startmatch" select="$entrystartpos"/>
<xsl:with-param name="endmatch" select="$entryendpos"/>
</xsl:apply-templates>
</xsl:variable>
<!-- Find the IDs of headers in the first column, which are aligned with this cell -->
<xsl:variable name="rowheader">
<!-- If this entry is not in the first column or in thead, and @rowheader=firstcol on table -->
<xsl:if test="not(number($entrystartpos) = 1) and
not(parent::*/parent::*[contains(@class, ' topic/thead ')]) and
../../../../@rowheader = 'firstcol'">
<!-- Find the start row for this entry -->
<xsl:variable name="startrow" select="number(count(parent::*/preceding-sibling::*[contains(@class, ' topic/row ')])+1)"/>
<!-- Find the end row for this entry -->
<xsl:variable name="endrow">
<xsl:if test="@morerows"><xsl:value-of select="number($startrow) + number(@morerows)"/></xsl:if>
<xsl:if test="not(@morerows)"><xsl:value-of select="$startrow"/></xsl:if>
</xsl:variable>
<!-- Scan first-column entries for ones that align with this cell, starting with
the first entry in the first row -->
<xsl:apply-templates select="../../*[contains(@class, ' topic/row ')][1]/*[contains(@class, ' topic/entry ')][1]" mode="check-first-column">
<xsl:with-param name="startMatchRow" select="$startrow"/>
<xsl:with-param name="endMatchRow" select="$endrow"/>
</xsl:apply-templates>
</xsl:if>
</xsl:variable>
<xsl:if test="string-length($rowheader) > 0 or string-length($hdrattr) > 0">
<xsl:attribute name="headers" select="concat($rowheader, $hdrattr)"/>
</xsl:if>
</xsl:template>
<!-- =========== SimpleTable - SEMANTIC TABLE =========== -->
<xsl:template match="*[contains(@class,' topic/simpletable ')]
[empty(*[contains(@class,' topic/strow ')]/*[contains(@class,' topic/stentry ')])]" priority="10"/>
<xsl:template match="*[contains(@class,' topic/strow ') or contains(@class,' topic/sthead ')][empty(*[contains(@class,' topic/stentry ')])]" priority="10"/>
<xsl:template match="*[contains(@class, ' topic/simpletable ')]" mode="generate-table-summary-attribute">
<!-- Override this to use a local convention for setting table's @summary attribute,
until OASIS provides a standard mechanism for setting. -->
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/simpletable ')]" name="topic.simpletable">
<xsl:call-template name="spec-title"/>
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:call-template name="setaname"/>
<table cellpadding="4" cellspacing="0" summary="">
<xsl:call-template name="setid"/>
<xsl:choose>
<xsl:when test="@frame = 'none'">
<xsl:attribute name="border">0</xsl:attribute>
<xsl:attribute name="class">simpletablenoborder</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="border">1</xsl:attribute>
<xsl:attribute name="class">simpletableborder</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="." mode="generate-table-summary-attribute"/>
<xsl:call-template name="setscale"/>
<xsl:call-template name="dita2html:simpletable-cols"/>
<xsl:apply-templates select="." mode="dita2html:simpletable-heading"/>
<tbody>
<xsl:apply-templates select="*[contains(@class, ' topic/strow ')]|processing-instruction()"/>
</tbody>
</table>
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template name="dita2html:simpletable-cols">
<xsl:variable name="col-count" as="xs:integer">
<xsl:apply-templates select="." mode="dita2html:get-max-entry-count"/>
</xsl:variable>
<xsl:variable name="col-widths" as="xs:double*">
<xsl:variable name="widths" select="tokenize(normalize-space(translate(@relcolwidth, '*', '')), '\s+')" as="xs:string*"/>
<xsl:for-each select="$widths">
<xsl:choose>
<xsl:when test=". castable as xs:double">
<xsl:sequence select="xs:double(.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="xs:double(1)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="1 to ($col-count - count($widths))">
<xsl:sequence select="xs:double(1)"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="col-widths-sum" select="sum($col-widths)"/>
<xsl:for-each select="$col-widths">
<col style="width:{(. div $col-widths-sum) * 100}%"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/simpletable ')]" mode="dita2html:get-max-entry-count" as="xs:integer">
<xsl:variable name="counts" as="xs:integer*">
<xsl:for-each select="*[contains(@class, ' topic/sthead ')] |
*[contains(@class, ' topic/strow ')]">
<xsl:sequence select="count(*[contains(@class, ' topic/stentry ')])"/>
</xsl:for-each>
</xsl:variable>
<xsl:sequence select="max($counts)"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/strow ')]" name="topic.strow">
<tr>
<xsl:call-template name="setid"/>
<xsl:call-template name="commonattributes"/>
<xsl:choose>
<!-- If there are any rows or headers before this, the width values have already been set. -->
<xsl:when test="preceding-sibling::*[contains(@class, ' topic/strow ')]">
<xsl:apply-templates/>
</xsl:when>
<!-- Otherwise, this is the first row. Pass the percentage to all entries in this row. -->
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</tr><xsl:value-of select="$newline"/>
</xsl:template>
<!-- Specialized simpletables may match this rule to create default column
headings. By default, process the sthead if available. -->
<xsl:template match="*" mode="dita2html:simpletable-heading">
<thead>
<xsl:apply-templates select="*[contains(@class, ' topic/sthead ')]"/>
</thead>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/sthead ')]" name="topic.sthead">
<tr>
<xsl:call-template name="commonattributes"/>
<!-- There is only one sthead, so use the entries in the header to set relative widths. -->
<xsl:apply-templates/>
</tr><xsl:value-of select="$newline"/>
</xsl:template>
<!-- Output the ID for a simpletable entry, when it is specified. If no ID is specified,
and this is a header row, generate an ID. The entry is considered a header entry
when the it is inside <sthead>, or when it is in the column specified in the keycol
attribute on <simpletable>
NOTE: It references simpletable with parent::*/parent::* in order to avoid problems
with nested simpletables. -->
<xsl:template name="output-stentry-id">
<!-- Find the position in this row -->
<xsl:variable name="thiscolnum"><xsl:number level="single" count="*[contains(@class, ' topic/stentry ')]"/></xsl:variable>
<xsl:choose>
<xsl:when test="@id"> <!-- If ID is specified, always use it -->
<xsl:attribute name="id" select="dita-ot:generate-html-id(.)"/>
</xsl:when>
<!-- If no ID is specified, and this is a header cell, generate an ID -->
<xsl:when test="parent::*[contains(@class, ' topic/sthead ')] or
(parent::*/parent::*/@keycol and number(parent::*/parent::*/@keycol) = number($thiscolnum))">
<xsl:attribute name="id" select="generate-id(.)"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Output the headers attribute for screen readers. If specified, it should match both
of the following:
* the <stentry> with the same position in the sthead
* the <stentry> that is in the key column (specified in @keycol on simpletable)
Note: This function is not called within sthead, so sthead never gets headers.
NOTE: I reference simpletable with parent::*/parent::* in order to avoid problems
with nested simpletables. -->
<xsl:template name="set.stentry.headers">
<xsl:variable name="keycol" select="parent::*/parent::*/@keycol"/>
<xsl:if test="$keycol | parent::*/parent::*/*[contains(@class, ' topic/sthead ')]">
<xsl:variable name="thiscolnum"><xsl:number level="single" count="*[contains(@class, ' topic/stentry ')]"/></xsl:variable>
<!-- If there is a keycol, and this is not the key column, get the ID for the keycol -->
<xsl:variable name="keycolhead">
<xsl:if test="$keycol and $thiscolnum != number($keycol)">
<xsl:variable name="col" select="../*[number($keycol)]"/>
<xsl:choose>
<xsl:when test="$col/@id">
<xsl:value-of select="$col/@id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="generate-id($col)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<!-- If there is a header, get the ID from the head cell in this column.
Go up to simpletable, into the row, to the entry at column $thiscolnum -->
<xsl:variable name="header">
<xsl:if test="parent::*/parent::*/*[contains(@class, ' topic/sthead ')]/*[contains(@class, ' topic/stentry ')][number($thiscolnum)]">
<xsl:value-of select="dita-ot:generate-html-id(parent::*/parent::*/*[contains(@class, ' topic/sthead ')]/*[contains(@class, ' topic/stentry ')][number($thiscolnum)])"/>
</xsl:if>
</xsl:variable>
<!-- If there is a keycol header or an sthead header, create the attribute -->
<xsl:if test="string-length($header) > 0 or string-length($keycolhead) > 0">
<xsl:attribute name="headers">
<xsl:value-of select="$header"/>
<xsl:if test="string-length($header) > 0 and string-length($keycolhead) > 0"><xsl:text> </xsl:text></xsl:if>
<xsl:value-of select="$keycolhead"/>
</xsl:attribute>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="*[contains(@class, ' topic/stentry ')]" name="topic.stentry">
<xsl:choose>
<xsl:when test="parent::*[contains(@class, ' topic/sthead ')]">
<xsl:call-template name="topic.sthead_stentry"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="topic.strow_stentry"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- sthead/stentry - bottom align the header text -->
<xsl:template name="topic.sthead_stentry">
<th>
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:text>vertical-align:bottom;</xsl:text>
<xsl:call-template name="th-align"/>
</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="output-stentry-id"/>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:choose>
<!-- If there is text, or a PI, or non-flagging element child -->
<xsl:when test="*[not(contains(@class, ' ditaot-d/startprop ') or contains(@class, ' dita-ot/endprop '))] | text() | processing-instruction()">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<!-- Add flags, then either @specentry or NBSP -->
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:choose>
<xsl:when test="@specentry"><xsl:value-of select="@specentry"/></xsl:when>
<xsl:otherwise> </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
</th><xsl:value-of select="$newline"/>
</xsl:template>
<!-- For simple table headers: <TH> Set align="right" when in a BIDI area -->
<xsl:template name="th-align">
<xsl:variable name="biditest" as="xs:boolean">
<xsl:call-template name="bidi-area"/>
</xsl:variable>
<xsl:text>text-align:</xsl:text>
<xsl:value-of select="if ($biditest) then 'right' else 'left'"/>
<xsl:text>;</xsl:text>
</xsl:template>
<!-- stentry -->
<!-- for specentry - if no text in cell, output specentry attr; otherwise output text -->
<!-- Bold the @keycol column. Get the column's number. When (Nth stentry = the @keycol value) then bold the stentry -->
<xsl:template name="topic.strow_stentry">
<xsl:variable name="localkeycol">
<xsl:choose>
<xsl:when test="ancestor::*[contains(@class, ' topic/simpletable ')]/@keycol">
<xsl:value-of select="ancestor::*[contains(@class, ' topic/simpletable ')]/@keycol"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Determine which column this entry is in. -->
<xsl:variable name="thiscolnum" select="number(count(preceding-sibling::*[contains(@class, ' topic/stentry ')])+1)"/>
<xsl:variable name="element-name">
<xsl:choose>
<xsl:when test="$thiscolnum = $localkeycol">th</xsl:when>
<xsl:otherwise>td</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$element-name}">
<xsl:call-template name="style">
<xsl:with-param name="contents">
<xsl:text>vertical-align:top;</xsl:text>
</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="output-stentry-id"/>
<xsl:call-template name="set.stentry.headers"/>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
<xsl:call-template name="stentry-templates"/>
<xsl:apply-templates select="../*[contains(@class, ' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
</xsl:element>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template name="stentry-templates">
<xsl:choose>
<xsl:when test="not(*|text()|processing-instruction()) and @specentry">
<xsl:value-of select="@specentry"/>
</xsl:when>
<xsl:when test="not(*|text()|processing-instruction())">
<xsl:text> </xsl:text> <!-- nbsp -->
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ========== "FORMAT" MACROS - Table title, figure title, InfoNavGraphic ========== -->
<!--
| These macros support globally-defined formatting constants for
| document content. Some elements have attributes that permit local
| control of formatting; such logic is part of the pertinent template rule.
+-->
<xsl:template name="place-tbl-width">
<xsl:variable name="twidth-fixed">100%</xsl:variable>
<xsl:if test="$twidth-fixed != ''">
<xsl:attribute name="width" select="$twidth-fixed"/>
</xsl:if>
</xsl:template>
<!-- table caption -->
<xsl:template name="place-tbl-lbl">
<xsl:param name="stringName"/>
<!-- Number of table/title's before this one -->
<xsl:variable name="tbl-count-actual" select="count(preceding::*[contains(@class, ' topic/table ')]/*[contains(@class, ' topic/title ')])+1"/>
<!-- normally: "Table 1. " -->
<xsl:variable name="ancestorlang">
<xsl:call-template name="getLowerCaseLang"/>
</xsl:variable>
<xsl:choose>
<!-- title -or- title & desc -->
<xsl:when test="*[contains(@class, ' topic/title ')]">
<caption>
<span class="tablecap">
<span class="table--title-label">
<!-- TODO language specific processing should be done with string variables -->
<xsl:choose> <!-- Hungarian: "1. Table " -->
<xsl:when test="$ancestorlang = ('hu', 'hu-hu')">