metanorma-bipm 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -167,7 +167,7 @@
167
167
  <xsl:template name="generateContents">
168
168
  <contents>
169
169
 
170
- <xsl:apply-templates select="/*/bipm:preface/*[position() &gt; 1]" mode="contents"/>
170
+ <xsl:apply-templates select="/*/bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][position() &gt; 1]" mode="contents"/>
171
171
 
172
172
  <xsl:apply-templates select="/*/bipm:sections/*" mode="contents"/>
173
173
  <xsl:apply-templates select="/*/bipm:bibliography/bipm:references[@normative='true']" mode="contents"/>
@@ -631,7 +631,7 @@
631
631
  </xsl:template>
632
632
 
633
633
 
634
- <xsl:template match="bipm:note" name="change_note_kind" mode="flatxml">
634
+ <xsl:template match="bipm:note[not(parent::bipm:preface)]" name="change_note_kind" mode="flatxml">
635
635
  <xsl:variable name="element">
636
636
  <xsl:choose>
637
637
  <xsl:when test="ancestor::bipm:quote">note</xsl:when>
@@ -949,7 +949,9 @@
949
949
 
950
950
  <xsl:call-template name="insertFootnoteSeparator"/>
951
951
 
952
- <xsl:call-template name="insertHeaderDraftWatermark"/>
952
+ <xsl:call-template name="insertHeaderDraftWatermark">
953
+ <xsl:with-param name="lang" select="$curr_lang"/>
954
+ </xsl:call-template>
953
955
 
954
956
  <fo:flow flow-name="xsl-region-body" font-family="Arial">
955
957
 
@@ -1020,17 +1022,17 @@
1020
1022
  </fo:page-sequence>
1021
1023
 
1022
1024
 
1023
- <xsl:if test="bipm:preface/*">
1025
+ <xsl:if test="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')]">
1024
1026
  <fo:page-sequence master-reference="document" force-page-count="no-force">
1025
1027
  <xsl:call-template name="insertFootnoteSeparator"/>
1026
1028
 
1027
1029
  <xsl:variable name="header-title">
1028
1030
  <xsl:choose>
1029
- <xsl:when test="bipm:preface/*[1]/bipm:title[1]/*[local-name() = 'tab']">
1030
- <xsl:apply-templates select="bipm:preface/*[1]/bipm:title[1]/*[local-name() = 'tab'][1]/following-sibling::node()" mode="header"/>
1031
+ <xsl:when test="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]/bipm:title[1]/*[local-name() = 'tab']">
1032
+ <xsl:apply-templates select="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]/bipm:title[1]/*[local-name() = 'tab'][1]/following-sibling::node()" mode="header"/>
1031
1033
  </xsl:when>
1032
1034
  <xsl:otherwise>
1033
- <xsl:apply-templates select="bipm:preface/*[1]/bipm:title[1]" mode="header"/>
1035
+ <xsl:apply-templates select="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]/bipm:title[1]" mode="header"/>
1034
1036
  </xsl:otherwise>
1035
1037
  </xsl:choose>
1036
1038
  </xsl:variable>
@@ -1040,7 +1042,7 @@
1040
1042
 
1041
1043
  <fo:flow flow-name="xsl-region-body">
1042
1044
  <fo:block line-height="135%">
1043
- <xsl:apply-templates select="bipm:preface/*[1]"/>
1045
+ <xsl:apply-templates select="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]"/>
1044
1046
  </fo:block>
1045
1047
  </fo:flow>
1046
1048
  </fo:page-sequence>
@@ -1139,7 +1141,7 @@
1139
1141
  </fo:page-sequence>
1140
1142
 
1141
1143
 
1142
- <xsl:apply-templates select="bipm:preface/*[position() &gt; 1]" mode="sections"/> <!-- bipm:clause -->
1144
+ <xsl:apply-templates select="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][position() &gt; 1]" mode="sections"/> <!-- bipm:clause -->
1143
1145
 
1144
1146
 
1145
1147
 
@@ -1164,6 +1166,7 @@
1164
1166
  <!-- Index -->
1165
1167
  <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:indexsect" mode="index">
1166
1168
  <xsl:with-param name="isDraft" select="normalize-space(//bipm:bipm-standard/bipm:bibdata/bipm:version/bipm:draft or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'draft') or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'projet'))"/>
1169
+ <xsl:with-param name="lang" select="$curr_lang"/>
1167
1170
  </xsl:apply-templates>
1168
1171
 
1169
1172
  <!-- End Document Pages -->
@@ -1304,7 +1307,7 @@
1304
1307
  </fo:page-sequence>
1305
1308
 
1306
1309
 
1307
- <xsl:apply-templates select="bipm:preface/*" mode="sections"/>
1310
+ <xsl:apply-templates select="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')]" mode="sections"/>
1308
1311
 
1309
1312
  <!-- Document Pages -->
1310
1313
  <xsl:apply-templates select="bipm:sections/*" mode="sections"/>
@@ -1324,6 +1327,7 @@
1324
1327
  <!-- Index -->
1325
1328
  <xsl:apply-templates select="xalan:nodeset($indexes)/doc[@id = $docid]//bipm:indexsect" mode="index">
1326
1329
  <xsl:with-param name="isDraft" select="normalize-space(//bipm:bipm-standard/bipm:bibdata/bipm:version/bipm:draft or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'draft') or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'projet'))"/>
1330
+ <xsl:with-param name="lang" select="$curr_lang"/>
1327
1331
  </xsl:apply-templates>
1328
1332
 
1329
1333
  </xsl:otherwise>
@@ -1640,7 +1644,9 @@
1640
1644
  </fo:block>
1641
1645
  </fo:block-container>
1642
1646
 
1643
- <xsl:call-template name="insertDraftWatermark"/>
1647
+ <xsl:call-template name="insertDraftWatermark">
1648
+ <xsl:with-param name="lang" select="$doc_split_by_language"/>
1649
+ </xsl:call-template>
1644
1650
 
1645
1651
  <!-- BIPM logo -->
1646
1652
  <fo:block-container absolute-position="fixed" left="12.8mm" top="12.2mm">
@@ -2280,7 +2286,7 @@
2280
2286
  <!-- ====== -->
2281
2287
 
2282
2288
 
2283
- <xsl:template match="bipm:preface/*[1]" priority="3">
2289
+ <xsl:template match="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]" priority="3">
2284
2290
  <fo:table table-layout="fixed" width="173.5mm">
2285
2291
  <xsl:call-template name="setId"/>
2286
2292
  <fo:table-column column-width="137mm"/>
@@ -2371,7 +2377,7 @@
2371
2377
  </xsl:template>
2372
2378
 
2373
2379
 
2374
- <xsl:template match="bipm:preface/*[1]/*" mode="clause_table">
2380
+ <xsl:template match="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]/*" mode="clause_table">
2375
2381
  <xsl:param name="rows"/>
2376
2382
 
2377
2383
  <xsl:variable name="current_row"><xsl:number count="*"/></xsl:variable>
@@ -2403,7 +2409,7 @@
2403
2409
  <xsl:variable name="end_row" select="$current_row + $number-rows-spanned"/>
2404
2410
  <fo:block>
2405
2411
 
2406
- <xsl:for-each select="ancestor::bipm:preface/*[1]/*[position() &gt;= $start_row and position() &lt; $end_row]//bipm:note_side">
2412
+ <xsl:for-each select="ancestor::bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]/*[position() &gt;= $start_row and position() &lt; $end_row]//bipm:note_side">
2407
2413
  <xsl:apply-templates select="." mode="note_side"/>
2408
2414
  </xsl:for-each>
2409
2415
  </fo:block>
@@ -2663,7 +2669,7 @@
2663
2669
 
2664
2670
 
2665
2671
  <!-- skip, because it process in note_side template -->
2666
- <xsl:template match="bipm:preface/*[1]//bipm:note_side" priority="3"/>
2672
+ <xsl:template match="bipm:preface/*[not(local-name() = 'note' or local-name() = 'admonition')][1]//bipm:note_side" priority="3"/>
2667
2673
 
2668
2674
 
2669
2675
  <xsl:template match="bipm:sections//bipm:note_side | bipm:annex//bipm:note_side" priority="3">
@@ -2727,6 +2733,7 @@
2727
2733
 
2728
2734
  <xsl:template match="bipm:p" name="paragraph">
2729
2735
  <xsl:param name="inline" select="'false'"/>
2736
+ <xsl:param name="split_keep-within-line"/>
2730
2737
 
2731
2738
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
2732
2739
  <xsl:variable name="element-name">
@@ -2773,7 +2780,9 @@
2773
2780
  <xsl:attribute name="role">BlockQuote</xsl:attribute>
2774
2781
  </xsl:if>
2775
2782
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
2776
- <xsl:apply-templates/>
2783
+ <xsl:apply-templates>
2784
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
2785
+ </xsl:apply-templates>
2777
2786
  </xsl:element>
2778
2787
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
2779
2788
  <fo:block margin-bottom="6pt">
@@ -3270,9 +3279,11 @@
3270
3279
  <xsl:param name="header-title"/>
3271
3280
  <xsl:param name="orientation"/>
3272
3281
  <xsl:param name="isDraft"/>
3282
+ <xsl:param name="lang"/>
3273
3283
  <fo:static-content flow-name="header-odd" role="artifact">
3274
3284
  <xsl:call-template name="insertDraftWatermark">
3275
3285
  <xsl:with-param name="isDraft" select="$isDraft"/>
3286
+ <xsl:with-param name="lang" select="$lang"/>
3276
3287
  </xsl:call-template>
3277
3288
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3278
3289
  <fo:block text-align="right">
@@ -3293,6 +3304,7 @@
3293
3304
  <fo:static-content flow-name="header-even" role="artifact">
3294
3305
  <xsl:call-template name="insertDraftWatermark">
3295
3306
  <xsl:with-param name="isDraft" select="$isDraft"/>
3307
+ <xsl:with-param name="lang" select="$lang"/>
3296
3308
  </xsl:call-template>
3297
3309
  <fo:block-container font-family="Arial" font-size="8pt" padding-top="12.5mm">
3298
3310
  <fo:block>
@@ -3310,6 +3322,7 @@
3310
3322
  <fo:static-content flow-name="header-blank" role="artifact">
3311
3323
  <xsl:call-template name="insertDraftWatermark">
3312
3324
  <xsl:with-param name="isDraft" select="$isDraft"/>
3325
+ <xsl:with-param name="lang" select="$lang"/>
3313
3326
  </xsl:call-template>
3314
3327
  <fo:block/>
3315
3328
  </fo:static-content>
@@ -3317,12 +3330,23 @@
3317
3330
 
3318
3331
  <xsl:template name="insertDraftWatermark">
3319
3332
  <xsl:param name="isDraft"/>
3333
+ <xsl:param name="lang"/>
3320
3334
  <xsl:if test="$isDraft = 'true' or normalize-space(//bipm:bipm-standard/bipm:bibdata/bipm:version/bipm:draft or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'draft') or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'projet')) = 'true'">
3321
3335
  <!-- DRAFT -->
3322
3336
  <xsl:variable name="draft_label">
3323
- <xsl:call-template name="getLocalizedString">
3324
- <xsl:with-param name="key">draft_label</xsl:with-param>
3325
- </xsl:call-template>
3337
+ <xsl:choose>
3338
+ <xsl:when test="normalize-space($lang) != ''">
3339
+ <xsl:call-template name="getLocalizedString">
3340
+ <xsl:with-param name="key">draft_label</xsl:with-param>
3341
+ <xsl:with-param name="lang" select="$lang"/>
3342
+ </xsl:call-template>
3343
+ </xsl:when>
3344
+ <xsl:otherwise>
3345
+ <xsl:call-template name="getLocalizedString">
3346
+ <xsl:with-param name="key">draft_label</xsl:with-param>
3347
+ </xsl:call-template>
3348
+ </xsl:otherwise>
3349
+ </xsl:choose>
3326
3350
  </xsl:variable>
3327
3351
  <fo:block-container absolute-position="fixed" left="0mm" top="30mm">
3328
3352
  <fo:block line-height="0">
@@ -3352,25 +3376,30 @@
3352
3376
 
3353
3377
  <xsl:template name="insertHeaderDraftWatermark">
3354
3378
  <xsl:variable name="isDraft" select="normalize-space(//bipm:bipm-standard/bipm:bibdata/bipm:version/bipm:draft or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'draft') or contains(//bipm:bipm-standard/bipm:bibdata/bipm:status/bipm:stage, 'projet'))"/>
3379
+ <xsl:variable name="curr_lang" select="$doc_split_by_language"/>
3355
3380
  <xsl:if test="$isDraft = 'true'">
3356
3381
  <fo:static-content flow-name="header-blank" role="artifact">
3357
3382
  <xsl:call-template name="insertDraftWatermark">
3358
3383
  <xsl:with-param name="isDraft" select="$isDraft"/>
3384
+ <xsl:with-param name="lang" select="$curr_lang"/>
3359
3385
  </xsl:call-template>
3360
3386
  </fo:static-content>
3361
3387
  <fo:static-content flow-name="header" role="artifact">
3362
3388
  <xsl:call-template name="insertDraftWatermark">
3363
3389
  <xsl:with-param name="isDraft" select="$isDraft"/>
3390
+ <xsl:with-param name="lang" select="$curr_lang"/>
3364
3391
  </xsl:call-template>
3365
3392
  </fo:static-content>
3366
3393
  <fo:static-content flow-name="header-odd" role="artifact">
3367
3394
  <xsl:call-template name="insertDraftWatermark">
3368
3395
  <xsl:with-param name="isDraft" select="$isDraft"/>
3396
+ <xsl:with-param name="lang" select="$curr_lang"/>
3369
3397
  </xsl:call-template>
3370
3398
  </fo:static-content>
3371
3399
  <fo:static-content flow-name="header-even" role="artifact">
3372
3400
  <xsl:call-template name="insertDraftWatermark">
3373
3401
  <xsl:with-param name="isDraft" select="$isDraft"/>
3402
+ <xsl:with-param name="lang" select="$curr_lang"/>
3374
3403
  </xsl:call-template>
3375
3404
  </fo:static-content>
3376
3405
  </xsl:if>
@@ -3423,6 +3452,7 @@
3423
3452
  <xsl:template match="bipm:indexsect"/>
3424
3453
  <xsl:template match="bipm:indexsect" mode="index">
3425
3454
  <xsl:param name="isDraft"/>
3455
+ <xsl:param name="lang"/>
3426
3456
 
3427
3457
  <fo:page-sequence master-reference="index" force-page-count="no-force">
3428
3458
  <xsl:variable name="header-title">
