metanorma-un 0.10.3 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1389,21 +1389,21 @@
1389
1389
 
1390
1390
  <xsl:attribute-set name="table-header-cell-style">
1391
1391
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1392
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1393
1392
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1394
1393
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1395
1394
  <xsl:attribute name="display-align">center</xsl:attribute>
1396
1395
 
1396
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1397
1397
  <xsl:attribute name="text-indent">0mm</xsl:attribute>
1398
1398
 
1399
1399
  </xsl:attribute-set> <!-- table-header-cell-style -->
1400
1400
 
1401
1401
  <xsl:attribute-set name="table-cell-style">
1402
1402
  <xsl:attribute name="display-align">center</xsl:attribute>
1403
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1404
1403
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1405
1404
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1406
1405
 
1406
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1407
1407
  <xsl:attribute name="text-indent">0mm</xsl:attribute>
1408
1408
 
1409
1409
  </xsl:attribute-set> <!-- table-cell-style -->
@@ -2121,7 +2121,7 @@
2121
2121
  <xsl:apply-templates select="." mode="contents"/>
2122
2122
  </xsl:for-each>
2123
2123
 
2124
- <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')]]">
2124
+ <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]">
2125
2125
  <xsl:sort select="@displayorder" data-type="number"/>
2126
2126
  <xsl:apply-templates select="." mode="contents"/>
2127
2127
  </xsl:for-each>
@@ -2456,6 +2456,7 @@
2456
2456
  <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) -->
2457
2457
 
2458
2458
  <xsl:choose>
2459
+ <xsl:when test="@width = 'full-page-width' or @width = 'text-width'">100%</xsl:when>
2459
2460
  <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
2460
2461
  <xsl:otherwise><xsl:value-of select="$table_width_default"/></xsl:otherwise>
2461
2462
  </xsl:choose>
@@ -2582,7 +2583,7 @@
2582
2583
  <xsl:variable name="isDeleted" select="@deleted"/>
2583
2584
 
2584
2585
  <xsl:choose>
2585
- <xsl:when test="@width">
2586
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
2586
2587
 
2587
2588
  <!-- centered table when table name is centered (see table-name-style) -->
2588
2589
 
@@ -2904,6 +2905,7 @@
2904
2905
  This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
2905
2906
  <xsl:when test="(@width_max &gt; $page_width and @width_min &lt; $page_width) or (@width_min &gt;= $page_width)">
2906
2907
  <!-- difference between the available space and the minimum table width -->
2908
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
2907
2909
  <xsl:variable name="W" select="$page_width - @width_min"/>
2908
2910
  <W><xsl:value-of select="$W"/></W>
2909
2911
  <!-- difference between maximum and minimum width of the table -->
@@ -3067,6 +3069,10 @@
3067
3069
  </xsl:choose>
3068
3070
  </xsl:variable>
3069
3071
 
3072
+ <xsl:variable name="table_fn_block">
3073
+ <xsl:call-template name="table_fn_display"/>
3074
+ </xsl:variable>
3075
+
3070
3076
  <xsl:variable name="tableWithNotesAndFootnotes">
3071
3077
 
3072
3078
  <fo:table keep-with-previous="always">
@@ -3114,11 +3120,25 @@
3114
3120
 
3115
3121
  <xsl:apply-templates select="../*[local-name()='note']"/>
3116
3122
 
3123
+ <xsl:variable name="isDisplayRowSeparator">
3124
+
3125
+ </xsl:variable>
3126
+
3117
3127
  <!-- horizontal row separator -->
3128
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3129
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3130
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3131
+
3132
+ <xsl:call-template name="setBordersTableArray"/>
3133
+ <fo:block font-size="1pt"> </fo:block>
3134
+ </fo:block-container>
3135
+ </xsl:if>
3136
+ </xsl:if>
3118
3137
 
3119
3138
  <!-- fn processing -->
