metanorma-un 0.10.3 → 0.10.5

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.
@@ -1309,7 +1309,6 @@
1309
1309
 
1310
1310
  <xsl:attribute-set name="table-header-cell-style">
1311
1311
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1312
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1313
1312
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1314
1313
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1315
1314
  <xsl:attribute name="display-align">center</xsl:attribute>
@@ -1328,7 +1327,6 @@
1328
1327
 
1329
1328
  <xsl:attribute-set name="table-cell-style">
1330
1329
  <xsl:attribute name="display-align">center</xsl:attribute>
1331
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1332
1330
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1333
1331
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1334
1332
 
@@ -2053,7 +2051,7 @@
2053
2051
  <xsl:apply-templates select="." mode="contents"/>
2054
2052
  </xsl:for-each>
2055
2053
 
2056
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2054
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0]">
2057
2055
  <xsl:sort select="@displayorder" data-type="number"/>
2058
2056
  <xsl:apply-templates select="." mode="contents"/>
2059
2057
  </xsl:for-each>
@@ -2384,6 +2382,7 @@
2384
2382
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
2385
2383
 
2386
2384
  <xsl:choose>
2385
+ <xsl:when test="@width = 'full-page-width' or @width = 'text-width'">100%</xsl:when>
2387
2386
  <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
2388
2387
  <xsl:otherwise><xsl:value-of select="$table_width_default"/></xsl:otherwise>
2389
2388
  </xsl:choose>
@@ -2505,7 +2504,7 @@
2505
2504
  <xsl:variable name="isDeleted" select="@deleted"/>
2506
2505
 
2507
2506
  <xsl:choose>
2508
- <xsl:when test="@width">
2507
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
2509
2508
 
2510
2509
  <!-- centered table when table name is centered (see table-name-style) -->
2511
2510
 
@@ -2827,6 +2826,7 @@
2827
2826
  This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
2828
2827
  <xsl:when test="(@width_max &gt; $page_width and @width_min &lt; $page_width) or (@width_min &gt;= $page_width)">
2829
2828
  <!-- difference between the available space and the minimum table width -->
2829
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
2830
2830
  <xsl:variable name="W" select="$page_width - @width_min"/>
2831
2831
  <W><xsl:value-of select="$W"/></W>
2832
2832
  <!-- difference between maximum and minimum width of the table -->
@@ -2990,6 +2990,10 @@
2990
2990
  </xsl:choose>
2991
2991
  </xsl:variable>
2992
2992
 
2993
+ <xsl:variable name="table_fn_block">
2994
+ <xsl:call-template name="table_fn_display"/>
2995
+ </xsl:variable>
2996
+
2993
2997
  <xsl:variable name="tableWithNotesAndFootnotes">
2994
2998
 
2995
2999
  <fo:table keep-with-previous="always">
@@ -3037,11 +3041,25 @@
3037
3041
 
3038
3042
  <xsl:apply-templates select="../*[local-name()='note']"/>
3039
3043
 
3044
+ <xsl:variable name="isDisplayRowSeparator">
3045
+
3046
+ </xsl:variable>
3047
+
3040
3048
  <!-- horizontal row separator -->
3049
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3050
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3051
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3052
+
3053
+ <xsl:call-template name="setBordersTableArray"/>
3054
+ <fo:block font-size="1pt"> </fo:block>
3055
+ </fo:block-container>
3056
+ </xsl:if>
3057
+ </xsl:if>
3041
3058
 
3042
3059
  <!-- fn processing -->
3043
3060
 
3044
- <xsl:call-template name="table_fn_display"/>
3061
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3062
+ <xsl:copy-of select="$table_fn_block"/>
3045
3063
 
3046
3064
  <!-- for PAS display Notes after footnotes -->
3047
3065
 
@@ -3158,6 +3176,28 @@
3158
3176
  </fo:table-row>
3159
3177
  </xsl:template>
3160
3178
 
3179
+ <xsl:template name="setBorderUnderRow">
3180
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3181
+ <xsl:choose>
3182
+ <xsl:when test="$border_under_row_ != ''">
3183
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3184
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3185
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3186
+ <xsl:variable name="border_under_row">
3187
+ <xsl:call-template name="split">
3188
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3189
+ </xsl:call-template>
3190
+ </xsl:variable>
3191
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3192
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3193
+ </xsl:if>
3194
+ </xsl:when>
3195
+ <xsl:otherwise>
3196
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3197
+ </xsl:otherwise>
3198
+ </xsl:choose>
3199
+ </xsl:template>
3200
+
3161
3201
  <!-- row in table footer (tfoot) -->