@@ -3438,6 +3468,7 @@
3438
3468
  <xsl:call-template name="insertHeaderFooter">
3439
3469
  <xsl:with-param name="header-title" select="$header-title"/>
3440
3470
  <xsl:with-param name="isDraft" select="$isDraft"/>
3471
+ <xsl:with-param name="lang" select="$lang"/>
3441
3472
  </xsl:call-template>
3442
3473
 
3443
3474
  <fo:flow flow-name="xsl-region-body">
@@ -3810,12 +3841,41 @@
3810
3841
  </xsl:template>
3811
3842
 
3812
3843
 
3813
- <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:variable name="lang">
3844
+ <xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:param name="table_if">false</xsl:param><xsl:param name="table_widths"/><xsl:variable name="table_widths_from_if" select="xalan:nodeset($table_widths)"/><xsl:variable name="table_widths_from_if_calculated_">
3845
+ <xsl:for-each select="$table_widths_from_if//table">
3846
+ <xsl:copy>
3847
+ <xsl:copy-of select="@*"/>
3848
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm"/>
3849
+ </xsl:copy>
3850
+ </xsl:for-each>
3851
+ </xsl:variable><xsl:variable name="table_widths_from_if_calculated" select="xalan:nodeset($table_widths_from_if_calculated_)"/><xsl:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
3852
+ false
3853
+ </xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
3814
3854
  <xsl:call-template name="getLang"/>
3815
- </xsl:variable><xsl:variable name="pageWidth_">
3816
- 210
3855
+ </xsl:variable><xsl:variable name="papersize" select="java:toLowerCase(java:java.lang.String.new(normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata']/*[local-name() = 'papersize'])))"/><xsl:variable name="papersize_width_">
3856
+ <xsl:choose>
3857
+ <xsl:when test="$papersize = 'letter'">215.9</xsl:when>
3858
+ <xsl:when test="$papersize = 'a4'">210</xsl:when>
3859
+ </xsl:choose>
3860
+ </xsl:variable><xsl:variable name="papersize_width" select="normalize-space($papersize_width_)"/><xsl:variable name="papersize_height_">
3861
+ <xsl:choose>
3862
+ <xsl:when test="$papersize = 'letter'">279.4</xsl:when>
3863
+ <xsl:when test="$papersize = 'a4'">297</xsl:when>
3864
+ </xsl:choose>
3865
+ </xsl:variable><xsl:variable name="papersize_height" select="normalize-space($papersize_height_)"/><xsl:variable name="pageWidth_">
3866
+ <xsl:choose>
3867
+ <xsl:when test="$papersize_width != ''"><xsl:value-of select="$papersize_width"/></xsl:when>
3868
+ <xsl:otherwise>
3869
+ 210
3870
+ </xsl:otherwise>
3871
+ </xsl:choose>
3817
3872
  </xsl:variable><xsl:variable name="pageWidth" select="normalize-space($pageWidth_)"/><xsl:variable name="pageHeight_">
3818
- 297
3873
+ <xsl:choose>
3874
+ <xsl:when test="$papersize_height != ''"><xsl:value-of select="$papersize_height"/></xsl:when>
3875
+ <xsl:otherwise>
3876
+ 297
3877
+ </xsl:otherwise>
3878
+ </xsl:choose>
3819
3879
  </xsl:variable><xsl:variable name="pageHeight" select="normalize-space($pageHeight_)"/><xsl:variable name="marginLeftRight1_">
3820
3880
  31.7
3821
3881
  </xsl:variable><xsl:variable name="marginLeftRight1" select="normalize-space($marginLeftRight1_)"/><xsl:variable name="marginLeftRight2_">
@@ -3931,9 +3991,10 @@
3931
3991
  <xsl:value-of select="$titles/*[local-name() = $name][@lang = 'en']"/>
3932
3992
  </xsl:otherwise>
3933
3993
  </xsl:choose>
3934
- </xsl:template><xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable><xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable><xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/><xsl:attribute-set name="root-style">
3994
+ </xsl:template><xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable><xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable><xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/><xsl:variable name="font_noto_sans">Noto Sans, Noto Sans HK, Noto Sans JP, Noto Sans KR, Noto Sans SC, Noto Sans TC</xsl:variable><xsl:variable name="font_noto_sans_mono">Noto Sans Mono, Noto Sans Mono CJK HK, Noto Sans Mono CJK JP, Noto Sans Mono CJK KR, Noto Sans Mono CJK SC, Noto Sans Mono CJK TC</xsl:variable><xsl:variable name="font_noto_serif">Noto Serif, Noto Serif HK, Noto Serif JP, Noto Serif KR, Noto Serif SC, Noto Serif TC</xsl:variable><xsl:attribute-set name="root-style">
3935
3995
 
3936
- <xsl:attribute name="font-family">Times New Roman, STIX Two Math, Source Han Sans</xsl:attribute>
3996
+ <xsl:attribute name="font-family">Times New Roman, STIX Two Math, <xsl:value-of select="$font_noto_serif"/></xsl:attribute>
3997
+ <xsl:attribute name="font-family-generic">Serif</xsl:attribute>
3937
3998
  <xsl:attribute name="font-size">10.5pt</xsl:attribute>
3938
3999
 
3939
4000
 
@@ -3951,6 +4012,7 @@
3951
4012
 
3952
4013
 
3953
4014
 
4015
+
3954
4016
  </xsl:attribute-set><xsl:template name="insertRootStyle">
3955
4017
  <xsl:param name="root-style"/>
3956
4018
  <xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
@@ -3962,17 +4024,60 @@
3962
4024
  </xsl:variable>
3963
4025
  <xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
3964
4026
 
4027
+ <xsl:variable name="font_family_generic" select="$root-style_/root-style/@font-family-generic"/>
4028
+
3965
4029
  <xsl:for-each select="$root-style_/root-style/@*">
4030
+
3966
4031
  <xsl:choose>
3967
- <xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
4032
+ <xsl:when test="local-name() = 'font-family-generic'"><!-- skip, it's using for determine 'sans' or 'serif' --></xsl:when>
4033
+ <xsl:when test="local-name() = 'font-family'">
4034
+
4035
+ <xsl:variable name="font_regional_prefix">
4036
+ <xsl:choose>
4037
+ <xsl:when test="$font_family_generic = 'Sans'">Noto Sans</xsl:when>
4038
+ <xsl:otherwise>Noto Serif</xsl:otherwise>
4039
+ </xsl:choose>
4040
+ </xsl:variable>
4041
+
3968
4042
  <xsl:attribute name="{local-name()}">
3969
- <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
4043
+
4044
+ <xsl:variable name="font_extended">
4045
+ <xsl:choose>
4046
+ <xsl:when test="$lang = 'zh'"><xsl:value-of select="$font_regional_prefix"/> SC</xsl:when>
4047
+ <xsl:when test="$lang = 'hk'"><xsl:value-of select="$font_regional_prefix"/> HK</xsl:when>
4048
+ <xsl:when test="$lang = 'jp'"><xsl:value-of select="$font_regional_prefix"/> JP</xsl:when>
4049
+ <xsl:when test="$lang = 'kr'"><xsl:value-of select="$font_regional_prefix"/> KR</xsl:when>
4050
+ <xsl:when test="$lang = 'sc'"><xsl:value-of select="$font_regional_prefix"/> SC</xsl:when>
4051
+ <xsl:when test="$lang = 'tc'"><xsl:value-of select="$font_regional_prefix"/> TC</xsl:when>
4052
+ </xsl:choose>
4053
+ </xsl:variable>
4054
+ <xsl:if test="normalize-space($font_extended) != ''">
4055
+ <xsl:value-of select="$font_regional_prefix"/><xsl:text>, </xsl:text>
4056
+ <xsl:value-of select="$font_extended"/><xsl:text>, </xsl:text>
4057
+ </xsl:if>
4058
+
4059
+ <xsl:value-of select="."/>
4060
+
4061
+ <xsl:if test="$additional_fonts != ''">
4062
+ <xsl:text>, </xsl:text><xsl:value-of select="$additional_fonts"/>
4063
+ </xsl:if>
3970
4064
  </xsl:attribute>
3971
4065
  </xsl:when>
3972
4066
  <xsl:otherwise>
3973
4067
  <xsl:copy-of select="."/>
3974
4068
  </xsl:otherwise>
3975
4069
  </xsl:choose>
4070
+
4071
+ <!-- <xsl:choose>
4072
+ <xsl:when test="local-name() = 'font-family'">
4073
+ <xsl:attribute name="{local-name()}">
4074
+ <xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
4075
+ </xsl:attribute>
4076
+ </xsl:when>
4077
+ <xsl:otherwise>
4078
+ <xsl:copy-of select="."/>
4079
+ </xsl:otherwise>
4080
+ </xsl:choose> -->
3976
4081
  </xsl:for-each>
3977
4082
  </xsl:template><xsl:attribute-set name="copyright-statement-style">
3978
4083
 
@@ -4058,6 +4163,7 @@
4058
4163
 
4059
4164
 
4060
4165
 
4166
+
4061
4167
 
4062
4168
 
4063
4169
 
@@ -4098,6 +4204,7 @@
4098
4204
 
4099
4205
 
4100
4206
 
4207
+
4101
4208
 
4102
4209
  </xsl:attribute-set><xsl:attribute-set name="example-style">
4103
4210
 
@@ -4112,6 +4219,7 @@
4112
4219
 
4113
4220
 
4114
4221
 
4222
+
4115
4223
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
4116
4224
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4117
4225
 
@@ -4135,6 +4243,7 @@
4135
4243
 
4136
4244
 
4137
4245
 
4246
+
4138
4247
 
4139
4248
 
4140
4249
 
@@ -4167,6 +4276,7 @@
4167
4276
 
4168
4277
  </xsl:attribute-set><xsl:variable name="table-border_">
4169
4278
 
4279
+
4170
4280
  </xsl:variable><xsl:variable name="table-border" select="normalize-space($table-border_)"/><xsl:attribute-set name="table-container-style">
4171
4281
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
4172
4282
  <xsl:attribute name="margin-right">0mm</xsl:attribute>
@@ -4191,6 +4301,7 @@
4191
4301
 
4192
4302
 
4193
4303
 
4304
+
4194
4305
 
4195
4306
 
4196
4307
 
@@ -4219,6 +4330,7 @@
4219
4330
 
4220
4331
 
4221
4332
 
4333
+
4222
4334
 
4223
4335
 
4224
4336
  </xsl:attribute-set><xsl:attribute-set name="table-name-style">
@@ -4227,6 +4339,7 @@
4227
4339
 
4228
4340
 
4229
4341
 
4342
+
4230
4343
 
4231
4344
 
4232
4345
 
@@ -4271,6 +4384,7 @@
4271
4384
  <xsl:attribute name="font-weight">bold</xsl:attribute>
4272
4385
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
4273
4386
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
4387
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
4274
4388
  <xsl:attribute name="display-align">center</xsl:attribute>
4275
4389
 
4276
4390
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -4295,6 +4409,7 @@
4295
4409
  <xsl:attribute name="display-align">center</xsl:attribute>
4296
4410
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
4297
4411
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
4412
+ <xsl:attribute name="padding-right">1mm</xsl:attribute>
4298
4413
 
4299
4414
 
4300
4415
  <xsl:attribute name="border">solid 0pt white</xsl:attribute>
@@ -4310,6 +4425,7 @@
4310
4425
 
4311
4426
 
4312
4427
 
4428
+
4313
4429
  </xsl:attribute-set><xsl:attribute-set name="table-footer-cell-style">
4314
4430
  <xsl:attribute name="border">solid black 1pt</xsl:attribute>
4315
4431
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
@@ -4324,7 +4440,7 @@
4324
4440
 
4325
4441
 
4326
4442
 
4327
-
4443
+
4328
4444
 
4329
4445
 
4330
4446
 
@@ -4342,6 +4458,7 @@
4342
4458
 
4343
4459
 
4344
4460
 
4461
+
4345
4462
  </xsl:attribute-set><xsl:attribute-set name="table-fn-style">
4346
4463
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
4347
4464
 
@@ -4355,6 +4472,8 @@
4355
4472
 
4356
4473
 
4357
4474
 
4475
+
4476
+
4358
4477
  </xsl:attribute-set><xsl:attribute-set name="table-fn-number-style">
4359
4478
  <xsl:attribute name="font-size">80%</xsl:attribute>
4360
4479
  <xsl:attribute name="padding-right">5mm</xsl:attribute>
@@ -4373,6 +4492,7 @@
4373
4492
 
4374
4493
 
4375
4494
 
4495
+
4376
4496
  </xsl:attribute-set><xsl:attribute-set name="fn-container-body-style">
4377
4497
  <xsl:attribute name="text-indent">0</xsl:attribute>
4378
4498
  <xsl:attribute name="start-indent">0</xsl:attribute>
@@ -4392,7 +4512,8 @@
4392
4512
  </xsl:attribute-set><xsl:attribute-set name="dt-row-style">
4393
4513
 
4394
4514
 
4395
- </xsl:attribute-set><xsl:attribute-set name="dt-style">
4515
+ </xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
4516
+ </xsl:attribute-set><xsl:attribute-set name="dt-block-style">
4396
4517
  <xsl:attribute name="margin-top">6pt</xsl:attribute>
4397
4518
 
4398
4519
 
@@ -4407,6 +4528,29 @@
4407
4528
 
4408
4529
 
4409
4530
 
4531
+
4532
+ </xsl:attribute-set><xsl:attribute-set name="dl-name-style">
4533
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
4534
+ <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4535
+
4536
+
4537
+
4538
+
4539
+
4540
+
4541
+
4542
+
4543
+
4544
+
4545
+
4546
+
4547
+
4548
+
4549
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
4550
+
4551
+
4552
+ </xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
4553
+ <xsl:attribute name="padding-left">2mm</xsl:attribute>
4410
4554
  </xsl:attribute-set><xsl:attribute-set name="appendix-style">
4411
4555
 
4412
4556
 
@@ -4434,6 +4578,7 @@
4434
4578
 
4435
4579
 
4436
4580
 
4581
+
4437
4582
 
4438
4583
 
4439
4584
 
@@ -4500,6 +4645,8 @@
4500
4645
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
4501
4646
 
4502
4647
 
4648
+ </xsl:attribute-set><xsl:attribute-set name="termnote-p-style">
4649
+
4503
4650
  </xsl:attribute-set><xsl:attribute-set name="quote-style">
4504
4651
  <xsl:attribute name="margin-left">12mm</xsl:attribute>
4505
4652
  <xsl:attribute name="margin-right">12mm</xsl:attribute>