3120
3139
 
3121
- <xsl:call-template name="table_fn_display"/>
3140
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3141
+ <xsl:copy-of select="$table_fn_block"/>
3122
3142
 
3123
3143
  <!-- for PAS display Notes after footnotes -->
3124
3144
 
@@ -3235,6 +3255,28 @@
3235
3255
  </fo:table-row>
3236
3256
  </xsl:template>
3237
3257
 
3258
+ <xsl:template name="setBorderUnderRow">
3259
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3260
+ <xsl:choose>
3261
+ <xsl:when test="$border_under_row_ != ''">
3262
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3263
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3264
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3265
+ <xsl:variable name="border_under_row">
3266
+ <xsl:call-template name="split">
3267
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3268
+ </xsl:call-template>
3269
+ </xsl:variable>
3270
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3271
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3272
+ </xsl:if>
3273
+ </xsl:when>
3274
+ <xsl:otherwise>
3275
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3276
+ </xsl:otherwise>
3277
+ </xsl:choose>
3278
+ </xsl:template>
3279
+
3238
3280
  <!-- row in table footer (tfoot) -->
3239
3281
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3240
3282
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -3545,17 +3587,20 @@
3545
3587
  <xsl:for-each select="xalan:nodeset($references)//fn">
3546
3588
  <xsl:variable name="reference" select="@reference"/>
3547
3589
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3548
- <fo:block xsl:use-attribute-sets="table-fn-style">
3549
3590
 
3550
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3591
+ <fo:block xsl:use-attribute-sets="table-fn-style">
3551
3592
 
3552
- <xsl:value-of select="@reference"/>
3593
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3594
+
3595
+ <xsl:value-of select="@reference"/>
3596
+
3597
+ </fo:inline>
3598
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3599
+ <xsl:copy-of select="./node()"/>
3600
+ </fo:inline>
3601
+
3602
+ </fo:block>
3553
3603
 
3554
- </fo:inline>
3555
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3556
- <xsl:copy-of select="./node()"/>
3557
- </fo:inline>
3558
- </fo:block>
3559
3604
  </xsl:if>
3560
3605
  </xsl:for-each>
3561
3606
  </xsl:template>
@@ -3584,8 +3629,16 @@
3584
3629
  <!-- figure's footnotes rendering -->
3585
3630
  <xsl:template name="fn_display_figure">
3586
3631
 
3632
+ <!-- current figure id -->
3633
+ <xsl:variable name="figure_id_">
3634
+ <xsl:value-of select="@id"/>
3635
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3636
+ </xsl:variable>
3637
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3638
+
3639
+ <!-- all footnotes relates to the current figure -->
3587
3640
  <xsl:variable name="references">
3588
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3641
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3589
3642
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3590
3643
  <xsl:apply-templates/>
3591
3644
  </fn>
@@ -3598,91 +3651,93 @@
3598
3651
 
3599
3652
  </xsl:variable>
3600
3653
 
3601
- <!-- current hierarchy is 'figure' element -->
3602
- <xsl:variable name="following_dl_colwidths">
3603
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3604
- <xsl:variable name="simple-table">
3605
- <!-- <xsl:variable name="doc_ns">
3606
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3654
+ <fo:block>
3655
+
3656
+ <!-- current hierarchy is 'figure' element -->
3657
+ <xsl:variable name="following_dl_colwidths">
3658
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3659
+ <xsl:variable name="simple-table">
3660
+ <!-- <xsl:variable name="doc_ns">
3661
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3662
+ </xsl:variable>
3663
+ <xsl:variable name="ns">
3664
+ <xsl:choose>
3665
+ <xsl:when test="normalize-space($doc_ns) != ''">
3666
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3667
+ </xsl:when>
3668
+ <xsl:otherwise>
3669
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3670
+ </xsl:otherwise>
3671
+ </xsl:choose>
3672
+ </xsl:variable> -->
3673
+
3674
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3675
+ <tbody>
3676
+ <xsl:apply-templates mode="dl"/>
3677
+ </tbody>
3678
+ </xsl:for-each>
3679
+ </xsl:variable>
3680
+
3681
+ <xsl:call-template name="calculate-column-widths">
3682
+ <xsl:with-param name="cols-count" select="2"/>
3683
+ <xsl:with-param name="table" select="$simple-table"/>
3684
+ </xsl:call-template>
3685
+
3686
+ </xsl:if>
3607
3687
  </xsl:variable>