3162
3202
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3163
3203
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -3452,17 +3492,20 @@
3452
3492
  <xsl:for-each select="xalan:nodeset($references)//fn">
3453
3493
  <xsl:variable name="reference" select="@reference"/>
3454
3494
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3455
- <fo:block xsl:use-attribute-sets="table-fn-style">
3456
3495
 
3457
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3496
+ <fo:block xsl:use-attribute-sets="table-fn-style">
3458
3497
 
3459
- <xsl:value-of select="@reference"/>
3498
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3499
+
3500
+ <xsl:value-of select="@reference"/>
3501
+
3502
+ </fo:inline>
3503
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3504
+ <xsl:copy-of select="./node()"/>
3505
+ </fo:inline>
3506
+
3507
+ </fo:block>
3460
3508
 
3461
- </fo:inline>
3462
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3463
- <xsl:copy-of select="./node()"/>
3464
- </fo:inline>
3465
- </fo:block>
3466
3509
  </xsl:if>
3467
3510
  </xsl:for-each>
3468
3511
  </xsl:template>
@@ -3491,8 +3534,16 @@
3491
3534
  <!-- figure's footnotes rendering -->
3492
3535
  <xsl:template name="fn_display_figure">
3493
3536
 
3537
+ <!-- current figure id -->
3538
+ <xsl:variable name="figure_id_">
3539
+ <xsl:value-of select="@id"/>
3540
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3541
+ </xsl:variable>
3542
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3543
+
3544
+ <!-- all footnotes relates to the current figure -->
3494
3545
  <xsl:variable name="references">
3495
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3546
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3496
3547
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3497
3548
  <xsl:apply-templates/>
3498
3549
  </fn>
@@ -3505,91 +3556,93 @@
3505
3556
 
3506
3557
  </xsl:variable>
3507
3558
 
3508
- <!-- current hierarchy is 'figure' element -->
3509
- <xsl:variable name="following_dl_colwidths">
3510
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3511
- <xsl:variable name="simple-table">
3512
- <!-- <xsl:variable name="doc_ns">
3513
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3559
+ <fo:block>
3560
+
3561
+ <!-- current hierarchy is 'figure' element -->
3562
+ <xsl:variable name="following_dl_colwidths">
3563
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3564
+ <xsl:variable name="simple-table">
3565
+ <!-- <xsl:variable name="doc_ns">
3566
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3567
+ </xsl:variable>
3568
+ <xsl:variable name="ns">
3569
+ <xsl:choose>
3570
+ <xsl:when test="normalize-space($doc_ns) != ''">
3571
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3572
+ </xsl:when>
3573
+ <xsl:otherwise>
3574
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3575
+ </xsl:otherwise>
3576
+ </xsl:choose>
3577
+ </xsl:variable> -->
3578
+
3579
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3580
+ <tbody>
3581
+ <xsl:apply-templates mode="dl"/>
3582
+ </tbody>
3583
+ </xsl:for-each>
3584
+ </xsl:variable>
3585
+
3586
+ <xsl:call-template name="calculate-column-widths">
3587
+ <xsl:with-param name="cols-count" select="2"/>
3588
+ <xsl:with-param name="table" select="$simple-table"/>
3589
+ </xsl:call-template>
3590
+
3591
+ </xsl:if>
3592
+ </xsl:variable>
3593
+
3594
+ <xsl:variable name="maxlength_dt">
3595
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3596
+ <xsl:call-template name="getMaxLength_dt"/>
3597
+ </xsl:for-each>
3514
3598
  </xsl:variable>
3515
- <xsl:variable name="ns">
3599
+
3600
+ <fo:table width="95%" table-layout="fixed">
3601
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3602
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3603
+
3604
+ </xsl:if>
3516
3605
  <xsl:choose>
3517
- <xsl:when test="normalize-space($doc_ns) != ''">
3518
- <xsl:value-of select="normalize-space($doc_ns)"/>
3606
+ <!-- if there 'dl', then set same columns width -->
3607
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3608
+ <xsl:call-template name="setColumnWidth_dl">
3609
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3610
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3611
+ </xsl:call-template>
3519
3612
  </xsl:when>