@@ -4544,6 +4691,7 @@
4544
4691
  <xsl:attribute name="text-align">left</xsl:attribute>
4545
4692
  <xsl:attribute name="margin-left">19mm</xsl:attribute>
4546
4693
  <xsl:attribute name="text-indent">-19mm</xsl:attribute>
4694
+
4547
4695
 
4548
4696
 
4549
4697
 
@@ -4588,6 +4736,7 @@
4588
4736
 
4589
4737
 
4590
4738
 
4739
+
4591
4740
  </xsl:attribute-set><xsl:attribute-set name="formula-stem-number-style">
4592
4741
  <xsl:attribute name="text-align">right</xsl:attribute>
4593
4742
 
@@ -4606,16 +4755,16 @@
4606
4755
  </xsl:attribute-set><xsl:attribute-set name="figure-pseudocode-p-style">
4607
4756
 
4608
4757
  </xsl:attribute-set><xsl:attribute-set name="image-graphic-style">
4758
+ <xsl:attribute name="width">100%</xsl:attribute>
4759
+ <xsl:attribute name="content-height">100%</xsl:attribute>
4760
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
4609
4761
 
4610
4762
 
4611
- <xsl:attribute name="width">100%</xsl:attribute>
4612
4763
  <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
4613
- <xsl:attribute name="scaling">uniform</xsl:attribute>
4614
4764
 
4615
4765
 
4616
4766
 
4617
-
4618
-
4767
+
4619
4768
  </xsl:attribute-set><xsl:attribute-set name="tt-style">
4620
4769
 
4621
4770
 
@@ -4694,6 +4843,25 @@
4694
4843
 
4695
4844
 
4696
4845
 
4846
+
4847
+ </xsl:attribute-set><xsl:attribute-set name="list-name-style">
4848
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
4849
+
4850
+
4851
+
4852
+
4853
+
4854
+
4855
+
4856
+
4857
+
4858
+
4859
+
4860
+
4861
+
4862
+ <xsl:attribute name="font-weight">bold</xsl:attribute>
4863
+
4864
+
4697
4865
  </xsl:attribute-set><xsl:attribute-set name="list-item-style">
4698
4866
 
4699
4867
 
@@ -4745,6 +4913,7 @@
4745
4913
 
4746
4914
 
4747
4915
 
4916
+
4748
4917
  </xsl:attribute-set><xsl:attribute-set name="fn-body-style">
4749
4918
  <xsl:attribute name="font-weight">normal</xsl:attribute>
4750
4919
  <xsl:attribute name="font-style">normal</xsl:attribute>
@@ -4773,6 +4942,7 @@
4773
4942
 
4774
4943
 
4775
4944
 
4945
+
4776
4946
  </xsl:attribute-set><xsl:attribute-set name="fn-body-num-style">
4777
4947
  <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
4778
4948
 
@@ -4796,6 +4966,7 @@
4796
4966
 
4797
4967
 
4798
4968
 
4969
+
4799
4970
  </xsl:attribute-set><xsl:attribute-set name="admonition-style">
4800
4971
 
4801
4972
 
@@ -4816,11 +4987,12 @@
4816
4987
 
4817
4988
 
4818
4989
 
4990
+
4819
4991
  </xsl:attribute-set><xsl:attribute-set name="admonition-container-style">
4992
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
4993
+ <xsl:attribute name="margin-right">0mm</xsl:attribute>
4820
4994
 
4821
4995
 
4822
- <xsl:attribute name="margin-left">0mm</xsl:attribute>
4823
- <xsl:attribute name="margin-right">0mm</xsl:attribute>
4824
4996
  <xsl:attribute name="padding">2mm</xsl:attribute>
4825
4997
  <xsl:attribute name="padding-top">3mm</xsl:attribute>
4826
4998
 
@@ -4832,6 +5004,7 @@
4832
5004
 
4833
5005
 
4834
5006
 
5007
+
4835
5008
  </xsl:attribute-set><xsl:attribute-set name="admonition-name-style">
4836
5009
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
4837
5010
 
@@ -4867,6 +5040,7 @@
4867
5040
 
4868
5041
 
4869
5042
 
5043
+
4870
5044
  </xsl:attribute-set><xsl:attribute-set name="bibitem-normative-style">
4871
5045
 
4872
5046
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
@@ -4907,6 +5081,7 @@
4907
5081
 
4908
5082
 
4909
5083
 
5084
+
4910
5085
  </xsl:attribute-set><xsl:attribute-set name="bibitem-non-normative-style">
4911
5086
 
4912
5087
 
@@ -4928,6 +5103,7 @@
4928
5103
 
4929
5104
 
4930
5105
 
5106
+
4931
5107
  </xsl:attribute-set><xsl:attribute-set name="bibitem-normative-list-body-style">
4932
5108
 
4933
5109
 
@@ -4956,6 +5132,7 @@
4956
5132
 
4957
5133
 
4958
5134
 
5135
+
4959
5136
  </xsl:attribute-set><xsl:attribute-set name="bibitem-note-fn-number-style">
4960
5137
  <xsl:attribute name="keep-with-next.within-line">always</xsl:attribute>
4961
5138
 
@@ -4977,6 +5154,7 @@
4977
5154
 
4978
5155
 
4979
5156
 
5157
+
4980
5158
  </xsl:attribute-set><xsl:attribute-set name="bibitem-note-fn-body-style">
4981
5159
  <xsl:attribute name="font-size">10pt</xsl:attribute>
4982
5160
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
@@ -4992,6 +5170,7 @@
4992
5170
 
4993
5171
 
4994
5172
 
5173
+
4995
5174
  </xsl:attribute-set><xsl:attribute-set name="references-non-normative-style">
4996
5175
 
4997
5176
  <xsl:attribute name="line-height">120%</xsl:attribute>
@@ -5114,13 +5293,13 @@
5114
5293
 
5115
5294
  </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:variable name="ace_tag">ace-tag_</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
5116
5295
  <xsl:variable name="nodes_preface_">
5117
- <xsl:for-each select="/*/*[local-name()='preface']/*">
5296
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5118
5297
  <node id="{@id}"/>
5119
5298
  </xsl:for-each>
5120
5299
  </xsl:variable>
5121
5300
  <xsl:variable name="nodes_preface" select="xalan:nodeset($nodes_preface_)"/>
5122
5301
 
5123
- <xsl:for-each select="/*/*[local-name()='preface']/*">
5302
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5124
5303
  <xsl:sort select="@displayorder" data-type="number"/>
5125
5304
 
5126
5305
  <!-- process Section's title -->
@@ -5186,7 +5365,7 @@
5186
5365
  </xsl:for-each>
5187
5366
  </figures>
5188
5367
  </xsl:template><xsl:template name="processPrefaceSectionsDefault">
5189
- <xsl:for-each select="/*/*[local-name()='preface']/*">
5368
+ <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]">
5190
5369
  <xsl:sort select="@displayorder" data-type="number"/>
5191
5370
  <xsl:apply-templates select="."/>
5192
5371
  </xsl:for-each>
@@ -5240,7 +5419,38 @@
5240
5419
  </xsl:template><xsl:template match="*[local-name()='br']">
5241
5420
  <xsl:value-of select="$linebreak"/>
5242
5421
  </xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
5243
- <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
5422
+ <xsl:param name="split_keep-within-line"/>
5423
+
5424
+ <!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
5425
+ <xsl:choose>
5426
+
5427
+ <xsl:when test="normalize-space($split_keep-within-line) = 'true'">
5428
+ <xsl:variable name="sep">_</xsl:variable>
5429
+ <xsl:variable name="items">
5430
+ <xsl:call-template name="split">
5431
+ <xsl:with-param name="pText" select="."/>
5432
+ <xsl:with-param name="sep" select="$sep"/>
5433
+ <xsl:with-param name="normalize-space">false</xsl:with-param>
5434
+ <xsl:with-param name="keep_sep">true</xsl:with-param>
5435
+ </xsl:call-template>
5436
+ </xsl:variable>
5437
+ <xsl:for-each select="xalan:nodeset($items)/item">
5438
+ <xsl:choose>
5439
+ <xsl:when test=". = $sep">
5440
+ <xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
5441
+ </xsl:when>
5442
+ <xsl:otherwise>
5443
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
5444
+ </xsl:otherwise>
5445
+ </xsl:choose>
5446
+ </xsl:for-each>
5447
+ </xsl:when>
5448
+
5449
+ <xsl:otherwise>
5450
+ <fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
5451
+ </xsl:otherwise>
5452
+
5453
+ </xsl:choose>
5244
5454
  </xsl:template><xsl:template match="*[local-name()='copyright-statement']">
5245
5455
  <fo:block xsl:use-attribute-sets="copyright-statement-style">
5246
5456
  <xsl:apply-templates/>
@@ -5342,9 +5552,14 @@
5342
5552
 
5343
5553
  <xsl:variable name="table">
5344
5554
 
5345
- <xsl:variable name="simple-table">
5346
- <xsl:call-template name="getSimpleTable"/>
5555
+ <xsl:variable name="simple-table">
5556
+ <xsl:call-template name="getSimpleTable">
5557
+ <xsl:with-param name="id" select="@id"/>
5558
+ </xsl:call-template>
5347
5559
  </xsl:variable>
5560
+ <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
5561
+
5562
+ <!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
5348
5563
 
5349
5564
 
5350
5565
  <!-- Display table's name before table as standalone block -->
@@ -5367,7 +5582,23 @@
5367
5582
  </xsl:call-template>
5368
5583
  </xsl:if>
5369
5584
  </xsl:variable>
5370
- <!-- DEBUG colwidths=<xsl:copy-of select="$colwidths"/> -->
5585
+ <!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
5586
+
5587
+ <!-- DEBUG -->
5588
+ <xsl:if test="$table_if_debug = 'true'">
5589
+ <fo:block font-size="60%">
5590
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
5591
+ </fo:block>
5592
+ </xsl:if>
5593
+
5594
+
5595
+ <!-- <xsl:copy-of select="$colwidths"/> -->
5596
+
5597
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
5598
+ DEBUG
5599
+ colwidths=<xsl:copy-of select="$colwidths"/>
5600
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
5601
+
5371
5602
 
5372
5603
 
5373
5604
  <xsl:variable name="margin-side">
@@ -5397,6 +5628,8 @@
5397
5628
 
5398
5629
 
5399
5630
 
5631
+
5632
+
5400
5633
 
5401
5634
 
5402
5635
 
@@ -5443,12 +5676,22 @@
5443
5676
 
5444
5677
 
5445
5678
 
5679
+
5680
+
5446
5681
  </xsl:element>
5447
5682
  </xsl:variable>
5448
5683
 
5684
+ <xsl:if test="$isGenerateTableIF = 'true'">
5685
+ <!-- to determine start of table -->
5686
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
5687
+ </xsl:if>
5449
5688
 
5450
5689
  <fo:table id="{@id}">
5451
5690
 
5691
+ <xsl:if test="$isGenerateTableIF = 'true'">
5692
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
5693
+ </xsl:if>
5694
+
5452
5695
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
5453
5696
  <xsl:attribute name="{local-name()}">
5454
5697
  <xsl:value-of select="."/>
@@ -5462,24 +5705,47 @@
5462
5705
 
5463
5706
 
5464
5707
  <xsl:choose>
5465
- <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
5466
- <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
5467
- <fo:table-column column-width="{@width}"/>
5468
- </xsl:for-each>
5708
+ <xsl:when test="$isGenerateTableIF = 'true'">
5709
+ <!-- generate IF for table widths -->
5710
+ <!-- example:
5711
+ <tr>
5712
+ <td valign="top" align="left" id="tab-symdu_1_1">
5713
+ <p>Symbol</p>
5714
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
5715
+ </td>
5716
+ <td valign="top" align="left" id="tab-symdu_1_2">
5717
+ <p>Description</p>
5718
+ <word id="tab-symdu_1_2_word_1">Description</word>
5719
+ </td>
5720
+ </tr>
5721
+ -->
5722
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
5723
+
5469
5724
  </xsl:when>
5470
5725
  <xsl:otherwise>
5471
- <xsl:call-template name="insertTableColumnWidth">
5472
- <xsl:with-param name="colwidths" select="$colwidths"/>
5473
- </xsl:call-template>
5474
- </xsl:otherwise>
5475
- </xsl:choose>
5476
5726
 
5477
- <xsl:choose>
5478
- <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
5479
- <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
5480
- </xsl:when>
5481
- <xsl:otherwise>
5482
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
5727
+ <xsl:choose>
5728
+ <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
5729
+ <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
5730
+ <fo:table-column column-width="{@width}"/>
5731
+ </xsl:for-each>
5732
+ </xsl:when>
5733
+ <xsl:otherwise>
5734
+ <xsl:call-template name="insertTableColumnWidth">
5735
+ <xsl:with-param name="colwidths" select="$colwidths"/>
5736
+ </xsl:call-template>
5737
+ </xsl:otherwise>
5738
+ </xsl:choose>
5739
+
5740
+ <xsl:choose>
5741
+ <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
5742
+ <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
5743
+ </xsl:when>
5744
+ <xsl:otherwise>
5745
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
5746
+ </xsl:otherwise>
5747
+ </xsl:choose>
5748
+
5483
5749
  </xsl:otherwise>
5484
5750
  </xsl:choose>
5485
5751
 
@@ -5554,30 +5820,36 @@
5554
5820
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
5555
5821
  <xsl:param name="continued"/>
5556
5822
  <xsl:if test="normalize-space() != ''">
5557
- <fo:block xsl:use-attribute-sets="table-name-style">
5558
-
5559
-
5560
- <xsl:if test="not(*[local-name()='tab'])"> <!-- table without number -->
5561
- <xsl:attribute name="margin-top">0pt</xsl:attribute>
5562
- </xsl:if>
5563
- <xsl:if test="not(../preceding-sibling::*) and ancestor::node()[@orientation]">
5564
- <xsl:attribute name="margin-top">0pt</xsl:attribute>
5565
- </xsl:if>
5566
-
5567
-
5568
-
5823
+
5824
+
5569
5825
 
5570
- <xsl:choose>
5571
- <xsl:when test="$continued = 'true'">
5826
+ <fo:block xsl:use-attribute-sets="table-name-style">
5827
+
5572
5828
 