3608
- <xsl:variable name="ns">
3688
+
3689
+ <xsl:variable name="maxlength_dt">
3690
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3691
+ <xsl:call-template name="getMaxLength_dt"/>
3692
+ </xsl:for-each>
3693
+ </xsl:variable>
3694
+
3695
+ <fo:table width="95%" table-layout="fixed">
3696
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3697
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3698
+
3699
+ </xsl:if>
3609
3700
  <xsl:choose>
3610
- <xsl:when test="normalize-space($doc_ns) != ''">
3611
- <xsl:value-of select="normalize-space($doc_ns)"/>
3701
+ <!-- if there 'dl', then set same columns width -->
3702
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3703
+ <xsl:call-template name="setColumnWidth_dl">
3704
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3705
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3706
+ </xsl:call-template>
3612
3707
  </xsl:when>
3613
3708
  <xsl:otherwise>
3614
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3709
+ <fo:table-column column-width="5%"/>
3710
+ <fo:table-column column-width="95%"/>
3615
3711
  </xsl:otherwise>
3616
3712
  </xsl:choose>
3617
- </xsl:variable> -->
3618
-
3619
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3620
- <tbody>
3621
- <xsl:apply-templates mode="dl"/>
3622
- </tbody>
3623
- </xsl:for-each>
3624
- </xsl:variable>
3625
-
3626
- <xsl:call-template name="calculate-column-widths">
3627
- <xsl:with-param name="cols-count" select="2"/>
3628
- <xsl:with-param name="table" select="$simple-table"/>
3629
- </xsl:call-template>
3630
-
3631
- </xsl:if>
3632
- </xsl:variable>
3633
-
3634
- <xsl:variable name="maxlength_dt">
3635
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3636
- <xsl:call-template name="getMaxLength_dt"/>
3637
- </xsl:for-each>
3638
- </xsl:variable>
3713
+ <fo:table-body>
3714
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3715
+ <xsl:variable name="reference" select="@reference"/>
3716
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3717
+ <fo:table-row>
3718
+ <fo:table-cell>
3719
+ <fo:block>
3720
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3721
+ <xsl:value-of select="@reference"/>
3722
+ </fo:inline>
3723
+ </fo:block>
3724
+ </fo:table-cell>
3725
+ <fo:table-cell>
3726
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3727
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3639
3728
 
3640
- <fo:block>
3641
- <fo:table width="95%" table-layout="fixed">
3642
- <xsl:if test="normalize-space($key_iso) = 'true'">
3643
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3729
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3644
3730
 
3645
- </xsl:if>
3646
- <xsl:choose>
3647
- <!-- if there 'dl', then set same columns width -->
3648
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3649
- <xsl:call-template name="setColumnWidth_dl">
3650
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3651
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3652
- </xsl:call-template>
3653
- </xsl:when>
3654
- <xsl:otherwise>
3655
- <fo:table-column column-width="15%"/>
3656
- <fo:table-column column-width="85%"/>
3657
- </xsl:otherwise>
3658
- </xsl:choose>
3659
- <fo:table-body>
3660
- <xsl:for-each select="xalan:nodeset($references)//fn">
3661
- <xsl:variable name="reference" select="@reference"/>
3662
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3663
- <fo:table-row>
3664
- <fo:table-cell>
3665
- <fo:block>
3666
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3667
- <xsl:value-of select="@reference"/>
3668
- </fo:inline>
3669
- </fo:block>
3670
- </fo:table-cell>
3671
- <fo:table-cell>
3672
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3673
- <xsl:if test="normalize-space($key_iso) = 'true'">
3674
-
3675
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3731
+ </xsl:if>
3732
+ <xsl:copy-of select="./node()"/>
3733
+ </fo:block>
3734
+ </fo:table-cell>
3735
+ </fo:table-row>
3736
+ </xsl:if>
3737
+ </xsl:for-each>
3738
+ </fo:table-body>
3739
+ </fo:table>
3676
3740
 