3520
3613
  <xsl:otherwise>
3521
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3614
+ <fo:table-column column-width="5%"/>
3615
+ <fo:table-column column-width="95%"/>
3522
3616
  </xsl:otherwise>
3523
3617
  </xsl:choose>
3524
- </xsl:variable> -->
3525
-
3526
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3527
- <tbody>
3528
- <xsl:apply-templates mode="dl"/>
3529
- </tbody>
3530
- </xsl:for-each>
3531
- </xsl:variable>
3532
-
3533
- <xsl:call-template name="calculate-column-widths">
3534
- <xsl:with-param name="cols-count" select="2"/>
3535
- <xsl:with-param name="table" select="$simple-table"/>
3536
- </xsl:call-template>
3537
-
3538
- </xsl:if>
3539
- </xsl:variable>
3618
+ <fo:table-body>
3619
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3620
+ <xsl:variable name="reference" select="@reference"/>
3621
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3622
+ <fo:table-row>
3623
+ <fo:table-cell>
3624
+ <fo:block>
3625
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3626
+ <xsl:value-of select="@reference"/>
3627
+ </fo:inline>
3628
+ </fo:block>
3629
+ </fo:table-cell>
3630
+ <fo:table-cell>
3631
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3632
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3540
3633
 
3541
- <xsl:variable name="maxlength_dt">
3542
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3543
- <xsl:call-template name="getMaxLength_dt"/>
3544
- </xsl:for-each>
3545
- </xsl:variable>
3634
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3546
3635
 
3547
- <fo:block>
3548
- <fo:table width="95%" table-layout="fixed">
3549
- <xsl:if test="normalize-space($key_iso) = 'true'">
3550
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3551
-
3552
- </xsl:if>
3553
- <xsl:choose>
3554
- <!-- if there 'dl', then set same columns width -->
3555
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3556
- <xsl:call-template name="setColumnWidth_dl">
3557
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3558
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3559
- </xsl:call-template>
3560
- </xsl:when>
3561
- <xsl:otherwise>
3562
- <fo:table-column column-width="15%"/>
3563
- <fo:table-column column-width="85%"/>
3564
- </xsl:otherwise>
3565
- </xsl:choose>
3566
- <fo:table-body>
3567
- <xsl:for-each select="xalan:nodeset($references)//fn">
3568
- <xsl:variable name="reference" select="@reference"/>
3569
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3570
- <fo:table-row>
3571
- <fo:table-cell>
3572
- <fo:block>
3573
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3574
- <xsl:value-of select="@reference"/>
3575
- </fo:inline>
3576
- </fo:block>
3577
- </fo:table-cell>
3578
- <fo:table-cell>
3579
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3580
- <xsl:if test="normalize-space($key_iso) = 'true'">
3581
-
3582
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3636
+ </xsl:if>
3637
+ <xsl:copy-of select="./node()"/>
3638
+ </fo:block>
3639
+ </fo:table-cell>
3640
+ </fo:table-row>
3641
+ </xsl:if>
3642
+ </xsl:for-each>
3643
+ </fo:table-body>
3644
+ </fo:table>
3583
3645
 
3584
- </xsl:if>
3585
- <xsl:copy-of select="./node()"/>
3586
- </fo:block>
3587
- </fo:table-cell>
3588
- </fo:table-row>
3589
- </xsl:if>
3590
- </xsl:for-each>
3591
- </fo:table-body>
3592
- </fo:table>
3593
3646
  </fo:block>
3594
3647
  </xsl:if>
3595
3648
 
@@ -3665,12 +3718,14 @@
3665
3718
 
3666
3719
  <fo:block margin-bottom="12pt" text-align="left">
3667
3720
 
3668
- <xsl:variable name="title-where">
3721
+ <!-- <xsl:variable name="title-where">
3669
3722
  <xsl:call-template name="getLocalizedString">
3670
3723
  <xsl:with-param name="key">where</xsl:with-param>
3671
3724
  </xsl:call-template>
3672
3725
  </xsl:variable>
3673
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3726
+ <xsl:value-of select="$title-where"/> -->
3727
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3728
+ <xsl:text> </xsl:text>
3674
3729
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3675
3730
  <xsl:text/>
3676
3731
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3680,12 +3735,14 @@
3680
3735
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3681
3736
  <fo:block margin-bottom="12pt" text-align="left">
3682
3737
 