5573
- </xsl:when>
5574
- <xsl:otherwise>
5575
- <xsl:apply-templates/>
5576
- </xsl:otherwise>
5577
- </xsl:choose>
5578
-
5829
+ <xsl:if test="not(*[local-name()='tab'])"> <!-- table without number -->
5830
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
5831
+ </xsl:if>
5832
+ <xsl:if test="not(../preceding-sibling::*) and ancestor::node()[@orientation]">
5833
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
5834
+ </xsl:if>
5835
+
5836
+
5837
+
5838
+
5839
+ <xsl:choose>
5840
+ <xsl:when test="$continued = 'true'">
5841
+
5842
+ </xsl:when>
5843
+ <xsl:otherwise>
5844
+ <xsl:apply-templates/>
5845
+ </xsl:otherwise>
5846
+ </xsl:choose>
5847
+
5848
+
5849
+ </fo:block>
5850
+
5579
5851
 
5580
- </fo:block>
5852
+
5581
5853
  </xsl:if>
5582
5854
  </xsl:template><xsl:template name="calculate-columns-numbers">
5583
5855
  <xsl:param name="table-row"/>
@@ -5586,11 +5858,22 @@
5586
5858
  <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
5587
5859
  <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
5588
5860
  </xsl:template><xsl:template name="calculate-column-widths">
5861
+ <xsl:param name="table"/>
5862
+ <xsl:param name="cols-count"/>
5863
+
5864
+ <xsl:call-template name="calculate-column-widths-proportional">
5865
+ <xsl:with-param name="cols-count" select="$cols-count"/>
5866
+ <xsl:with-param name="table" select="$table"/>
5867
+ </xsl:call-template>
5868
+
5869
+ </xsl:template><xsl:template name="calculate-column-widths-proportional">
5589
5870
  <xsl:param name="table"/>
5590
5871
  <xsl:param name="cols-count"/>
5591
5872
  <xsl:param name="curr-col" select="1"/>
5592
5873
  <xsl:param name="width" select="0"/>
5593
5874
 
5875
+ <!-- table=<xsl:copy-of select="$table"/> -->
5876
+
5594
5877
  <xsl:if test="$curr-col &lt;= $cols-count">
5595
5878
  <xsl:variable name="widths">
5596
5879
  <xsl:choose>
@@ -5628,10 +5911,15 @@
5628
5911
  </xsl:for-each>
5629
5912
  </xsl:when>
5630
5913
  <xsl:otherwise>
5631
- <xsl:for-each select="xalan:nodeset($table)/*/tr">
5914
+ <!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
5915
+
5916
+ <!-- <table><xsl:copy-of select="$table"/></table>
5917
+ -->
5918
+ <xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
5632
5919
  <xsl:variable name="td_text">
5633
5920
  <xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
5634
5921
  </xsl:variable>
5922
+ <!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
5635
5923
  <xsl:variable name="words">
5636
5924
  <xsl:variable name="string_with_added_zerospaces">
5637
5925
  <xsl:call-template name="add-zero-spaces-java">
@@ -5646,6 +5934,7 @@
5646
5934
  <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
5647
5935
  </xsl:call-template>
5648
5936
  </xsl:variable>
5937
+ <!-- words=<xsl:copy-of select="$words"/> -->
5649
5938
  <xsl:variable name="max_length">
5650
5939
  <xsl:call-template name="max_length">
5651
5940
  <xsl:with-param name="words" select="xalan:nodeset($words)"/>
@@ -5670,6 +5959,8 @@
5670
5959
  </xsl:choose>
5671
5960
  </xsl:variable>
5672
5961
 
5962
+ <!-- widths=<xsl:copy-of select="$widths"/> -->
5963
+
5673
5964
  <column>
5674
5965
  <xsl:for-each select="xalan:nodeset($widths)//width">
5675
5966
  <xsl:sort select="." data-type="number" order="descending"/>
@@ -5678,34 +5969,272 @@
5678
5969
  </xsl:if>
5679
5970
  </xsl:for-each>
5680
5971
  </column>
5681
- <xsl:call-template name="calculate-column-widths">
5972
+ <xsl:call-template name="calculate-column-widths-proportional">
5682
5973
  <xsl:with-param name="cols-count" select="$cols-count"/>
5683
5974
  <xsl:with-param name="curr-col" select="$curr-col +1"/>
5684
5975
  <xsl:with-param name="table" select="$table"/>
5685
5976
  </xsl:call-template>
5686
5977
  </xsl:if>
5687
- </xsl:template><xsl:template match="*[@keep-together.within-line]/text()" priority="2" mode="td_text">
5978
+ </xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
5688
5979
  <!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
5689
5980
  <xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
5690
5981
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
5982
+
5983
+ <!-- if all capitals english letters or digits -->
5984
+ <xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
5985
+ <xsl:call-template name="repeat">
5986
+ <xsl:with-param name="char" select="'X'"/>
5987
+ <xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
5988
+ </xsl:call-template>
5989
+ </xsl:if>
5691
5990
  </xsl:template><xsl:template match="text()" mode="td_text">
5692
5991
  <xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
5693
5992
  </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
5694
5993
  <xsl:value-of select="*[local-name()='origin']/@citeas"/>
5695
5994
  </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
5696
5995
  <xsl:value-of select="@target"/>
5697
- </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
5698
- <xsl:variable name="mathml">
5699
- <xsl:for-each select="*">
5700
- <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
5701
- <xsl:copy-of select="."/>
5702
- </xsl:if>
5703
- </xsl:for-each>
5704
- </xsl:variable>
5996
+ </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
5997
+ <xsl:if test="$isGenerateTableIF = 'false'">
5998
+ <xsl:variable name="mathml_">
5999
+ <xsl:for-each select="*">
6000
+ <xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
6001
+ <xsl:copy-of select="."/>
6002
+ </xsl:if>
6003
+ </xsl:for-each>
6004
+ </xsl:variable>
6005
+ <xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
6006
+
6007
+ <xsl:variable name="math_text">
6008
+ <xsl:value-of select="normalize-space($mathml)"/>
6009
+ <xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
6010
+ <xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
6011
+ </xsl:variable>
6012
+ <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
6013
+ </xsl:if>
6014
+ </xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
6015
+ <xsl:param name="parent_table_page-width"/> <!-- for nested tables, in re-calculate step -->
5705
6016
 
5706
- <xsl:variable name="math_text" select="normalize-space(xalan:nodeset($mathml))"/>
5707
- <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
5708
- </xsl:template><xsl:template match="*[local-name()='thead']">
6017
+ <!-- via intermediate format -->
6018
+
6019
+ <!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
6020
+
6021
+ <!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
6022
+
6023
+ <!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
6024
+
6025
+ <!-- get current table id -->
6026
+ <xsl:variable name="table_id" select="@id"/>
6027
+ <!-- find table by id in the file 'table_widths' -->
6028
+ <!-- <xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
6029
+ <xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/> -->
6030
+
6031
+ <!-- table='<xsl:copy-of select="$table"/>' -->
6032
+ <!-- table_id='<xsl:value-of select="$table_id"/>\ -->
6033
+ <!-- table-if='<xsl:copy-of select="$table-if"/>' -->
6034
+ <!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
6035
+
6036
+ <xsl:variable name="table_with_cell_widths_">
6037
+ <xsl:apply-templates select="." mode="determine_cell_widths-if"/> <!-- read column's width from IF -->
6038
+ </xsl:variable>
6039
+ <xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
6040
+
6041
+ <!-- <xsl:if test="$table_if_debug = 'true'">
6042
+ <xsl:copy-of select="$table_with_cell_widths"/>
6043
+ </xsl:if> -->
6044
+
6045
+
6046
+ <!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
6047
+
6048
+ <xsl:variable name="column_widths_">
6049
+ <!-- iteration of columns -->
6050
+ <xsl:for-each select="$table_with_cell_widths//tr[1]/td">
6051
+ <xsl:variable name="pos" select="position()"/>
6052
+ <column>
6053
+ <xsl:attribute name="width_max">
6054
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
6055
+ <xsl:sort select="." data-type="number" order="descending"/>
6056
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
6057
+ </xsl:for-each>
6058
+ </xsl:attribute>
6059
+ <xsl:attribute name="width_min">
6060
+ <xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
6061
+ <xsl:sort select="." data-type="number" order="descending"/>
6062
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
6063
+ </xsl:for-each>
6064
+ </xsl:attribute>
6065
+ </column>
6066
+ </xsl:for-each>
6067
+ </xsl:variable>
6068
+ <xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
6069
+
6070
+ <!-- <column_widths>
6071
+ <xsl:copy-of select="$column_widths"/>
6072
+ </column_widths> -->
6073
+
6074
+ <!-- These in turn, are used to find the minimum and maximum width for the table. -->
6075
+ <xsl:variable name="table_widths_">
6076
+ <table>
6077
+ <xsl:attribute name="width_max">
6078
+ <xsl:value-of select="sum($column_widths/column/@width_max)"/>
6079
+ </xsl:attribute>
6080
+ <xsl:attribute name="width_min">
6081
+ <xsl:value-of select="sum($column_widths/column/@width_min)"/>
6082
+ </xsl:attribute>
6083
+ </table>
6084
+ </xsl:variable>
6085
+ <xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
6086
+
6087
+ <xsl:variable name="page_width">
6088
+ <xsl:choose>
6089
+ <xsl:when test="$parent_table_page-width != ''">
6090
+ <xsl:value-of select="$parent_table_page-width"/>
6091
+ </xsl:when>
6092
+ <xsl:otherwise>
6093
+ <xsl:value-of select="@page-width"/>
6094
+ </xsl:otherwise>
6095
+ </xsl:choose>
6096
+ </xsl:variable>
6097
+
6098
+ <xsl:if test="$table_if_debug = 'true'">
6099
+ <table_width>
6100
+ <xsl:copy-of select="$table_widths"/>
6101
+ </table_width>
6102
+ <debug>$page_width=<xsl:value-of select="$page_width"/></debug>
6103
+ </xsl:if>
6104
+
6105
+
6106
+ <!-- There are three cases: -->
6107
+ <xsl:choose>
6108
+ <!-- 1. The minimum table width is equal to or wider than the available space -->
6109
+ <xsl:when test="$table_widths/table/@width_min &gt;= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
6110
+ <!-- call old algorithm -->
6111
+ <case1/>
6112
+ <!-- <xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
6113
+ <xsl:call-template name="calculate-column-widths-proportional">
6114
+ <xsl:with-param name="cols-count" select="$cols-count"/>
6115
+ <xsl:with-param name="table" select="$table"/>
6116
+ </xsl:call-template> -->
6117
+ </xsl:when>
6118
+ <!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
6119
+ <xsl:when test="$table_widths/table/@width_max &lt;= $page_width">
6120
+ <case2/>
6121
+ <autolayout/>
6122
+ <xsl:for-each select="$column_widths/column/@width_max">
6123
+ <column divider="100"><xsl:value-of select="."/></column>
6124
+ </xsl:for-each>
6125
+ </xsl:when>
6126
+ <!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
6127
+ In this case, find the difference between the available space and the minimum table width, lets call it W.
6128
+ Lets also call D the difference between maximum and minimum width of the table.
6129
+ For each column, let d be the difference between maximum and minimum width of that column.
6130
+ Now set the column's width to the minimum width plus d times W over D.
6131
+ This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
6132
+ <xsl:when test="($table_widths/table/@width_max &gt; $page_width and $table_widths/table/@width_min &lt; $page_width) or ($table_widths/table/@width_min &gt;= $page_width)">
6133
+ <!-- difference between the available space and the minimum table width -->
6134
+ <xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
6135
+ <W><xsl:value-of select="$W"/></W>
6136
+ <!-- difference between maximum and minimum width of the table -->
6137
+ <xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
6138
+ <D><xsl:value-of select="$D"/></D>
6139
+ <case3/>
6140
+ <autolayout/>
6141
+ <xsl:if test="$table_widths/table/@width_min &gt;= $page_width">
6142
+ <split_keep-within-line>true</split_keep-within-line>
6143
+ </xsl:if>
6144
+ <xsl:for-each select="$column_widths/column">
6145
+ <!-- difference between maximum and minimum width of that column. -->
6146
+ <xsl:variable name="d" select="@width_max - @width_min"/>
6147
+ <d><xsl:value-of select="$d"/></d>
6148
+ <width_min><xsl:value-of select="@width_min"/></width_min>
6149
+ <e><xsl:value-of select="$d * $W div $D"/></e>
6150
+ <!-- set the column's width to the minimum width plus d times W over D. -->
6151
+ <column divider="100">
6152
+ <xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
6153
+ </column>
6154
+ </xsl:for-each>
6155
+
6156
+ </xsl:when>
6157
+ <xsl:otherwise><unknown_case/></xsl:otherwise>
6158
+ </xsl:choose>
6159
+
6160
+ </xsl:template><xsl:template name="get-calculated-column-widths-autolayout-algorithm">
6161
+
6162
+ <!-- if nested 'dl' or 'table' -->
6163
+ <xsl:variable name="parent_table_id" select="normalize-space(ancestor::*[local-name() = 'table' or local-name() = 'dl'][1]/@id)"/>
6164
+ <parent_table_id><xsl:value-of select="$parent_table_id"/></parent_table_id>
6165
+
6166
+ <parent_element><xsl:value-of select="local-name(..)"/></parent_element>
6167
+
6168
+ <xsl:variable name="parent_table_page-width_">
6169
+ <xsl:if test="$parent_table_id != ''">
6170
+ <!-- determine column number in the parent table -->
6171
+ <xsl:variable name="parent_table_column_number">
6172
+ <xsl:choose>
6173
+ <xsl:when test="parent::*[local-name() = 'dd']">2</xsl:when>
6174
+ <xsl:otherwise> <!-- parent is table -->
6175
+ <xsl:value-of select="count(ancestor::*[local-name() = 'td'][1]/preceding-sibling::*[local-name() = 'td']) + 1"/>
6176
+ </xsl:otherwise>
6177
+ </xsl:choose>
6178
+ </xsl:variable>
6179
+ <!-- find table by id in the file 'table_widths' and get all Nth `<column>...</column> -->
6180
+ <xsl:value-of select="$table_widths_from_if_calculated//table[@id = $parent_table_id]/column[number($parent_table_column_number)]"/>
6181
+ </xsl:if>
6182
+ </xsl:variable>
6183
+ <xsl:variable name="parent_table_page-width" select="normalize-space($parent_table_page-width_)"/>
6184
+
6185
+ <!-- get current table id -->
6186
+ <xsl:variable name="table_id" select="@id"/>
6187
+
6188
+ <xsl:choose>
6189
+ <xsl:when test="$parent_table_id = '' or $parent_table_page-width = ''">
6190
+ <!-- find table by id in the file 'table_widths' and get all `<column>...</column> -->
6191
+ <xsl:copy-of select="$table_widths_from_if_calculated//table[@id = $table_id]/node()"/>
6192
+ </xsl:when>
6193
+ <xsl:otherwise>
6194
+ <!-- recalculate columns width based on parent table width -->
6195
+ <xsl:for-each select="$table_widths_from_if//table[@id = $table_id]">
6196
+ <xsl:call-template name="calculate-column-widths-autolayout-algorithm">
6197
+ <xsl:with-param name="parent_table_page-width" select="$parent_table_page-width"/> <!-- padding-left = 2mm = 50000-->
6198
+ </xsl:call-template>
6199
+ </xsl:for-each>
6200
+ </xsl:otherwise>
6201
+ </xsl:choose>
6202
+
6203
+ </xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
6204
+ <xsl:copy>
6205
+ <xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
6206
+ </xsl:copy>
6207
+ </xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
6208
+ <xsl:copy>
6209
+ <xsl:copy-of select="@*"/>
6210
+
6211
+ <!-- The maximum width is given by the widest line. -->
6212
+ <xsl:attribute name="width_max">
6213
+ <xsl:for-each select="p_len">
6214
+ <xsl:sort select="." data-type="number" order="descending"/>
6215
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
6216
+ </xsl:for-each>
6217
+ </xsl:attribute>
6218
+
6219
+ <!-- The minimum width is given by the widest text element (word, image, etc.) -->
6220
+ <xsl:variable name="width_min">
6221
+ <xsl:for-each select="word_len">
6222
+ <xsl:sort select="." data-type="number" order="descending"/>
6223
+ <xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
6224
+ </xsl:for-each>
6225
+ </xsl:variable>
6226
+ <xsl:attribute name="width_min">
6227
+ <xsl:value-of select="$width_min"/>
6228
+ </xsl:attribute>
6229
+
6230
+ <xsl:if test="$width_min = 0">
6231
+ <xsl:attribute name="width_min">1</xsl:attribute>
6232
+ </xsl:if>
6233
+
6234
+ <xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
6235
+
6236
+ </xsl:copy>
6237
+ </xsl:template><xsl:template match="*[local-name()='thead']">
5709
6238
  <xsl:param name="cols-count"/>