3677
- </xsl:if>
3678
- <xsl:copy-of select="./node()"/>
3679
- </fo:block>
3680
- </fo:table-cell>
3681
- </fo:table-row>
3682
- </xsl:if>
3683
- </xsl:for-each>
3684
- </fo:table-body>
3685
- </fo:table>
3686
3741
  </fo:block>
3687
3742
  </xsl:if>
3688
3743
 
@@ -3758,12 +3813,14 @@
3758
3813
 
3759
3814
  <fo:block margin-bottom="12pt" text-align="left">
3760
3815
 
3761
- <xsl:variable name="title-where">
3816
+ <!-- <xsl:variable name="title-where">
3762
3817
  <xsl:call-template name="getLocalizedString">
3763
3818
  <xsl:with-param name="key">where</xsl:with-param>
3764
3819
  </xsl:call-template>
3765
3820
  </xsl:variable>
3766
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3821
+ <xsl:value-of select="$title-where"/> -->
3822
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3823
+ <xsl:text> </xsl:text>
3767
3824
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3768
3825
  <xsl:text/>
3769
3826
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3773,12 +3830,14 @@
3773
3830
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3774
3831
  <fo:block margin-bottom="12pt" text-align="left">
3775
3832
 
3776
- <xsl:variable name="title-where">
3833
+ <!-- <xsl:variable name="title-where">
3777
3834
  <xsl:call-template name="getLocalizedString">
3778
3835
  <xsl:with-param name="key">where</xsl:with-param>
3779
3836
  </xsl:call-template>
3780
3837
  </xsl:variable>
3781
- <xsl:value-of select="$title-where"/>
3838
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3839
+ <!-- preceding 'p' with word 'where' -->
3840
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3782
3841
  </fo:block>
3783
3842
  </xsl:when> <!-- END: a few components -->
3784
3843
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3961,6 +4020,9 @@
3961
4020
 
3962
4021
  </xsl:template> <!-- END: dl -->
3963
4022
 
4023
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
4024
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
4025
+
3964
4026
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3965
4027
  <xsl:param name="process">false</xsl:param>
3966
4028
  <xsl:if test="$process = 'true'">
@@ -4491,12 +4553,12 @@
4491
4553
  <xsl:param name="value"/>
4492
4554
  <xsl:variable name="add_width" select="string-length($value) * 20"/>
4493
4555
  <xsl:variable name="maxwidth" select="60 + $add_width"/>
4494
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
4495
- <xsl:attribute name="height">5mm</xsl:attribute>
4556
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
4557
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
4496
4558
  <xsl:attribute name="content-width">100%</xsl:attribute>
4497
4559
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4498
4560
  <xsl:attribute name="scaling">uniform</xsl:attribute>
4499
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4561
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4500
4562
  <g>
4501
4563
  <xsl:if test="$type = 'closing' or $type = 'end'">
4502
4564
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
@@ -4510,6 +4572,27 @@
4510
4572
  </xsl:if>
4511
4573
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
4512
4574
  </text>