3683
- <xsl:variable name="title-where">
3738
+ <!-- <xsl:variable name="title-where">
3684
3739
  <xsl:call-template name="getLocalizedString">
3685
3740
  <xsl:with-param name="key">where</xsl:with-param>
3686
3741
  </xsl:call-template>
3687
3742
  </xsl:variable>
3688
- <xsl:value-of select="$title-where"/>
3743
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3744
+ <!-- preceding 'p' with word 'where' -->
3745
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3689
3746
  </fo:block>
3690
3747
  </xsl:when> <!-- END: a few components -->
3691
3748
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3868,6 +3925,9 @@
3868
3925
 
3869
3926
  </xsl:template> <!-- END: dl -->
3870
3927
 
3928
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
3929
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
3930
+
3871
3931
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3872
3932
  <xsl:param name="process">false</xsl:param>
3873
3933
  <xsl:if test="$process = 'true'">
@@ -4398,12 +4458,12 @@
4398
4458
  <xsl:param name="value"/>
4399
4459
  <xsl:variable name="add_width" select="string-length($value) * 20"/>
4400
4460
  <xsl:variable name="maxwidth" select="60 + $add_width"/>
4401
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
4402
- <xsl:attribute name="height">5mm</xsl:attribute>
4461
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
4462
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
4403
4463
  <xsl:attribute name="content-width">100%</xsl:attribute>
4404
4464
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4405
4465
  <xsl:attribute name="scaling">uniform</xsl:attribute>
4406
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4466
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4407
4467
  <g>
4408
4468
  <xsl:if test="$type = 'closing' or $type = 'end'">
4409
4469
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
@@ -4417,6 +4477,27 @@
4417
4477
  </xsl:if>
4418
4478
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
4419
4479
  </text>
4480
+ </svg> -->
4481
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4482
+ <g>
4483
+ <xsl:if test="$type = 'closing' or $type = 'end'">
4484
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
4485
+ </xsl:if>
4486
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
4487
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
4488
+ </g>
4489
+ <xsl:variable name="text_x">
4490
+ <xsl:choose>
4491
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
4492
+ <xsl:otherwise>22</xsl:otherwise>
4493
+ </xsl:choose>
4494
+ </xsl:variable>
4495
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
4496
+ <xsl:value-of select="$kind"/>
4497
+ </text>
4498
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
4499
+ <xsl:value-of select="$value"/>
4500
+ </text>
4420
4501
  </svg>
4421
4502
  </fo:instream-foreign-object>
4422
4503
  </xsl:template>
@@ -4671,18 +4752,34 @@
4671
4752
 
4672
4753
  <xsl:template name="add-zero-spaces-java">
4673
4754
  <xsl:param name="text" select="."/>