5710
6239
  <fo:table-header>
5711
6240
 
@@ -5718,12 +6247,18 @@
5718
6247
  <fo:table-row>
5719
6248
  <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black">
5720
6249
 
5721
- <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
5722
- <xsl:with-param name="continued">true</xsl:with-param>
5723
- </xsl:apply-templates>
5724
6250
 
5725
6251
 
5726
6252
 
6253
+ <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
6254
+ <xsl:with-param name="continued">true</xsl:with-param>
6255
+ </xsl:apply-templates>
6256
+
6257
+
6258
+
6259
+
6260
+
6261
+
5727
6262
  </fo:table-cell>
5728
6263
  </fo:table-row>
5729
6264
  </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">
@@ -5789,6 +6324,7 @@
5789
6324
  </xsl:for-each>
5790
6325
  </xsl:when>
5791
6326
  <xsl:otherwise>
6327
+ <!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
5792
6328
  <xsl:call-template name="insertTableColumnWidth">
5793
6329
  <xsl:with-param name="colwidths" select="$colwidths"/>
5794
6330
  </xsl:call-template>
@@ -5833,7 +6369,10 @@
5833
6369
 
5834
6370
 
5835
6371
  <!-- fn processing -->
5836
- <xsl:call-template name="table_fn_display"/>
6372
+
6373
+ <xsl:call-template name="table_fn_display"/>
6374
+
6375
+
5837
6376
 
5838
6377
  <!-- for PAS display Notes after footnotes -->
5839
6378
 
@@ -5843,6 +6382,9 @@
5843
6382
  </fo:table-body>
5844
6383
 
5845
6384
  </fo:table>
6385
+
6386
+
6387
+
5846
6388
  </xsl:if>
5847
6389
  </xsl:template><xsl:template match="*[local-name()='tbody']">
5848
6390
 
@@ -5878,6 +6420,52 @@
5878
6420
 
5879
6421
  </fo:table-body>
5880
6422
 
6423
+ </xsl:template><xsl:template match="/" mode="process_table-if">
6424
+ <xsl:param name="table_or_dl">table</xsl:param>
6425
+ <xsl:apply-templates mode="process_table-if">
6426
+ <xsl:with-param name="table_or_dl" select="$table_or_dl"/>
6427
+ </xsl:apply-templates>
6428
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
6429
+ <xsl:param name="table_or_dl">table</xsl:param>
6430
+
6431
+ <fo:table-body>
6432
+ <xsl:for-each select="*[local-name() = 'tr']">
6433
+ <xsl:variable name="col_count" select="count(*)"/>
6434
+
6435
+ <!-- iteration for each tr/td -->
6436
+
6437
+ <xsl:choose>
6438
+ <xsl:when test="$table_or_dl = 'table'">
6439
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
6440
+ <fo:table-row number-columns-spanned="{$col_count}">
6441
+ <!-- <test_table><xsl:copy-of select="."/></test_table> -->
6442
+ <xsl:call-template name="td"/>
6443
+ </fo:table-row>
6444
+ </xsl:for-each>
6445
+ </xsl:when>
6446
+ <xsl:otherwise> <!-- $table_or_dl = 'dl' -->
6447
+ <xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
6448
+ <xsl:variable name="is_dt" select="position() = 1"/>
6449
+
6450
+ <xsl:for-each select="*">
6451
+ <!-- <test><xsl:copy-of select="."/></test> -->
6452
+ <fo:table-row number-columns-spanned="{$col_count}">
6453
+ <xsl:choose>
6454
+ <xsl:when test="$is_dt">
6455
+ <xsl:call-template name="insert_dt_cell"/>
6456
+ </xsl:when>
6457
+ <xsl:otherwise>
6458
+ <xsl:call-template name="insert_dd_cell"/>
6459
+ </xsl:otherwise>
6460
+ </xsl:choose>
6461
+ </fo:table-row>
6462
+ </xsl:for-each>
6463
+ </xsl:for-each>
6464
+ </xsl:otherwise>
6465
+ </xsl:choose>
6466
+
6467
+ </xsl:for-each>
6468
+ </fo:table-body>
5881
6469
  </xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
5882
6470
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
5883
6471
 
@@ -5885,6 +6473,9 @@
5885
6473
 
5886
6474
 
5887
6475
 
6476
+
6477
+
6478
+
5888
6479
 
5889
6480
 
5890
6481
  <xsl:call-template name="setTableRowAttributes"/>
@@ -5904,6 +6495,8 @@
5904
6495
 
5905
6496
 
5906
6497
 
6498
+
6499
+
5907
6500
  <xsl:call-template name="setTableRowAttributes"/>
5908
6501
  <xsl:apply-templates/>
5909
6502
  </fo:table-row>
@@ -5982,7 +6575,7 @@
5982
6575
  </xsl:choose>
5983
6576
  </xsl:attribute>
5984
6577
  </xsl:if>
5985
- </xsl:template><xsl:template match="*[local-name()='td']">
6578
+ </xsl:template><xsl:template match="*[local-name()='td']" name="td">
5986
6579
  <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
5987
6580
  <xsl:call-template name="setTextAlignment">
5988
6581
  <xsl:with-param name="default">left</xsl:with-param>
@@ -6014,6 +6607,8 @@
6014
6607
 
6015
6608
 
6016
6609
 
6610
+
6611
+
6017
6612
 
6018
6613
 
6019
6614
 
@@ -6027,8 +6622,18 @@
6027
6622
 
6028
6623
  <xsl:call-template name="setTableCellAttributes"/>
6029
6624
 
6625
+ <xsl:if test="$isGenerateTableIF = 'true'">
6626
+ <xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
6627
+ <xsl:attribute name="text-align">left</xsl:attribute>
6628
+ </xsl:if>
6629
+
6030
6630
  <fo:block>
6031
6631
 
6632
+ <xsl:if test="$isGenerateTableIF = 'true'">
6633
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
6634
+ </xsl:if>
6635
+
6636
+
6032
6637
 
6033
6638
  <xsl:if test="not(.//bipm:image)">
6034
6639
  <xsl:attribute name="line-stacking-strategy">font-height</xsl:attribute>
@@ -6041,6 +6646,9 @@
6041
6646
 
6042
6647
 
6043
6648
  <xsl:apply-templates/>
6649
+
6650
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
6651
+
6044
6652
  </fo:block>
6045
6653
  </fo:table-cell>
6046
6654
  </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
@@ -6094,7 +6702,11 @@
6094
6702
 
6095
6703
  <xsl:variable name="gen_id" select="generate-id(.)"/>
6096
6704
  <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
6097
- <xsl:variable name="reference" select="@reference"/>
6705
+ <xsl:variable name="reference_">
6706
+ <xsl:value-of select="@reference"/>
6707
+ <xsl:if test="normalize-space(@reference) = ''"><xsl:value-of select="$gen_id"/></xsl:if>
6708
+ </xsl:variable>
6709
+ <xsl:variable name="reference" select="normalize-space($reference_)"/>
6098
6710
  <!-- fn sequence number in document -->
6099
6711
  <xsl:variable name="current_fn_number">
6100
6712
  <xsl:choose>
@@ -6169,7 +6781,7 @@
6169
6781
  <xsl:copy-of select="node()"/>
6170
6782
  </fn>
6171
6783
  </xsl:for-each>
6172
- <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
6784
+ <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibliography']/*">
6173
6785
  <xsl:sort select="@displayorder" data-type="number"/>
6174
6786
  <xsl:for-each select=".//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | .//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure') and not(ancestor::*[local-name() = 'name'])])][generate-id(.)=generate-id(key('kfn',@reference)[1])]">
6175
6787
  <!-- copy unique fn -->
@@ -6254,9 +6866,9 @@
6254
6866
  <!-- current hierarchy is 'figure' element -->
6255
6867
  <xsl:variable name="following_dl_colwidths">
6256
6868
  <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
6257
- <xsl:variable name="html-table">
6258
- <xsl:variable name="doc_ns">
6259
- bipm
6869
+ <xsl:variable name="simple-table">
6870
+ <!-- <xsl:variable name="doc_ns">
6871
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
6260
6872
  </xsl:variable>
6261
6873
  <xsl:variable name="ns">
6262
6874
  <xsl:choose>
@@ -6267,7 +6879,7 @@
6267
6879
  <xsl:value-of select="substring-before(name(/*), '-')"/>
6268
6880
  </xsl:otherwise>
6269
6881
  </xsl:choose>
6270
- </xsl:variable>
6882
+ </xsl:variable> -->
6271
6883
 
6272
6884
  <xsl:for-each select="*[local-name() = 'dl'][1]">
6273
6885
  <tbody>
@@ -6278,7 +6890,7 @@
6278
6890
 
6279
6891
  <xsl:call-template name="calculate-column-widths">
6280
6892
  <xsl:with-param name="cols-count" select="2"/>
6281
- <xsl:with-param name="table" select="$html-table"/>
6893
+ <xsl:with-param name="table" select="$simple-table"/>
6282
6894
  </xsl:call-template>
6283
6895
 
6284
6896
  </xsl:if>
@@ -6458,12 +7070,31 @@
6458
7070
 
6459
7071
 
6460
7072
 
7073
+
7074
+ <xsl:if test="ancestor::*[local-name() = 'dd' or local-name() = 'td']">
7075
+ <xsl:attribute name="margin-top">0</xsl:attribute>
7076
+ </xsl:if>
7077
+
6461
7078
  <fo:block>
6462
7079
 
6463
7080
 
6464
7081
 
6465
7082
 
7083
+ <xsl:apply-templates select="*[local-name() = 'name']">
7084
+ <xsl:with-param name="process">true</xsl:with-param>
7085
+ </xsl:apply-templates>
7086
+
7087
+ <xsl:if test="$isGenerateTableIF = 'true'">
7088
+ <!-- to determine start of table -->
7089
+ <fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
7090
+ </xsl:if>
7091
+
6466
7092
  <fo:table width="95%" table-layout="fixed">
7093
+
7094
+ <xsl:if test="$isGenerateTableIF = 'true'">
7095
+ <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
7096
+ </xsl:if>
7097
+
6467
7098
 
6468
7099
  <xsl:choose>
6469
7100
  <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
@@ -6472,69 +7103,173 @@
6472
7103
 
6473
7104
  </xsl:when>
6474
7105
  </xsl:choose>
6475
- <!-- create virtual html table for dl/[dt and dd] -->
6476
- <xsl:variable name="html-table">
6477
- <xsl:variable name="doc_ns">
6478
- bipm
6479
- </xsl:variable>
6480
- <xsl:variable name="ns">
6481
- <xsl:choose>
6482
- <xsl:when test="normalize-space($doc_ns) != ''">
6483
- <xsl:value-of select="normalize-space($doc_ns)"/>
6484
- </xsl:when>
6485
- <xsl:otherwise>
6486
- <xsl:value-of select="substring-before(name(/*), '-')"/>
6487
- </xsl:otherwise>
6488
- </xsl:choose>
6489
- </xsl:variable>
6490
- <tbody>
6491
- <xsl:apply-templates mode="dl"/>
6492
- </tbody>
6493
- </xsl:variable>
6494
- <!-- DEBUG: html-table<xsl:copy-of select="$html-table"/> -->
6495
- <xsl:variable name="colwidths">
6496
- <xsl:call-template name="calculate-column-widths">
6497
- <xsl:with-param name="cols-count" select="2"/>
6498
- <xsl:with-param name="table" select="$html-table"/>
6499
- </xsl:call-template>
6500
- </xsl:variable>
6501
- <!-- DEBUG: colwidths=<xsl:copy-of select="$colwidths"/> -->
6502
- <xsl:variable name="maxlength_dt">
6503
- <xsl:call-template name="getMaxLength_dt"/>
6504
- </xsl:variable>
6505
- <xsl:variable name="isContainsKeepTogetherTag_">
6506
- false
6507
- </xsl:variable>
6508
- <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
6509
- <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
6510
- <xsl:call-template name="setColumnWidth_dl">
6511
- <xsl:with-param name="colwidths" select="$colwidths"/>
6512
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
6513
- <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
6514
- </xsl:call-template>
6515
7106
 