4575
+ </svg> -->
4576
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4577
+ <g>
4578
+ <xsl:if test="$type = 'closing' or $type = 'end'">
4579
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
4580
+ </xsl:if>
4581
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
4582
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
4583
+ </g>
4584
+ <xsl:variable name="text_x">
4585
+ <xsl:choose>
4586
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
4587
+ <xsl:otherwise>22</xsl:otherwise>
4588
+ </xsl:choose>
4589
+ </xsl:variable>
4590
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
4591
+ <xsl:value-of select="$kind"/>
4592
+ </text>
4593
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
4594
+ <xsl:value-of select="$value"/>
4595
+ </text>
4513
4596
  </svg>
4514
4597
  </fo:instream-foreign-object>
4515
4598
  </xsl:template>
@@ -4764,18 +4847,34 @@
4764
4847
 
4765
4848
  <xsl:template name="add-zero-spaces-java">
4766
4849
  <xsl:param name="text" select="."/>
4767
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
4768
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
4850
+
4851
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
4852
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4853
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4854
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4855
+ <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4856
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4769
4857
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4770
- <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' -->
4858
+ <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' -->
4771
4859
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4772
- <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' -->
4860
+ <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' -->
4773
4861
  <!-- add zero-width space (#x200B) before character: { -->
4774
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4862
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4775
4863
  <!-- add zero-width space (#x200B) after character: , -->
4776
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4864
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4865
+ <!-- add zero-width space (#x200B) after character: '/' -->
4866
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4867
+
4868
+ <xsl:variable name="text9">
4869
+ <xsl:choose>
4870
+ <xsl:when test="$isGenerateTableIF = 'true'">
4871
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4872
+ </xsl:when>
4873
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4874
+ </xsl:choose>
4875
+ </xsl:variable>
4777
4876
 
4778
- <xsl:value-of select="$text5"/>
4877
+ <xsl:value-of select="$text9"/>
4779
4878
  </xsl:template>
4780
4879
 
4781
4880
  <xsl:template name="add-zero-spaces-link-java">
@@ -4783,8 +4882,10 @@
4783
4882
 
4784
4883
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4785
4884
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4786
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4787
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
4885
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
4886
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
4887
+ <!-- remove zero-width space at the end -->
4888
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4788
4889
  </xsl:template>
4789
4890
 
4790
4891
  <!-- add zero space after dash character (for table's entries) -->
@@ -4921,7 +5022,7 @@
4921
5022
  </xsl:copy>
4922
5023
  </xsl:template>
4923
5024
 
4924
- <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">
5025
+ <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">
4925
5026
  <xsl:copy>
4926
5027
  <xsl:copy-of select="@*"/>
4927
5028
  <p>
@@ -4997,6 +5098,14 @@
4997
5098
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
4998
5099
  </xsl:template>
4999
5100
 
5101
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" mode="table-without-br">
5102
+ <xsl:apply-templates mode="table-without-br"/>
5103
+ </xsl:template>
5104
+
5105
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'li']" mode="table-without-br">
5106
+ <xsl:apply-templates mode="table-without-br"/>
5107
+ </xsl:template>
5108
+
5000
5109
  <!-- mode="table-without-br" -->
5001
5110
  <!-- ================================== -->
5002
5111
  <!-- END: Step 0. replace <br/> to <p>...</p> -->
@@ -5129,9 +5238,28 @@
5129
5238
  </xsl:variable>
5130
5239
  <xsl:copy-of select="$newRow"/>
5131
5240
 
5132
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5133
- <xsl:with-param name="previousRow" select="$newRow"/>
5134
- </xsl:apply-templates>
5241
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5242
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5243
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5244
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5245
+ <xsl:choose>
5246
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5247
+ <xsl:copy-of select="following-sibling::tr"/>
5248
+ </xsl:when>
5249
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5250
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5251
+
5252
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5253
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5254
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5255
+ </xsl:apply-templates>
5256
+ </xsl:when> -->
5257
+ <xsl:otherwise>
5258
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5259
+ <xsl:with-param name="previousRow" select="$newRow"/>
5260
+ </xsl:apply-templates>
5261
+ </xsl:otherwise>
5262
+ </xsl:choose>
5135
5263
  </xsl:template>
5136
5264
  <!-- End mode simple-table-rowspan -->
5137
5265
 
@@ -5294,6 +5422,27 @@
5294
5422
  </xsl:call-template>
5295
5423
  </xsl:template>
5296
5424
 
5425
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5426
+ <xsl:variable name="link">
5427
+ <link_updated>
5428
+ <xsl:variable name="target_text">
5429
+ <xsl:choose>
5430
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5431
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5432
+ </xsl:when>
5433
+ <xsl:otherwise>
5434
+ <xsl:value-of select="normalize-space(@target)"/>
5435
+ </xsl:otherwise>
5436
+ </xsl:choose>
5437
+ </xsl:variable>
5438
+ <xsl:value-of select="$target_text"/>
5439
+ </link_updated>
5440
+ </xsl:variable>
5441
+ <xsl:for-each select="xalan:nodeset($link)/*">
5442
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5443
+ </xsl:for-each>
5444
+ </xsl:template>
5445
+
5297
5446
  <xsl:template name="getFormattingTags">
5298
5447
  <tags>
5299
5448
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5635,7 +5784,7 @@
5635
5784
  </xsl:variable>
5636
5785
  <fo:inline xsl:use-attribute-sets="link-style">
5637
5786
 
5638
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5787
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5639
5788
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5640
5789
  </xsl:if>
5641
5790
 
@@ -5819,7 +5968,7 @@
5819
5968
  <xsl:attribute name="border-top">0pt solid black</xsl:attribute>
5820
5969
  </xsl:if>
5821
5970
 
5822
- <fo:block-container margin-left="0mm">
5971
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5823
5972
 
5824
5973
  <fo:block>
5825
5974
 
@@ -6006,13 +6155,16 @@
6006
6155
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
6007
6156
  </xsl:call-template>
6008
6157
 
6158
+ <!-- Example: Dimensions in millimeters -->
6159
+ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/>
6160
+
6009
6161
  <fo:block xsl:use-attribute-sets="figure-style">
6010
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
6162
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
6011
6163
  </fo:block>
6012
- <xsl:call-template name="fn_display_figure"/>
6013
- <xsl:for-each select="*[local-name() = 'note']">
6164
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
6014
6165
  <xsl:call-template name="note"/>
6015
6166
  </xsl:for-each>
6167
+ <xsl:call-template name="fn_display_figure"/>
6016
6168
 
6017
6169
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
6018
6170
 
@@ -6080,7 +6232,13 @@
6080
6232
  </xsl:choose>
6081
6233
  </xsl:variable>
6082
6234
 
6083
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6235
+ <xsl:variable name="image_width_effective">
6236
+
6237
+ <xsl:value-of select="$width_effective"/>
6238
+
6239
+ </xsl:variable>
6240
+
6241
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6084
6242
  <xsl:if test="number($scale) &lt; 100">
6085
6243
 
6086
6244
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -6272,24 +6430,47 @@
6272
6430
 
6273
6431
  </xsl:when>
6274
6432
  <xsl:otherwise>
6275
- <fo:block xsl:use-attribute-sets="image-style">
6276
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6277
- <xsl:attribute name="width">100%</xsl:attribute>
6278
- <xsl:attribute name="content-height">100%</xsl:attribute>
6279
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6280
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6281
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6282
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6283
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6284
- <!-- effective height / width = 1.48, 1.4 - with title -->
6285
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6286
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6287
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6288
- </xsl:if>
6289
- <xsl:attribute name="scaling">uniform</xsl:attribute>
6290
- <xsl:copy-of select="$svg_content"/>
6291
- </fo:instream-foreign-object>
6292
- </fo:block>
6433
+
6434
+ <xsl:variable name="element">
6435
+ <xsl:choose>
6436
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
6437
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
6438
+ </xsl:when>
6439
+ <xsl:otherwise>
6440
+ <fo:block xsl:use-attribute-sets="image-style">
6441
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
6442
+ <xsl:attribute name="text-align">left</xsl:attribute>
6443
+ </xsl:if>
6444
+ </fo:block>
6445
+ </xsl:otherwise>
6446
+ </xsl:choose>
6447
+ </xsl:variable>
6448
+
6449
+ <xsl:for-each select="xalan:nodeset($element)/*">
6450
+ <xsl:copy>
6451
+ <xsl:copy-of select="@*"/>
6452
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
6453
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6454
+ <xsl:if test="$isGenerateTableIF = 'false'">
6455
+ <xsl:attribute name="width">100%</xsl:attribute>
6456
+ </xsl:if>
6457
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6458
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6459
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6460
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6461
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6462
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6463
+ <!-- effective height / width = 1.48, 1.4 - with title -->
6464
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6465
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6466
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6467
+ </xsl:if>
6468
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6469
+ <xsl:copy-of select="$svg_content"/>
6470
+ </fo:instream-foreign-object>
6471
+ <!-- </fo:block> -->
6472
+ </xsl:copy>
6473
+ </xsl:for-each>
6293
6474
  </xsl:otherwise>
6294
6475
  </xsl:choose>
6295
6476
  </xsl:template>
@@ -6381,6 +6562,13 @@
6381
6562
  </xsl:for-each>
6382
6563
  </xsl:template>
6383
6564
 
6565
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
6566
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
6567
+ <xsl:for-each select="*[local-name() = 'svg']">
6568
+ <xsl:call-template name="image_svg"/>
6569
+ </xsl:for-each>
6570
+ </xsl:template>
6571
+
6384
6572
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
6385
6573
  <xsl:variable name="svg_content" select="document(@src)"/>
6386
6574
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -6519,6 +6707,8 @@
6519
6707
  <xsl:value-of select="."/>
6520
6708
  </xsl:template>
6521
6709
 
6710
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
6711
+
6522
6712
  <xsl:template match="node()" mode="contents">
6523
6713
  <xsl:apply-templates mode="contents"/>
6524
6714
  </xsl:template>
@@ -6635,6 +6825,13 @@
6635
6825
  <xsl:when test="$contents_nodes/doc">
6636
6826
  <xsl:choose>
6637
6827
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6828
+
6829
+ <xsl:if test="$contents_nodes/collection">
6830
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6831
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6832
+ </fo:bookmark>
6833
+ </xsl:if>
6834
+
6638
6835
  <xsl:for-each select="$contents_nodes/doc">
6639
6836
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6640
6837
  <xsl:if test="@bundle = 'true'">
@@ -6826,7 +7023,15 @@
6826
7023
  <xsl:value-of select="@section"/>
6827
7024
  <xsl:text> </xsl:text>
6828
7025
  </xsl:if>
6829
- <xsl:value-of select="normalize-space(title)"/>
7026
+ <xsl:variable name="title">
7027
+ <xsl:for-each select="title/node()">
7028
+ <xsl:choose>
7029
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
7030
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7031
+ </xsl:choose>
7032
+ </xsl:for-each>
7033
+ </xsl:variable>
7034
+ <xsl:value-of select="normalize-space($title)"/>
6830
7035
  </fo:bookmark-title>
6831
7036
  <xsl:apply-templates mode="bookmark"/>
6832
7037
  </fo:bookmark>
@@ -6852,6 +7057,12 @@
6852
7057
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
6853
7058
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
6854
7059
 
7060
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
7061
+ <fo:block text-align="right" keep-with-next="always">
7062
+ <xsl:apply-templates/>
7063
+ </fo:block>
7064
+ </xsl:template>
7065
+
6855
7066
  <!-- ====== -->
6856
7067
  <!-- ====== -->
6857
7068
  <xsl:template match="*[local-name() = 'title']" mode="contents_item">
@@ -7001,6 +7212,10 @@
7001
7212
  </xsl:for-each>
7002
7213
  </xsl:template>
7003
7214
 
7215
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
7216
+ <xsl:value-of select="."/>
7217
+ </xsl:template>
7218
+
7004
7219
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
7005
7220
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
7006
7221
  <xsl:apply-templates mode="contents_item"/>
@@ -8499,9 +8714,47 @@
8499
8714
 
8500
8715
  <fo:list-block xsl:use-attribute-sets="list-style">
8501
8716
 
8502
- <xsl:if test="local-name() = 'ol'">
8503
- <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8717
+ <xsl:variable name="provisional_distance_between_starts_">
8718
+ <attributes xsl:use-attribute-sets="list-style">
8719
+
8720
+ <xsl:if test="local-name() = 'ol'">
8721
+ <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8722
+ </xsl:if>
8723
+
8724
+ </attributes>
8725
+ </xsl:variable>
8726
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8727
+ <xsl:if test="$provisional_distance_between_starts != ''">
8728
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8729
+ </xsl:if>
8730
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8731
+
8732
+ <!-- increase provisional-distance-between-starts for long lists -->
8733
+ <xsl:if test="local-name() = 'ol'">
8734
+ <!-- Examples: xiii), xviii), xxviii) -->
8735
+ <xsl:variable name="item_numbers">
8736
+ <xsl:for-each select="*[local-name() = 'li']">
8737
+ <item><xsl:call-template name="getListItemFormat"/></item>
8738
+ </xsl:for-each>
8739
+ </xsl:variable>
8740
+
8741
+ <xsl:variable name="max_length">
8742
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8743
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8744
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8745
+ </xsl:for-each>
8746
+ </xsl:variable>
8747
+
8748
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8749
+ <xsl:variable name="addon" select="$max_length - 4"/>
8750
+ <xsl:if test="$addon &gt; 0">
8751
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8504
8752
  </xsl:if>