4674
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
4675
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
4755
+
4756
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
4757
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4758
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4759
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4760
+ <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4761
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4676
4762
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4677
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
4763
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
4678
4764
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4679
- <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
4765
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
4680
4766
  <!-- add zero-width space (#x200B) before character: { -->
4681
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4767
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4682
4768
  <!-- add zero-width space (#x200B) after character: , -->
4683
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4769
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4770
+ <!-- add zero-width space (#x200B) after character: '/' -->
4771
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4772
+
4773
+ <xsl:variable name="text9">
4774
+ <xsl:choose>
4775
+ <xsl:when test="$isGenerateTableIF = 'true'">
4776
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4777
+ </xsl:when>
4778
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4779
+ </xsl:choose>
4780
+ </xsl:variable>
4684
4781
 
4685
- <xsl:value-of select="$text5"/>
4782
+ <xsl:value-of select="$text9"/>
4686
4783
  </xsl:template>
4687
4784
 
4688
4785
  <xsl:template name="add-zero-spaces-link-java">
@@ -4690,8 +4787,10 @@
4690
4787
 
4691
4788
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4692
4789
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4693
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4694
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
4790
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
4791
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
4792
+ <!-- remove zero-width space at the end -->
4793
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4695
4794
  </xsl:template>
4696
4795
 
4697
4796
  <!-- add zero space after dash character (for table's entries) -->
@@ -4828,7 +4927,7 @@
4828
4927
  </xsl:copy>
4829
4928
  </xsl:template>
4830
4929
 
4831
- <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode'])]" mode="table-without-br">
4930
+ <xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p']) and not(*[local-name()='sourcecode']) and not(*[local-name()='ul']) and not(*[local-name()='ol'])]" mode="table-without-br">
4832
4931
  <xsl:copy>
4833
4932
  <xsl:copy-of select="@*"/>
4834
4933
  <p>
@@ -4904,6 +5003,14 @@
4904
5003
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4905
5004
  </xsl:template>
4906
5005
 
5006
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" mode="table-without-br">
5007
+ <xsl:apply-templates mode="table-without-br"/>
5008
+ </xsl:template>
5009
+
5010
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'li']" mode="table-without-br">
5011
+ <xsl:apply-templates mode="table-without-br"/>
5012
+ </xsl:template>
5013
+
4907
5014
  <!-- mode="table-without-br" -->
4908
5015
  <!-- ================================== -->
4909
5016
  <!-- END: Step 0. replace <br/> to <p>...</p> -->
@@ -5036,9 +5143,28 @@
5036
5143
  </xsl:variable>
5037
5144
  <xsl:copy-of select="$newRow"/>
5038
5145
 
5039
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5040
- <xsl:with-param name="previousRow" select="$newRow"/>
5041
- </xsl:apply-templates>
5146
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5147
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5148
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5149
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5150
+ <xsl:choose>
5151
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5152
+ <xsl:copy-of select="following-sibling::tr"/>
5153
+ </xsl:when>
5154
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5155
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5156
+
5157
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5158
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5159
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5160
+ </xsl:apply-templates>
5161
+ </xsl:when> -->
5162
+ <xsl:otherwise>
5163
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5164
+ <xsl:with-param name="previousRow" select="$newRow"/>
5165
+ </xsl:apply-templates>
5166
+ </xsl:otherwise>
5167
+ </xsl:choose>
5042
5168
  </xsl:template>
5043
5169
  <!-- End mode simple-table-rowspan -->
5044
5170
 
@@ -5201,6 +5327,27 @@
5201
5327
  </xsl:call-template>
5202
5328
  </xsl:template>
5203
5329
 
5330
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5331
+ <xsl:variable name="link">
5332
+ <link_updated>
5333
+ <xsl:variable name="target_text">
5334
+ <xsl:choose>
5335
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5336
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5337
+ </xsl:when>
5338
+ <xsl:otherwise>
5339
+ <xsl:value-of select="normalize-space(@target)"/>
5340
+ </xsl:otherwise>
5341
+ </xsl:choose>
5342
+ </xsl:variable>
5343
+ <xsl:value-of select="$target_text"/>
5344
+ </link_updated>
5345
+ </xsl:variable>
5346
+ <xsl:for-each select="xalan:nodeset($link)/*">
5347
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5348
+ </xsl:for-each>
5349
+ </xsl:template>
5350
+
5204
5351
  <xsl:template name="getFormattingTags">
5205
5352
  <tags>
5206
5353
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5542,7 +5689,7 @@
5542
5689
  </xsl:variable>
5543
5690
  <fo:inline xsl:use-attribute-sets="link-style">
5544
5691
 
5545
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5692
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5546
5693
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5547
5694
  </xsl:if>
5548
5695
 
@@ -5722,7 +5869,7 @@
5722
5869
 
5723
5870
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5724
5871
 
5725
- <fo:block-container margin-left="0mm">
5872
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5726
5873
 
5727
5874
  <fo:block>
5728
5875
 
@@ -5909,13 +6056,16 @@
5909
6056
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
5910
6057
  </xsl:call-template>
5911
6058
 
6059
+ <!-- Example: Dimensions in millimeters -->
6060
+ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/>
6061
+
5912
6062
  <fo:block xsl:use-attribute-sets="figure-style">
5913
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
6063
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
5914
6064
  </fo:block>
5915
- <xsl:call-template name="fn_display_figure"/>
5916
- <xsl:for-each select="*[local-name() = 'note']">
6065
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
5917
6066
  <xsl:call-template name="note"/>
5918
6067
  </xsl:for-each>
6068
+ <xsl:call-template name="fn_display_figure"/>
5919
6069
 
5920
6070
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
5921
6071
 
@@ -5978,7 +6128,13 @@
5978
6128
  </xsl:choose>
5979
6129
  </xsl:variable>
5980
6130
 
5981
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6131
+ <xsl:variable name="image_width_effective">
6132
+
6133
+ <xsl:value-of select="$width_effective"/>
6134
+
6135
+ </xsl:variable>
6136
+
6137
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
5982
6138
  <xsl:if test="number($scale) &lt; 100">
5983
6139
 
5984
6140
  <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
@@ -6170,24 +6326,47 @@
6170
6326
 
6171
6327
  </xsl:when>
6172
6328
  <xsl:otherwise>
6173
- <fo:block xsl:use-attribute-sets="image-style">
6174
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6175
- <xsl:attribute name="width">100%</xsl:attribute>
6176
- <xsl:attribute name="content-height">100%</xsl:attribute>
6177
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6178
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6179
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6180
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6181
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6182
- <!-- effective height / width = 1.48, 1.4 - with title -->
6183
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6184
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6185
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6186
- </xsl:if>
6187
- <xsl:attribute name="scaling">uniform</xsl:attribute>
6188
- <xsl:copy-of select="$svg_content"/>
6189
- </fo:instream-foreign-object>
6190
- </fo:block>
6329
+
6330
+ <xsl:variable name="element">
6331
+ <xsl:choose>
6332
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
6333
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
6334
+ </xsl:when>
6335
+ <xsl:otherwise>
6336
+ <fo:block xsl:use-attribute-sets="image-style">
6337
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
6338
+ <xsl:attribute name="text-align">left</xsl:attribute>
6339
+ </xsl:if>
6340
+ </fo:block>
6341
+ </xsl:otherwise>
6342
+ </xsl:choose>
6343
+ </xsl:variable>
6344
+
6345
+ <xsl:for-each select="xalan:nodeset($element)/*">
6346
+ <xsl:copy>
6347
+ <xsl:copy-of select="@*"/>
6348
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
6349
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6350
+ <xsl:if test="$isGenerateTableIF = 'false'">
6351
+ <xsl:attribute name="width">100%</xsl:attribute>
6352
+ </xsl:if>
6353
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6354
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6355
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6356
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6357
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6358
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6359
+ <!-- effective height / width = 1.48, 1.4 - with title -->
6360
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6361
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6362
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6363
+ </xsl:if>
6364
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6365
+ <xsl:copy-of select="$svg_content"/>
6366
+ </fo:instream-foreign-object>
6367
+ <!-- </fo:block> -->
6368
+ </xsl:copy>
6369
+ </xsl:for-each>
6191
6370
  </xsl:otherwise>
6192
6371
  </xsl:choose>
6193
6372
  </xsl:template>
@@ -6279,6 +6458,13 @@
6279
6458
  </xsl:for-each>
6280
6459
  </xsl:template>
6281
6460
 
6461
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
6462
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
6463
+ <xsl:for-each select="*[local-name() = 'svg']">
6464
+ <xsl:call-template name="image_svg"/>
6465
+ </xsl:for-each>
6466
+ </xsl:template>
6467
+
6282
6468
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
6283
6469
  <xsl:variable name="svg_content" select="document(@src)"/>
6284
6470
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -6417,6 +6603,8 @@
6417
6603
  <xsl:value-of select="."/>
6418
6604
  </xsl:template>
6419
6605
 
6606
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
6607
+
6420
6608
  <xsl:template match="node()" mode="contents">
6421
6609
  <xsl:apply-templates mode="contents"/>
6422
6610
  </xsl:template>
@@ -6533,6 +6721,13 @@
6533
6721
  <xsl:when test="$contents_nodes/doc">
6534
6722
  <xsl:choose>
6535
6723
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6724
+
6725
+ <xsl:if test="$contents_nodes/collection">
6726
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6727
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6728
+ </fo:bookmark>
6729
+ </xsl:if>
6730
+
6536
6731
  <xsl:for-each select="$contents_nodes/doc">
6537
6732
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6538
6733
  <xsl:if test="@bundle = 'true'">
@@ -6724,7 +6919,15 @@
6724
6919
  <xsl:value-of select="@section"/>
6725
6920
  <xsl:text> </xsl:text>
6726
6921
  </xsl:if>
6727
- <xsl:value-of select="normalize-space(title)"/>
6922
+ <xsl:variable name="title">
6923
+ <xsl:for-each select="title/node()">
6924
+ <xsl:choose>
6925
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
6926
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
6927
+ </xsl:choose>
6928
+ </xsl:for-each>
6929
+ </xsl:variable>
6930
+ <xsl:value-of select="normalize-space($title)"/>
6728
6931
  </fo:bookmark-title>
6729
6932
  <xsl:apply-templates mode="bookmark"/>
6730
6933
  </fo:bookmark>
@@ -6750,6 +6953,12 @@
6750
6953
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
6751
6954
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
6752
6955
 
6956
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
6957
+ <fo:block text-align="right" keep-with-next="always">
6958
+ <xsl:apply-templates/>
6959
+ </fo:block>
6960
+ </xsl:template>
6961
+
6753
6962
  <!-- ====== -->
6754
6963
  <!-- ====== -->
6755
6964
  <xsl:template match="*[local-name() = 'title']" mode="contents_item">
@@ -6899,6 +7108,10 @@
6899
7108
  </xsl:for-each>
6900
7109
  </xsl:template>
6901
7110
 
7111
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
7112
+ <xsl:value-of select="."/>
7113
+ </xsl:template>
7114
+
6902
7115
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
6903
7116
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
6904
7117
  <xsl:apply-templates mode="contents_item"/>
@@ -8397,9 +8610,47 @@
8397
8610
 
8398
8611
  <fo:list-block xsl:use-attribute-sets="list-style">
8399
8612
 
8400
- <xsl:if test="local-name() = 'ol'">
8401
- <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8613
+ <xsl:variable name="provisional_distance_between_starts_">
8614
+ <attributes xsl:use-attribute-sets="list-style">
8615
+
8616
+ <xsl:if test="local-name() = 'ol'">
8617
+ <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8618
+ </xsl:if>
8619
+
8620
+ </attributes>
8621
+ </xsl:variable>
8622
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8623
+ <xsl:if test="$provisional_distance_between_starts != ''">
8624
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8625
+ </xsl:if>
8626
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8627
+
8628
+ <!-- increase provisional-distance-between-starts for long lists -->
8629
+ <xsl:if test="local-name() = 'ol'">
8630
+ <!-- Examples: xiii), xviii), xxviii) -->
8631
+ <xsl:variable name="item_numbers">
8632
+ <xsl:for-each select="*[local-name() = 'li']">
8633
+ <item><xsl:call-template name="getListItemFormat"/></item>
8634
+ </xsl:for-each>
8635
+ </xsl:variable>
8636
+
8637
+ <xsl:variable name="max_length">
8638
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8639
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8640
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8641
+ </xsl:for-each>
8642
+ </xsl:variable>
8643
+
8644
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8645
+ <xsl:variable name="addon" select="$max_length - 4"/>
8646
+ <xsl:if test="$addon &gt; 0">
8647
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8402
8648
  </xsl:if>