6516
- <fo:table-body>
6517
- <xsl:apply-templates>
6518
- <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
6519
- </xsl:apply-templates>
6520
- </fo:table-body>
7107
+
7108
+
7109
+ <xsl:choose>
7110
+ <xsl:when test="$isGenerateTableIF = 'true'">
7111
+ <!-- generate IF for table widths -->
7112
+ <!-- example:
7113
+ <tr>
7114
+ <td valign="top" align="left" id="tab-symdu_1_1">
7115
+ <p>Symbol</p>
7116
+ <word id="tab-symdu_1_1_word_1">Symbol</word>
7117
+ </td>
7118
+ <td valign="top" align="left" id="tab-symdu_1_2">
7119
+ <p>Description</p>
7120
+ <word id="tab-symdu_1_2_word_1">Description</word>
7121
+ </td>
7122
+ </tr>
7123
+ -->
7124
+
7125
+ <!-- create virtual html table for dl/[dt and dd] -->
7126
+ <xsl:variable name="simple-table">
7127
+
7128
+ <xsl:variable name="dl_table">
7129
+ <tbody>
7130
+ <xsl:apply-templates mode="dl_if">
7131
+ <xsl:with-param name="id" select="@id"/>
7132
+ </xsl:apply-templates>
7133
+ </tbody>
7134
+ </xsl:variable>
7135
+
7136
+ <!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
7137
+
7138
+ <!-- Step: replace <br/> to <p>...</p> -->
7139
+ <xsl:variable name="table_without_br">
7140
+ <xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
7141
+ </xsl:variable>
7142
+
7143
+ <!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
7144
+
7145
+ <!-- Step: add id to each cell -->
7146
+ <!-- add <word>...</word> for each word, image, math -->
7147
+ <xsl:variable name="simple-table-id">
7148
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
7149
+ <xsl:with-param name="id" select="@id"/>
7150
+ </xsl:apply-templates>
7151
+ </xsl:variable>
7152
+
7153
+ <!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
7154
+
7155
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
7156
+
7157
+ </xsl:variable>
7158
+
7159
+ <!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
7160
+
7161
+ <xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
7162
+ <xsl:with-param name="table_or_dl">dl</xsl:with-param>
7163
+ </xsl:apply-templates>
7164
+
7165
+ </xsl:when>
7166
+ <xsl:otherwise>
7167
+
7168
+ <xsl:variable name="simple-table">
7169
+
7170
+ <xsl:variable name="dl_table">
7171
+ <tbody>
7172
+ <xsl:apply-templates mode="dl">
7173
+ <xsl:with-param name="id" select="@id"/>
7174
+ </xsl:apply-templates>
7175
+ </tbody>
7176
+ </xsl:variable>
7177
+
7178
+ <xsl:copy-of select="$dl_table"/>
7179
+ </xsl:variable>
7180
+
7181
+ <xsl:variable name="colwidths">
7182
+ <xsl:call-template name="calculate-column-widths">
7183
+ <xsl:with-param name="cols-count" select="2"/>
7184
+ <xsl:with-param name="table" select="$simple-table"/>
7185
+ </xsl:call-template>
7186
+ </xsl:variable>
7187
+
7188
+ <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
7189
+ DEBUG
7190
+ colwidths=<xsl:copy-of select="$colwidths"/>
7191
+ <xsl:text disable-output-escaping="yes">- -&gt;</xsl:text> -->
7192
+
7193
+ <!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
7194
+
7195
+ <xsl:variable name="maxlength_dt">
7196
+ <xsl:call-template name="getMaxLength_dt"/>
7197
+ </xsl:variable>
7198
+
7199
+ <xsl:variable name="isContainsKeepTogetherTag_">
7200
+ false
7201
+ </xsl:variable>
7202
+ <xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
7203
+ <!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
7204
+
7205
+
7206
+ <xsl:call-template name="setColumnWidth_dl">
7207
+ <xsl:with-param name="colwidths" select="$colwidths"/>
7208
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
7209
+ <xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
7210
+ </xsl:call-template>
7211
+
7212
+ <fo:table-body>
7213
+
7214
+ <!-- DEBUG -->
7215
+ <xsl:if test="$table_if_debug = 'true'">
7216
+ <fo:table-row>
7217
+ <fo:table-cell number-columns-spanned="2" font-size="60%">
7218
+ <xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
7219
+ </fo:table-cell>
7220
+ </fo:table-row>
7221
+ </xsl:if>
7222
+
7223
+ <xsl:apply-templates>
7224
+ <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
7225
+ <xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
7226
+ </xsl:apply-templates>
7227
+
7228
+ </fo:table-body>
7229
+ </xsl:otherwise>
7230
+ </xsl:choose>
6521
7231
  </fo:table>
6522
7232
  </fo:block>
6523
7233
  </fo:block>
6524
7234
  </xsl:if> <!-- END: a few components -->
6525
7235
  </fo:block-container>
6526
7236
  </fo:block-container>
7237
+
7238
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- process nested 'dl' -->
7239
+ <xsl:apply-templates select="*[local-name() = 'dd']/*[local-name() = 'dl']"/>
7240
+ </xsl:if>
7241
+
7242
+ </xsl:template><xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
7243
+ <xsl:param name="process">false</xsl:param>
7244
+ <xsl:if test="$process = 'true'">
7245
+ <fo:block xsl:use-attribute-sets="dl-name-style">
7246
+ <xsl:apply-templates/>
7247
+ </fo:block>
7248
+ </xsl:if>
6527
7249
  </xsl:template><xsl:template name="setColumnWidth_dl">
6528
7250
  <xsl:param name="colwidths"/>
6529
7251
  <xsl:param name="maxlength_dt"/>
6530
7252
  <xsl:param name="isContainsKeepTogetherTag"/>
7253
+
7254
+ <!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
7255
+
6531
7256
  <xsl:choose>
7257
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
7258
+ <xsl:call-template name="insertTableColumnWidth">
7259
+ <xsl:with-param name="colwidths" select="$colwidths"/>
7260
+ </xsl:call-template>
7261
+ </xsl:when>
6532
7262
  <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
6533
7263
  <fo:table-column column-width="50%"/>
6534
7264
  <fo:table-column column-width="50%"/>
6535
7265
  </xsl:when>
6536
7266
  <xsl:otherwise>
6537
7267
  <xsl:choose>
7268
+ <xsl:when test="xalan:nodeset($colwidths)/autolayout">
7269
+ <xsl:call-template name="insertTableColumnWidth">
7270
+ <xsl:with-param name="colwidths" select="$colwidths"/>
7271
+ </xsl:call-template>
7272
+ </xsl:when>
6538
7273
  <xsl:when test="$isContainsKeepTogetherTag">
6539
7274
  <xsl:call-template name="insertTableColumnWidth">
6540
7275
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -6579,13 +7314,19 @@
6579
7314
  </xsl:choose>
6580
7315
  </xsl:template><xsl:template name="insertTableColumnWidth">
6581
7316
  <xsl:param name="colwidths"/>
7317
+
6582
7318
  <xsl:for-each select="xalan:nodeset($colwidths)//column">
6583
7319
  <xsl:choose>
6584
7320
  <xsl:when test=". = 1 or . = 0">
6585
7321
  <fo:table-column column-width="proportional-column-width(2)"/>
6586
7322
  </xsl:when>
6587
7323
  <xsl:otherwise>
6588
- <fo:table-column column-width="proportional-column-width({.})"/>
7324
+ <!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
7325
+ <xsl:variable name="divider">
7326
+ <xsl:value-of select="@divider"/>
7327
+ <xsl:if test="not(@divider)">1</xsl:if>
7328
+ </xsl:variable>
7329
+ <fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
6589
7330
  </xsl:otherwise>
6590
7331
  </xsl:choose>
6591
7332
  </xsl:for-each>
@@ -6647,11 +7388,19 @@
6647
7388
  </fo:table-cell>
6648
7389
  </fo:table-row>
6649
7390
  </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
7391
+ <xsl:param name="id"/>
7392
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
6650
7393
  <tr>
6651
7394
  <td>
7395
+ <xsl:attribute name="id">
7396
+ <xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
7397
+ </xsl:attribute>
6652
7398
  <xsl:apply-templates/>
6653
7399
  </td>
6654
7400
  <td>
7401
+ <xsl:attribute name="id">
7402
+ <xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
7403
+ </xsl:attribute>
6655
7404
 
6656
7405
  <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
6657
7406
  <xsl:with-param name="process">true</xsl:with-param>
@@ -6662,50 +7411,134 @@
6662
7411
 
6663
7412
  </xsl:template><xsl:template match="*[local-name()='dt']">
6664
7413
  <xsl:param name="key_iso"/>
7414
+ <xsl:param name="split_keep-within-line"/>
6665
7415
 
6666
7416
  <fo:table-row xsl:use-attribute-sets="dt-row-style">
6667
- <fo:table-cell>
7417
+ <xsl:call-template name="insert_dt_cell">
7418
+ <xsl:with-param name="key_iso" select="$key_iso"/>
7419
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7420
+ </xsl:call-template>
7421
+ <xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
7422
+ <xsl:call-template name="insert_dd_cell">
7423
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7424
+ </xsl:call-template>
7425
+ </xsl:for-each>
7426
+ </fo:table-row>
7427
+ </xsl:template><xsl:template name="insert_dt_cell">
7428
+ <xsl:param name="key_iso"/>
7429
+ <xsl:param name="split_keep-within-line"/>
7430
+ <fo:table-cell xsl:use-attribute-sets="dt-cell-style">
7431
+
7432
+ <xsl:if test="$isGenerateTableIF = 'true'">
7433
+ <!-- border is mandatory, to calculate real width -->
7434
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
7435
+ <xsl:attribute name="text-align">left</xsl:attribute>
7436
+ </xsl:if>
7437
+
7438
+
7439
+ <fo:block xsl:use-attribute-sets="dt-block-style">
7440
+ <xsl:copy-of select="@id"/>
7441
+
7442
+ <xsl:if test="normalize-space($key_iso) = 'true'">
7443
+ <xsl:attribute name="margin-top">0</xsl:attribute>
7444
+ </xsl:if>
7445
+
7446
+
7447
+
7448
+ <xsl:apply-templates>
7449
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7450
+ </xsl:apply-templates>
7451
+
7452
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
7453
+
7454
+ </fo:block>
7455
+ </fo:table-cell>
7456
+ </xsl:template><xsl:template name="insert_dd_cell">
7457
+ <xsl:param name="split_keep-within-line"/>
7458
+ <fo:table-cell xsl:use-attribute-sets="dd-cell-style">
7459
+
7460
+ <xsl:if test="$isGenerateTableIF = 'true'">
7461
+ <!-- border is mandatory, to calculate real width -->
7462
+ <xsl:attribute name="border">0.1pt solid black</xsl:attribute>
7463
+ </xsl:if>
7464
+
7465
+ <fo:block>
7466
+
7467
+ <xsl:if test="$isGenerateTableIF = 'true'">
7468
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
7469
+ </xsl:if>
7470
+
6668
7471
 
6669
- <fo:block xsl:use-attribute-sets="dt-style">
6670
- <xsl:copy-of select="@id"/>
6671
-
6672
- <xsl:if test="normalize-space($key_iso) = 'true'">
6673
- <xsl:attribute name="margin-top">0</xsl:attribute>
6674
- </xsl:if>
6675
-
6676
-
6677
-
6678
- <xsl:apply-templates/>
6679
- </fo:block>
6680
- </fo:table-cell>
6681
- <fo:table-cell>
6682
- <fo:block>
6683
-
6684
7472
 
6685
- <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
6686
- <xsl:with-param name="process">true</xsl:with-param>
6687
- </xsl:apply-templates>
6688
- </fo:block>
6689
- </fo:table-cell>
6690
- </fo:table-row>
7473
+ <xsl:choose>
7474
+ <xsl:when test="$isGenerateTableIF = 'true'">
7475
+ <xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
7476
+ <xsl:with-param name="process">true</xsl:with-param>
7477
+ </xsl:apply-templates>
7478
+ </xsl:when>
7479
+ <xsl:otherwise>
7480
+ <xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
7481
+ <xsl:with-param name="process">true</xsl:with-param>
7482
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7483
+ </xsl:apply-templates>
7484
+ </xsl:otherwise>
7485
+
7486
+ </xsl:choose>
7487
+
7488
+ <xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
7489
+
7490
+ </fo:block>
7491
+ </fo:table-cell>
6691
7492
  </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
6692
7493
  <xsl:apply-templates/>
6693
7494
  </xsl:template><xsl:template match="*[local-name()='dd']">
6694
7495
  <xsl:param name="process">false</xsl:param>
7496
+ <xsl:param name="split_keep-within-line"/>
6695
7497
  <xsl:if test="$process = 'true'">
6696
7498
  <xsl:apply-templates select="@language"/>
6697
- <xsl:apply-templates/>
7499
+ <xsl:apply-templates>
7500
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7501
+ </xsl:apply-templates>
6698
7502
  </xsl:if>
6699
7503
  </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
6700
7504
  <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