8753
+ <!-- DEBUG -->
8754
+ <!-- <xsl:copy-of select="$item_numbers"/>
8755
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8756
+ <addon><xsl:value-of select="$addon"/></addon> -->
8757
+ </xsl:if>
8505
8758
 
8506
8759
  <xsl:if test="*[local-name() = 'name']">
8507
8760
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9440,7 +9693,7 @@
9440
9693
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9441
9694
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9442
9695
  <!-- add &lt; and &gt; to \S -->
9443
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9696
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9444
9697
  <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>
9445
9698
  <xsl:variable name="text3">
9446
9699
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9462,7 +9715,8 @@
9462
9715
  <xsl:choose>
9463
9716
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9464
9717
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9465
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9718
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9719
+ <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>
9466
9720
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9467
9721
  <xsl:choose>
9468
9722
  <xsl:when test="self::text()">
@@ -10065,6 +10319,23 @@
10065
10319
  </xsl:if>
10066
10320
  </xsl:template>
10067
10321
 
10322
+ <xsl:template name="setBlockAttributes">
10323
+ <xsl:param name="text_align_default">left</xsl:param>
10324
+ <xsl:call-template name="setTextAlignment">
10325
+ <xsl:with-param name="default" select="$text_align_default"/>
10326
+ </xsl:call-template>
10327
+
10328
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10329
+ <!-- Example: keep-lines-together="true" -->
10330
+ <xsl:if test="@keep-lines-together = 'true'">
10331
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10332
+ </xsl:if>
10333
+ <!-- Example: keep-with-next="true" -->
10334
+ <xsl:if test="@keep-with-next = 'true'">
10335
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10336
+ </xsl:if>
10337
+ </xsl:template>
10338
+
10068
10339
  <xsl:template name="number-to-words">
10069
10340
  <xsl:param name="number"/>
10070
10341
  <xsl:param name="first"/>