8649
+ <!-- DEBUG -->
8650
+ <!-- <xsl:copy-of select="$item_numbers"/>
8651
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8652
+ <addon><xsl:value-of select="$addon"/></addon> -->
8653
+ </xsl:if>
8403
8654
 
8404
8655
  <xsl:if test="*[local-name() = 'name']">
8405
8656
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9337,7 +9588,7 @@
9337
9588
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9338
9589
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9339
9590
  <!-- add &lt; and &gt; to \S -->
9340
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9591
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9341
9592
  <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
9342
9593
  <xsl:variable name="text3">
9343
9594
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9359,7 +9610,8 @@
9359
9610
  <xsl:choose>
9360
9611
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9361
9612
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9362
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9613
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9614
+ <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
9363
9615
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9364
9616
  <xsl:choose>
9365
9617
  <xsl:when test="self::text()">
@@ -9962,6 +10214,23 @@
9962
10214
  </xsl:if>
9963
10215
  </xsl:template>
9964
10216
 
10217
+ <xsl:template name="setBlockAttributes">
10218
+ <xsl:param name="text_align_default">left</xsl:param>
10219
+ <xsl:call-template name="setTextAlignment">
10220
+ <xsl:with-param name="default" select="$text_align_default"/>
10221
+ </xsl:call-template>
10222
+
10223
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10224
+ <!-- Example: keep-lines-together="true" -->
10225
+ <xsl:if test="@keep-lines-together = 'true'">
10226
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10227
+ </xsl:if>
10228
+ <!-- Example: keep-with-next="true" -->
10229
+ <xsl:if test="@keep-with-next = 'true'">
10230
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10231
+ </xsl:if>
10232
+ </xsl:template>
10233
+
9965
10234
  <xsl:template name="number-to-words">
9966
10235
  <xsl:param name="number"/>
9967
10236
  <xsl:param name="first"/>