6701
- </xsl:template><xsl:template match="*[local-name()='em']">
7505
+ </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
7506
+ <xsl:param name="id"/>
7507
+ <xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
7508
+ <tr>
7509
+ <td>
7510
+ <xsl:copy-of select="node()"/>
7511
+ </td>
7512
+ <td>
7513
+
7514
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()[not(local-name() = 'dl')]"/>
7515
+
7516
+ <!-- get paragraphs from nested 'dl' -->
7517
+ <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'dl']" mode="dl_if_nested"/>
7518
+
7519
+
7520
+ </td>
7521
+ </tr>
7522
+
7523
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='dl']" mode="dl_if_nested">
7524
+ <xsl:for-each select="*[local-name() = 'dt']">
7525
+ <p>
7526
+ <xsl:copy-of select="node()"/>
7527
+ <xsl:text> </xsl:text>
7528
+ <xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/*[local-name() = 'p']/node()"/>
7529
+ </p>
7530
+ </xsl:for-each>
7531
+ </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if_nested"/><xsl:template match="*[local-name()='em']">
6702
7532
  <fo:inline font-style="italic">
6703
7533
  <xsl:apply-templates/>
6704
7534
  </fo:inline>
6705
7535
  </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
7536
+ <xsl:param name="split_keep-within-line"/>
6706
7537
  <fo:inline font-weight="bold">
6707
7538
 
6708
- <xsl:apply-templates/>
7539
+ <xsl:apply-templates>
7540
+ <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
7541
+ </xsl:apply-templates>
6709
7542
  </fo:inline>
6710
7543
  </xsl:template><xsl:template match="*[local-name()='padding']">
6711
7544
  <fo:inline padding-right="{@value}"> </fo:inline>
@@ -6726,7 +7559,7 @@
6726
7559
 
6727
7560
 
6728
7561
 
6729
-
7562
+ <!-- 10 -->
6730
7563
 
6731
7564
 
6732
7565
 
@@ -6906,6 +7739,10 @@
6906
7739
  <xsl:param name="text"/>
6907
7740
  <xsl:param name="separator" select="' '"/>
6908
7741
  <xsl:choose>
7742
+
7743
+ <xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
7744
+ <word><xsl:value-of select="normalize-space($text)"/></word>
7745
+ </xsl:when>
6909
7746
  <xsl:when test="not(contains($text, $separator))">
6910
7747
  <word>
6911
7748
  <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
@@ -6950,13 +7787,66 @@
6950
7787
  </xsl:when>
6951
7788
  <xsl:otherwise>
6952
7789
  <word>
6953
- <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
7790
+ <xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
7791
+ <xsl:choose>
7792
+ <xsl:when test="$isGenerateTableIF = 'true'">
7793
+ <xsl:value-of select="$word"/>
7794
+ </xsl:when>
7795
+ <xsl:otherwise>
7796
+ <xsl:value-of select="string-length($word)"/>
7797
+ </xsl:otherwise>
7798
+ </xsl:choose>
6954
7799
  </word>
6955
7800
  <xsl:call-template name="tokenize">
6956
7801
  <xsl:with-param name="text" select="substring-after($text, $separator)"/>
6957
7802
  </xsl:call-template>
6958
7803
  </xsl:otherwise>
6959
7804
  </xsl:choose>
7805
+ </xsl:template><xsl:template name="tokenize_with_tags">
7806
+ <xsl:param name="tags"/>
7807
+ <xsl:param name="text"/>
7808
+ <xsl:param name="separator" select="' '"/>
7809
+ <xsl:choose>
7810
+
7811
+ <xsl:when test="not(contains($text, $separator))">
7812
+ <word>
7813
+ <xsl:call-template name="enclose_text_in_tags">
7814
+ <xsl:with-param name="text" select="normalize-space($text)"/>
7815
+ <xsl:with-param name="tags" select="$tags"/>
7816
+ </xsl:call-template>
7817
+ </word>
7818
+ </xsl:when>
7819
+ <xsl:otherwise>
7820
+ <word>
7821
+ <xsl:call-template name="enclose_text_in_tags">
7822
+ <xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
7823
+ <xsl:with-param name="tags" select="$tags"/>
7824
+ </xsl:call-template>
7825
+ </word>
7826
+ <xsl:call-template name="tokenize_with_tags">
7827
+ <xsl:with-param name="text" select="substring-after($text, $separator)"/>
7828
+ </xsl:call-template>
7829
+ </xsl:otherwise>
7830
+ </xsl:choose>
7831
+ </xsl:template><xsl:template name="enclose_text_in_tags">
7832
+ <xsl:param name="text"/>
7833
+ <xsl:param name="tags"/>
7834
+ <xsl:param name="num">1</xsl:param> <!-- default (start) value -->
7835
+
7836
+ <xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
7837
+
7838
+ <xsl:choose>
7839
+ <xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
7840
+ <xsl:otherwise>
7841
+ <xsl:element name="{$tag_name}">
7842
+ <xsl:call-template name="enclose_text_in_tags">
7843
+ <xsl:with-param name="text" select="$text"/>
7844
+ <xsl:with-param name="tags" select="$tags"/>
7845
+ <xsl:with-param name="num" select="$num + 1"/>
7846
+ </xsl:call-template>
7847
+ </xsl:element>
7848
+ </xsl:otherwise>
7849
+ </xsl:choose>
6960
7850
  </xsl:template><xsl:template name="max_length">
6961
7851
  <xsl:param name="words"/>
6962
7852
  <xsl:for-each select="$words//word">
@@ -7057,12 +7947,19 @@
7057
7947
  </xsl:otherwise>
7058
7948
  </xsl:choose>
7059
7949
  </xsl:template><xsl:template name="getSimpleTable">
7950
+ <xsl:param name="id"/>
7951
+
7060
7952
  <xsl:variable name="simple-table">
7061
7953
 
7954
+ <!-- Step 0. replace <br/> to <p>...</p> -->
7955
+ <xsl:variable name="table_without_br">
7956
+ <xsl:apply-templates mode="table-without-br"/>
7957
+ </xsl:variable>
7958
+
7062
7959
  <!-- Step 1. colspan processing -->
7063
7960
  <xsl:variable name="simple-table-colspan">
7064
7961
  <tbody>
7065
- <xsl:apply-templates mode="simple-table-colspan"/>
7962
+ <xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
7066
7963
  </tbody>
7067
7964
  </xsl:variable>
7068
7965
 
@@ -7071,10 +7968,67 @@
7071
7968
  <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
7072
7969
  </xsl:variable>
7073
7970
 
7074
- <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>
7075
-
7971
+ <!-- Step 3: add id to each cell -->
7972
+ <!-- add <word>...</word> for each word, image, math -->
7973
+ <xsl:variable name="simple-table-id">
7974
+ <xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
7975
+ <xsl:with-param name="id" select="$id"/>
7976
+ </xsl:apply-templates>
7977
+ </xsl:variable>
7978
+
7979
+ <xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
7980
+
7076
7981
  </xsl:variable>
7077
7982
  <xsl:copy-of select="$simple-table"/>
7983
+ </xsl:template><xsl:template match="@*|node()" mode="table-without-br">
7984
+ <xsl:copy>
7985
+ <xsl:apply-templates select="@*|node()" mode="table-without-br"/>
7986
+ </xsl:copy>
7987
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
7988
+ <xsl:copy>
7989
+ <xsl:copy-of select="@*"/>
7990
+ <p>
7991
+ <xsl:copy-of select="node()"/>
7992
+ </p>
7993
+ </xsl:copy>
7994
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
7995
+ <xsl:copy>
7996
+ <xsl:copy-of select="@*"/>
7997
+ <xsl:for-each select="*[local-name()='br']">
7998
+ <xsl:variable name="current_id" select="generate-id()"/>
7999
+ <p>
8000
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
8001
+ <xsl:copy-of select="."/>
8002
+ </xsl:for-each>
8003
+ </p>
8004
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
8005
+ <p>
8006
+ <xsl:for-each select="following-sibling::node()">
8007
+ <xsl:copy-of select="."/>
8008
+ </xsl:for-each>
8009
+ </p>
8010
+ </xsl:if>
8011
+ </xsl:for-each>
8012
+ </xsl:copy>
8013
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
8014
+ <xsl:for-each select="*[local-name()='br']">
8015
+ <xsl:variable name="current_id" select="generate-id()"/>
8016
+ <p>
8017
+ <xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
8018
+ <xsl:copy-of select="."/>
8019
+ </xsl:for-each>
8020
+ </p>
8021
+ <xsl:if test="not(following-sibling::*[local-name() = 'br'])">
8022
+ <p>
8023
+ <xsl:for-each select="following-sibling::node()">
8024
+ <xsl:copy-of select="."/>
8025
+ </xsl:for-each>
8026
+ </p>
8027
+ </xsl:if>
8028
+ </xsl:for-each>
8029
+ </xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
8030
+ <xsl:variable name="text" select="translate(.,'&#9;&#10;&#13;','')"/>
8031
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
7078
8032
  </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
7079
8033
  <xsl:apply-templates mode="simple-table-colspan"/>
7080
8034
  </xsl:template><xsl:template match="*[local-name()='fn']" mode="simple-table-colspan"/><xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan">
@@ -7164,6 +8118,126 @@
7164
8118
  <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
7165
8119
  <xsl:with-param name="previousRow" select="$newRow"/>
7166
8120
  </xsl:apply-templates>
8121
+ </xsl:template><xsl:template match="/" mode="simple-table-id">
8122
+ <xsl:param name="id"/>
8123
+ <xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
8124
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
8125
+ <xsl:with-param name="id" select="$id_prefixed"/>
8126
+ </xsl:apply-templates>
8127
+ </xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
8128
+ <xsl:param name="id"/>
8129
+ <xsl:copy>
8130
+ <xsl:apply-templates select="@*|node()" mode="simple-table-id">
8131
+ <xsl:with-param name="id" select="$id"/>
8132
+ </xsl:apply-templates>
8133
+ </xsl:copy>
8134
+ </xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
8135
+ <xsl:param name="id"/>
8136
+ <xsl:copy>
8137
+ <xsl:copy-of select="@*"/>
8138
+ <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
8139
+ <xsl:apply-templates select="node()" mode="simple-table-id">
8140
+ <xsl:with-param name="id" select="$id"/>
8141
+ </xsl:apply-templates>
8142
+ </xsl:copy>
8143
+ </xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
8144
+ <xsl:param name="id"/>
8145
+ <xsl:copy>
8146
+ <xsl:copy-of select="@*"/>
8147
+ <xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
8148
+ <xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
8149
+ <xsl:attribute name="id">
8150
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
8151
+ </xsl:attribute>
8152
+
8153
+ <xsl:for-each select="*[local-name() = 'p']">
8154
+ <xsl:copy>
8155
+ <xsl:copy-of select="@*"/>
8156
+ <xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
8157
+ <xsl:attribute name="id">
8158
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
8159
+ </xsl:attribute>
8160
+
8161
+ <xsl:copy-of select="node()"/>
8162
+ </xsl:copy>
8163
+ </xsl:for-each>
8164
+
8165
+
8166
+ <xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
8167
+
8168
+ <xsl:variable name="td_text">
8169
+ <xsl:apply-templates select="." mode="td_text_with_formatting"/>
8170
+ </xsl:variable>
8171
+
8172
+ <!-- td_text='<xsl:copy-of select="$td_text"/>' -->
8173
+
8174
+ <xsl:variable name="words">
8175
+ <xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
8176
+ <word>
8177
+ <xsl:copy-of select="."/>
8178
+ </word>
8179
+ </xsl:for-each>
8180
+
8181
+ <xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
8182
+ <xsl:copy-of select="."/>
8183
+ </xsl:for-each>
8184
+
8185
+ </xsl:variable>
8186
+
8187
+ <xsl:for-each select="xalan:nodeset($words)/word">
8188
+ <xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
8189
+ <xsl:copy>
8190
+ <xsl:attribute name="id">
8191
+ <xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
8192
+ </xsl:attribute>
8193
+ <xsl:copy-of select="node()"/>
8194
+ </xsl:copy>
8195
+ </xsl:for-each>
8196
+ </xsl:if>
8197
+ </xsl:copy>
8198
+
8199
+ </xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
8200
+ <xsl:copy>
8201
+ <xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
8202
+ </xsl:copy>
8203
+ </xsl:template><xsl:template match="*[local-name() = 'stem' or local-name() = 'image']" mode="td_text_with_formatting"/><xsl:template match="*[local-name() = 'keep-together_within-line']/text()" mode="td_text_with_formatting">
8204
+ <xsl:variable name="formatting_tags">
8205
+ <xsl:call-template name="getFormattingTags"/>
8206
+ </xsl:variable>
8207
+ <word>
8208
+ <xsl:call-template name="enclose_text_in_tags">
8209
+ <xsl:with-param name="text" select="normalize-space(.)"/>
8210
+ <xsl:with-param name="tags" select="$formatting_tags"/>
8211
+ </xsl:call-template>
8212
+ </word>
8213
+ </xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
8214
+
8215
+ <xsl:variable name="td_text" select="."/>
8216
+
8217
+ <xsl:variable name="string_with_added_zerospaces">
8218
+ <xsl:call-template name="add-zero-spaces-java">
8219
+ <xsl:with-param name="text" select="$td_text"/>
8220
+ </xsl:call-template>
8221
+ </xsl:variable>
8222
+
8223
+ <xsl:variable name="formatting_tags">
8224
+ <xsl:call-template name="getFormattingTags"/>
8225
+ </xsl:variable>
8226
+
8227
+ <!-- <word>text</word> -->
8228
+ <xsl:call-template name="tokenize_with_tags">
8229
+ <xsl:with-param name="tags" select="$formatting_tags"/>
8230
+ <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​­', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
8231
+ </xsl:call-template>
8232
+ </xsl:template><xsl:template name="getFormattingTags">
8233
+ <tags>
8234
+ <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
8235
+ <xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
8236
+ <xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
8237
+ <xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
8238
+ <xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
8239
+ <xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
8240
+ </tags>
7167
8241
  </xsl:template><xsl:template name="getLang">
7168
8242
  <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
7169
8243
  <xsl:variable name="language">
@@ -7392,6 +8466,11 @@
7392
8466
  </xsl:variable>
7393
8467
  <fo:inline xsl:use-attribute-sets="link-style">
7394
8468
 
8469
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
8470
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
8471
+ </xsl:if>
8472
+
8473
+
7395
8474
 
7396
8475
 
7397
8476
 
@@ -7668,7 +8747,19 @@
7668
8747
  <xsl:value-of select="$suffix"/>
7669
8748
  </xsl:if>
7670
8749
  </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'p']">
7671
- <fo:inline><xsl:apply-templates/></fo:inline>
8750
+ <xsl:variable name="num"><xsl:number/></xsl:variable>
8751
+ <xsl:choose>
8752
+ <xsl:when test="$num = 1"> <!-- first paragraph renders in the same line as titlenote name -->
8753
+ <fo:inline xsl:use-attribute-sets="termnote-p-style">
8754
+ <xsl:apply-templates/>
8755
+ </fo:inline>
8756
+ </xsl:when>
8757
+ <xsl:otherwise>
8758
+ <fo:block xsl:use-attribute-sets="termnote-p-style">
8759
+ <xsl:apply-templates/>
8760
+ </fo:block>
8761
+ </xsl:otherwise>
8762
+ </xsl:choose>
7672
8763
  </xsl:template><xsl:template match="*[local-name() = 'terms']">
7673
8764
  <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
7674
8765
  <fo:block id="{@id}">
@@ -8503,7 +9594,7 @@
8503
9594
  </xsl:choose>
8504
9595
  </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'xref']" mode="contents">
8505
9596
  <xsl:value-of select="."/>
8506
- </xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
9597
+ </xsl:template><xsl:template match="*[local-name() = 'review']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
8507
9598
  <xsl:text> </xsl:text>
8508
9599
  </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
8509
9600
  <xsl:copy>
@@ -8574,7 +9665,7 @@
8574
9665
 
8575
9666
 
8576
9667
 
8577
-
9668
+ <!-- 9 -->
8578
9669
 
8579
9670
 
8580
9671
 
@@ -8658,7 +9749,7 @@
8658
9749
  <xsl:for-each select="xalan:nodeset($text_step4)/node()">
8659
9750
  <xsl:choose>
8660
9751
  <xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
8661
- <xsl:call-template name="interspers">
9752
+ <xsl:call-template name="interspers-java">
8662
9753
  <xsl:with-param name="str" select="."/>
8663
9754
  </xsl:call-template>
8664
9755
  </xsl:when>
@@ -8708,6 +9799,10 @@
8708
9799
  <xsl:with-param name="char" select="$char"/>
8709
9800
  </xsl:call-template>
8710
9801
  </xsl:if>
9802
+ </xsl:template><xsl:template name="interspers-java">
9803
+ <xsl:param name="str"/>
9804
+ <xsl:param name="char" select="$zero_width_space"/>
9805
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($str),'([^ -.:=_—])',concat('$1', $char))"/> <!-- insert $char after each char excep space, - . : = _ etc. -->
8711
9806
  </xsl:template><xsl:template match="*" mode="syntax_highlight">
8712
9807
  <xsl:apply-templates mode="syntax_highlight"/>
8713
9808
  </xsl:template><xsl:variable name="syntax_highlight_styles_">
@@ -8920,7 +10015,9 @@
8920
10015
  <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
8921
10016
  </xsl:if>
8922
10017
  <xsl:variable name="simple-table">
8923
- <xsl:call-template name="getSimpleTable"/>
10018
+ <xsl:call-template name="getSimpleTable">
10019
+ <xsl:with-param name="id" select="@id"/>
10020
+ </xsl:call-template>
8924
10021
  </xsl:variable>
8925
10022
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
8926
10023
  <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
@@ -9356,6 +10453,7 @@
9356
10453
 
9357
10454
 
9358
10455
 
10456
+
9359
10457
  <xsl:choose>
9360
10458
  <xsl:when test="ancestor::bipm:annex">2</xsl:when>
9361
10459
  <xsl:otherwise>8</xsl:otherwise>
@@ -9664,6 +10762,11 @@
9664
10762
  </xsl:otherwise>
9665
10763
  </xsl:choose>
9666
10764
  </xsl:template><xsl:template match="*[local-name()='ul'] | *[local-name()='ol']" mode="list" name="list">
10765
+
10766
+ <xsl:apply-templates select="*[local-name() = 'name']">
10767
+ <xsl:with-param name="process">true</xsl:with-param>
10768
+ </xsl:apply-templates>
10769
+
9667
10770
  <fo:list-block xsl:use-attribute-sets="list-style">
9668
10771
 
9669
10772
 
@@ -9674,12 +10777,23 @@
9674
10777
 
9675
10778
 
9676
10779
 
10780
+ <xsl:if test="*[local-name() = 'name']">
10781
+ <xsl:attribute name="margin-top">0pt</xsl:attribute>
10782
+ </xsl:if>
10783
+
9677
10784
  <xsl:apply-templates select="node()[not(local-name() = 'note')]"/>
9678
10785
  </fo:list-block>
9679
10786
  <!-- <xsl:for-each select="./iho:note">
9680
10787
  <xsl:call-template name="note"/>
9681
10788
  </xsl:for-each> -->
9682
10789
  <xsl:apply-templates select="./*[local-name() = 'note']"/>
10790
+ </xsl:template><xsl:template match="*[local-name() = 'ol' or local-name() = 'ul']/*[local-name() = 'name']">
10791
+ <xsl:param name="process">false</xsl:param>
10792
+ <xsl:if test="$process = 'true'">
10793
+ <fo:block xsl:use-attribute-sets="list-name-style">
10794
+ <xsl:apply-templates/>
10795
+ </fo:block>
10796
+ </xsl:if>
9683
10797
  </xsl:template><xsl:template match="*[local-name()='li']">
9684
10798
  <fo:list-item xsl:use-attribute-sets="list-item-style">
9685
10799
  <xsl:copy-of select="@id"/>
@@ -9879,7 +10993,7 @@
9879
10993
  <!-- <fo:inline id="{@id}" font-size="1pt"/> -->
9880
10994
  <fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
9881
10995
  <!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
9882
- <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"> </xsl:if>
10996
+ <xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
9883
10997
  </xsl:template><xsl:template match="*[local-name() = 'errata']">
9884
10998
  <!-- <row>
9885
10999
  <date>05-07-2013</date>
@@ -9951,6 +11065,7 @@
9951
11065
  </xsl:template><xsl:template match="*[local-name() = 'references'][not(@normative='true')]/*[local-name() = 'bibitem']" priority="2">
9952
11066
 
9953
11067
 
11068
+ <!-- start BIPM bibitem processing -->
9954
11069
  <fo:list-block id="{@id}" xsl:use-attribute-sets="bibitem-non-normative-list-style">
9955
11070
  <fo:list-item>
9956
11071
  <fo:list-item-label end-indent="label-end()">
@@ -9963,7 +11078,7 @@
9963
11078
  <xsl:value-of select="bipm:docidentifier[@type='metanorma']"/>
9964
11079
  </xsl:when>
9965
11080
  <xsl:otherwise>
9966
- <xsl:number format="[1]"/>
11081
+ <xsl:number format="[1]" count="*[local-name()='bibitem'][not(@hidden = 'true')]"/>
9967
11082
  </xsl:otherwise>
9968
11083
  </xsl:choose>
9969
11084
  </xsl:if>
@@ -9977,6 +11092,7 @@
9977
11092
  </fo:list-item-body>
9978
11093
  </fo:list-item>
9979
11094
  </fo:list-block>
11095
+ <!-- END BIPM bibitem processing -->
9980
11096
 
9981
11097
 
9982
11098
  </xsl:template><xsl:template name="processBibitem">
@@ -9986,32 +11102,12 @@
9986
11102
  <xsl:if test=".//bipm:fn">
9987
11103
  <xsl:attribute name="line-height-shift-adjustment">disregard-shifts</xsl:attribute>
9988
11104
  </xsl:if>
9989
- <xsl:choose>
9990
- <xsl:when test="*[local-name() = 'formattedref']">
9991
- <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
9992
- </xsl:when>
9993
- <xsl:otherwise>
9994
- <xsl:variable name="docidentifier" select="*[local-name() = 'docidentifier'][not(@type = 'URN' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'BIPM' or @type = 'ISBN' or @type = 'ISSN')]"/>
9995
-
9996
- <xsl:value-of select="$docidentifier"/>
9997
- <xsl:if test="$docidentifier != '' and *[local-name() = 'title']">, </xsl:if>
9998
-
9999
- <xsl:variable name="curr_lang" select="ancestor::bipm:bipm-standard/bipm:bibdata/bipm:language"/>
10000
-
10001
- <xsl:choose>
10002
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = $curr_lang]">
10003
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = $curr_lang]"/>
10004
- </xsl:when>
10005
- <xsl:when test="*[local-name() = 'title'][@type = 'main' and @language = 'en']">
10006
- <xsl:apply-templates select="*[local-name() = 'title'][@type = 'main' and @language = 'en']"/>
10007
- </xsl:when>
10008
- <xsl:otherwise>
10009
- <xsl:apply-templates select="*[local-name() = 'title']"/>
10010
- </xsl:otherwise>
10011
- </xsl:choose>
10012
-
10013
- </xsl:otherwise>
10014
- </xsl:choose>
11105
+
11106
+ <xsl:variable name="docidentifier" select="*[local-name() = 'docidentifier'][not(@type = 'URN' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'BIPM' or @type = 'ISBN' or @type = 'ISSN')]"/>
11107
+ <xsl:value-of select="$docidentifier"/>
11108
+
11109
+ <xsl:if test="$docidentifier != '' and *[local-name() = 'formattedref']">, </xsl:if>
11110
+ <xsl:apply-templates select="*[local-name() = 'formattedref']"/>
10015
11111
  <!-- end BIPM bibitem processing-->
10016
11112
 
10017
11113
  </xsl:template><xsl:template name="processBibitemDocId">
@@ -10321,12 +11417,16 @@
10321
11417
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
10322
11418
 
10323
11419
 
11420
+
11421
+
10324
11422
 
10325
11423
 
10326
11424
 
10327
11425
  <fo:block-container xsl:use-attribute-sets="admonition-container-style">
10328
11426
 
10329
11427
 
11428
+
11429
+
10330
11430
  <fo:block xsl:use-attribute-sets="admonition-name-style">
10331
11431
  <xsl:call-template name="displayAdmonitionName"/>
10332
11432
  </fo:block>
@@ -10339,25 +11439,32 @@
10339
11439
  </fo:block-container>
10340
11440
 
10341
11441
  </xsl:template><xsl:template name="displayAdmonitionName">
10342
-
11442
+ <xsl:param name="sep"/> <!-- Example: ' - ' -->
11443
+ <!-- <xsl:choose>
11444
+ <xsl:when test="$namespace = 'nist-cswp' or $namespace = 'nist-sp'">
11445
+ <xsl:choose>
11446
+ <xsl:when test="@type='important'"><xsl:apply-templates select="@type"/></xsl:when>
11447
+ <xsl:otherwise>
11448
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
11449
+ </xsl:otherwise>
11450
+ </xsl:choose>
11451
+ </xsl:when>
11452
+ <xsl:otherwise>
10343
11453
  <xsl:apply-templates select="*[local-name() = 'name']"/>
10344
11454
  <xsl:if test="not(*[local-name() = 'name'])">
10345
11455
  <xsl:apply-templates select="@type"/>
10346
11456
  </xsl:if>
10347
-
10348
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
10349
- <xsl:apply-templates/>
10350
- </xsl:template><xsl:template match="*[local-name() = 'admonition']/@type">
10351
- <xsl:variable name="admonition_type_">
10352
- <xsl:call-template name="getLocalizedString">
10353
- <xsl:with-param name="key">admonition.<xsl:value-of select="."/></xsl:with-param>
10354
- </xsl:call-template>
11457
+ </xsl:otherwise>
11458
+ </xsl:choose> -->
11459
+ <xsl:variable name="name">
11460
+ <xsl:apply-templates select="*[local-name() = 'name']"/>
10355
11461
  </xsl:variable>
10356
- <xsl:variable name="admonition_type" select="normalize-space(java:toUpperCase(java:java.lang.String.new($admonition_type_)))"/>
10357
- <xsl:value-of select="$admonition_type"/>
10358
- <xsl:if test="$admonition_type = ''">
10359
- <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(.))"/>
11462
+ <xsl:copy-of select="$name"/>
11463
+ <xsl:if test="normalize-space($name) != ''">
11464
+ <xsl:value-of select="$sep"/>
10360
11465
  </xsl:if>
11466
+ </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'name']">
11467
+ <xsl:apply-templates/>
10361
11468
  </xsl:template><xsl:template match="*[local-name() = 'admonition']/*[local-name() = 'p']">
10362
11469
 
10363
11470
  <fo:block xsl:use-attribute-sets="admonition-p-style">
@@ -10528,6 +11635,8 @@
10528
11635
  </xsl:when>
10529
11636
  <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
10530
11637
  </xsl:choose>
11638
+ </xsl:template><xsl:template match="*[local-name() = 'lang_none']">
11639
+ <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
10531
11640
  </xsl:template><xsl:template name="printEdition">
10532
11641
  <xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
10533
11642
  <xsl:text> </xsl:text>
@@ -10634,6 +11743,27 @@
10634
11743
  </xsl:when>
10635
11744
  <xsl:otherwise><xsl:value-of select="$monthStr_"/></xsl:otherwise>
10636
11745
  </xsl:choose>
11746
+ </xsl:template><xsl:template name="getMonthLocalizedByNum">
11747
+ <xsl:param name="num"/>
11748
+ <xsl:variable name="monthStr">
11749
+ <xsl:choose>
11750
+ <xsl:when test="$num = '01'">january</xsl:when>
11751
+ <xsl:when test="$num = '02'">february</xsl:when>
11752
+ <xsl:when test="$num = '03'">march</xsl:when>
11753
+ <xsl:when test="$num = '04'">april</xsl:when>
11754
+ <xsl:when test="$num = '05'">may</xsl:when>
11755
+ <xsl:when test="$num = '06'">june</xsl:when>
11756
+ <xsl:when test="$num = '07'">july</xsl:when>
11757
+ <xsl:when test="$num = '08'">august</xsl:when>
11758
+ <xsl:when test="$num = '09'">september</xsl:when>
11759
+ <xsl:when test="$num = '10'">october</xsl:when>
11760
+ <xsl:when test="$num = '11'">november</xsl:when>
11761
+ <xsl:when test="$num = '12'">december</xsl:when>
11762
+ </xsl:choose>
11763
+ </xsl:variable>
11764
+ <xsl:call-template name="getLocalizedString">
11765
+ <xsl:with-param name="key">month_<xsl:value-of select="$monthStr"/></xsl:with-param>
11766
+ </xsl:call-template>
10637
11767
  </xsl:template><xsl:template name="insertKeywords">
10638
11768
  <xsl:param name="sorting" select="'true'"/>
10639
11769
  <xsl:param name="charAtEnd" select="'.'"/>
@@ -10833,6 +11963,7 @@
10833
11963
 
10834
11964
 
10835
11965
 
11966
+
10836
11967
 
10837
11968
 
10838
11969
 
@@ -11240,4 +12371,40 @@
11240
12371
  <xsl:value-of select="$value"/>
11241
12372
  </xsl:otherwise>
11242
12373
  </xsl:choose>
12374
+ </xsl:template><xsl:template match="*" mode="print_as_xml">
12375
+ <xsl:param name="level">0</xsl:param>
12376
+
12377
+ <fo:block margin-left="{2*$level}mm">
12378
+ <xsl:text>
12379
+ &lt;</xsl:text>
12380
+ <xsl:value-of select="local-name()"/>
12381
+ <xsl:for-each select="@*">
12382
+ <xsl:text> </xsl:text>
12383
+ <xsl:value-of select="local-name()"/>
12384
+ <xsl:text>="</xsl:text>
12385
+ <xsl:value-of select="."/>
12386
+ <xsl:text>"</xsl:text>
12387
+ </xsl:for-each>
12388
+ <xsl:text>&gt;</xsl:text>
12389
+
12390
+ <xsl:if test="not(*)">
12391
+ <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
12392
+ <xsl:text>&lt;/</xsl:text>
12393
+ <xsl:value-of select="local-name()"/>
12394
+ <xsl:text>&gt;</xsl:text>
12395
+ </xsl:if>
12396
+ </fo:block>
12397
+
12398
+ <xsl:if test="*">
12399
+ <fo:block>
12400
+ <xsl:apply-templates mode="print_as_xml">
12401
+ <xsl:with-param name="level" select="$level + 1"/>
12402
+ </xsl:apply-templates>
12403
+ </fo:block>
12404
+ <fo:block margin-left="{2*$level}mm">
12405
+ <xsl:text>&lt;/</xsl:text>
12406
+ <xsl:value-of select="local-name()"/>
12407
+ <xsl:text>&gt;</xsl:text>
12408
+ </fo:block>
12409
+ </xsl:if>
11243
12410
  </xsl:template></xsl:stylesheet>