metanorma-iho 0.7.4 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -357,6 +357,7 @@
357
357
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='definitions']"/>
358
358
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope')]"/>
359
359
 
360
+ <xsl:if test="$table_if = 'true'"><fo:block/></xsl:if>
360
361
  </fo:block-container>
361
362
  </fo:flow>
362
363
  </fo:page-sequence>
@@ -373,6 +374,8 @@
373
374
  <fo:flow flow-name="xsl-region-body">
374
375
  <fo:block-container>
375
376
  <xsl:apply-templates select="/*/*[local-name()='annex']"/>
377
+
378
+ <xsl:if test="$table_if = 'true'"><fo:block/></xsl:if>
376
379
  </fo:block-container>
377
380
  </fo:flow>
378
381
  </fo:page-sequence>
@@ -390,6 +393,8 @@
390
393
  <fo:block-container>
391
394
  <!-- Bibliography -->
392
395
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]"/>
396
+
397
+ <xsl:if test="$table_if = 'true'"><fo:block/></xsl:if>
393
398
  </fo:block-container>
394
399
  </fo:flow>
395
400
  </fo:page-sequence>
@@ -1427,7 +1432,6 @@
1427
1432
 
1428
1433
  <xsl:attribute-set name="table-header-cell-style">
1429
1434
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1430
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1431
1435
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1432
1436
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1433
1437
  <xsl:attribute name="display-align">center</xsl:attribute>
@@ -1442,7 +1446,6 @@
1442
1446
 
1443
1447
  <xsl:attribute-set name="table-cell-style">
1444
1448
  <xsl:attribute name="display-align">center</xsl:attribute>
1445
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1446
1449
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1447
1450
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1448
1451
 
@@ -2200,7 +2203,7 @@
2200
2203
  <xsl:apply-templates select="." mode="contents"/>
2201
2204
  </xsl:for-each>
2202
2205
 
2203
- <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')]]">
2206
+ <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]">
2204
2207
  <xsl:sort select="@displayorder" data-type="number"/>
2205
2208
  <xsl:apply-templates select="." mode="contents"/>
2206
2209
  </xsl:for-each>
@@ -2639,7 +2642,7 @@
2639
2642
  <xsl:variable name="isDeleted" select="@deleted"/>
2640
2643
 
2641
2644
  <xsl:choose>
2642
- <xsl:when test="@width">
2645
+ <xsl:when test="@width and @width != 'full-page-width' and @width != 'text-width'">
2643
2646
 
2644
2647
  <!-- centered table when table name is centered (see table-name-style) -->
2645
2648
 
@@ -2964,6 +2967,7 @@
2964
2967
  This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
2965
2968
  <xsl:when test="(@width_max &gt; $page_width and @width_min &lt; $page_width) or (@width_min &gt;= $page_width)">
2966
2969
  <!-- difference between the available space and the minimum table width -->
2970
+ <_width_min><xsl:value-of select="@width_min"/></_width_min>
2967
2971
  <xsl:variable name="W" select="$page_width - @width_min"/>
2968
2972
  <W><xsl:value-of select="$W"/></W>
2969
2973
  <!-- difference between maximum and minimum width of the table -->
@@ -3127,6 +3131,10 @@
3127
3131
  </xsl:choose>
3128
3132
  </xsl:variable>
3129
3133
 
3134
+ <xsl:variable name="table_fn_block">
3135
+ <xsl:call-template name="table_fn_display"/>
3136
+ </xsl:variable>
3137
+
3130
3138
  <xsl:variable name="tableWithNotesAndFootnotes">
3131
3139
 
3132
3140
  <fo:table keep-with-previous="always">
@@ -3174,11 +3182,25 @@
3174
3182
 
3175
3183
  <xsl:apply-templates select="../*[local-name()='note']"/>
3176
3184
 
3185
+ <xsl:variable name="isDisplayRowSeparator">
3186
+
3187
+ </xsl:variable>
3188
+
3177
3189
  <!-- horizontal row separator -->
3190
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3191
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3192
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3193
+
3194
+ <xsl:call-template name="setBordersTableArray"/>
3195
+ <fo:block font-size="1pt"> </fo:block>
3196
+ </fo:block-container>
3197
+ </xsl:if>
3198
+ </xsl:if>
3178
3199
 
3179
3200
  <!-- fn processing -->
3180
3201
 
3181
- <xsl:call-template name="table_fn_display"/>
3202
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3203
+ <xsl:copy-of select="$table_fn_block"/>
3182
3204
 
3183
3205
  <!-- for PAS display Notes after footnotes -->
3184
3206
 
@@ -3295,6 +3317,28 @@
3295
3317
  </fo:table-row>
3296
3318
  </xsl:template>
3297
3319
 
3320
+ <xsl:template name="setBorderUnderRow">
3321
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3322
+ <xsl:choose>
3323
+ <xsl:when test="$border_under_row_ != ''">
3324
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3325
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3326
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3327
+ <xsl:variable name="border_under_row">
3328
+ <xsl:call-template name="split">
3329
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3330
+ </xsl:call-template>
3331
+ </xsl:variable>
3332
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3333
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3334
+ </xsl:if>
3335
+ </xsl:when>
3336
+ <xsl:otherwise>
3337
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3338
+ </xsl:otherwise>
3339
+ </xsl:choose>
3340
+ </xsl:template>
3341
+
3298
3342
  <!-- row in table footer (tfoot) -->
3299
3343
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3300
3344
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -3581,17 +3625,20 @@
3581
3625
  <xsl:for-each select="xalan:nodeset($references)//fn">
3582
3626
  <xsl:variable name="reference" select="@reference"/>
3583
3627
  <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3584
- <fo:block xsl:use-attribute-sets="table-fn-style">
3585
3628
 
3586
- <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3629
+ <fo:block xsl:use-attribute-sets="table-fn-style">
3587
3630
 
3588
- <xsl:value-of select="@reference"/>
3631
+ <fo:inline id="{@id}" xsl:use-attribute-sets="table-fn-number-style">
3632
+
3633
+ <xsl:value-of select="@reference"/>
3634
+
3635
+ </fo:inline>
3636
+ <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3637
+ <xsl:copy-of select="./node()"/>
3638
+ </fo:inline>
3639
+
3640
+ </fo:block>
3589
3641
 
3590
- </fo:inline>
3591
- <fo:inline xsl:use-attribute-sets="table-fn-body-style">
3592
- <xsl:copy-of select="./node()"/>
3593
- </fo:inline>
3594
- </fo:block>
3595
3642
  </xsl:if>
3596
3643
  </xsl:for-each>
3597
3644
  </xsl:template>
@@ -3620,8 +3667,16 @@
3620
3667
  <!-- figure's footnotes rendering -->
3621
3668
  <xsl:template name="fn_display_figure">
3622
3669
 
3670
+ <!-- current figure id -->
3671
+ <xsl:variable name="figure_id_">
3672
+ <xsl:value-of select="@id"/>
3673
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3674
+ </xsl:variable>
3675
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3676
+
3677
+ <!-- all footnotes relates to the current figure -->
3623
3678
  <xsl:variable name="references">
3624
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3679
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3625
3680
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3626
3681
  <xsl:apply-templates/>
3627
3682
  </fn>
@@ -3634,91 +3689,93 @@
3634
3689
 
3635
3690
  </xsl:variable>
3636
3691
 
3637
- <!-- current hierarchy is 'figure' element -->
3638
- <xsl:variable name="following_dl_colwidths">
3639
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3640
- <xsl:variable name="simple-table">
3641
- <!-- <xsl:variable name="doc_ns">
3642
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3692
+ <fo:block>
3693
+
3694
+ <!-- current hierarchy is 'figure' element -->
3695
+ <xsl:variable name="following_dl_colwidths">
3696
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3697
+ <xsl:variable name="simple-table">
3698
+ <!-- <xsl:variable name="doc_ns">
3699
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3700
+ </xsl:variable>
3701
+ <xsl:variable name="ns">
3702
+ <xsl:choose>
3703
+ <xsl:when test="normalize-space($doc_ns) != ''">
3704
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3705
+ </xsl:when>
3706
+ <xsl:otherwise>
3707
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3708
+ </xsl:otherwise>
3709
+ </xsl:choose>
3710
+ </xsl:variable> -->
3711
+
3712
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3713
+ <tbody>
3714
+ <xsl:apply-templates mode="dl"/>
3715
+ </tbody>
3716
+ </xsl:for-each>
3717
+ </xsl:variable>
3718
+
3719
+ <xsl:call-template name="calculate-column-widths">
3720
+ <xsl:with-param name="cols-count" select="2"/>
3721
+ <xsl:with-param name="table" select="$simple-table"/>
3722
+ </xsl:call-template>
3723
+
3724
+ </xsl:if>
3643
3725
  </xsl:variable>
3644
- <xsl:variable name="ns">
3726
+
3727
+ <xsl:variable name="maxlength_dt">
3728
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3729
+ <xsl:call-template name="getMaxLength_dt"/>
3730
+ </xsl:for-each>
3731
+ </xsl:variable>
3732
+
3733
+ <fo:table width="95%" table-layout="fixed">
3734
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3735
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3736
+
3737
+ </xsl:if>
3645
3738
  <xsl:choose>
3646
- <xsl:when test="normalize-space($doc_ns) != ''">
3647
- <xsl:value-of select="normalize-space($doc_ns)"/>
3739
+ <!-- if there 'dl', then set same columns width -->
3740
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3741
+ <xsl:call-template name="setColumnWidth_dl">
3742
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3743
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3744
+ </xsl:call-template>
3648
3745
  </xsl:when>
3649
3746
  <xsl:otherwise>
3650
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3747
+ <fo:table-column column-width="5%"/>
3748
+ <fo:table-column column-width="95%"/>
3651
3749
  </xsl:otherwise>
3652
3750
  </xsl:choose>
3653
- </xsl:variable> -->
3654
-
3655
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3656
- <tbody>
3657
- <xsl:apply-templates mode="dl"/>
3658
- </tbody>
3659
- </xsl:for-each>
3660
- </xsl:variable>
3661
-
3662
- <xsl:call-template name="calculate-column-widths">
3663
- <xsl:with-param name="cols-count" select="2"/>
3664
- <xsl:with-param name="table" select="$simple-table"/>
3665
- </xsl:call-template>
3666
-
3667
- </xsl:if>
3668
- </xsl:variable>
3669
-
3670
- <xsl:variable name="maxlength_dt">
3671
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3672
- <xsl:call-template name="getMaxLength_dt"/>
3673
- </xsl:for-each>
3674
- </xsl:variable>
3675
-
3676
- <fo:block>
3677
- <fo:table width="95%" table-layout="fixed">
3678
- <xsl:if test="normalize-space($key_iso) = 'true'">
3679
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3751
+ <fo:table-body>
3752
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3753
+ <xsl:variable name="reference" select="@reference"/>
3754
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3755
+ <fo:table-row>
3756
+ <fo:table-cell>
3757
+ <fo:block>
3758
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3759
+ <xsl:value-of select="@reference"/>
3760
+ </fo:inline>
3761
+ </fo:block>
3762
+ </fo:table-cell>
3763
+ <fo:table-cell>
3764
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3765
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3680
3766
 
3681
- </xsl:if>
3682
- <xsl:choose>
3683
- <!-- if there 'dl', then set same columns width -->
3684
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3685
- <xsl:call-template name="setColumnWidth_dl">
3686
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3687
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3688
- </xsl:call-template>
3689
- </xsl:when>
3690
- <xsl:otherwise>
3691
- <fo:table-column column-width="15%"/>
3692
- <fo:table-column column-width="85%"/>
3693
- </xsl:otherwise>
3694
- </xsl:choose>
3695
- <fo:table-body>
3696
- <xsl:for-each select="xalan:nodeset($references)//fn">
3697
- <xsl:variable name="reference" select="@reference"/>
3698
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3699
- <fo:table-row>
3700
- <fo:table-cell>
3701
- <fo:block>
3702
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3703
- <xsl:value-of select="@reference"/>
3704
- </fo:inline>
3705
- </fo:block>
3706
- </fo:table-cell>
3707
- <fo:table-cell>
3708
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3709
- <xsl:if test="normalize-space($key_iso) = 'true'">
3767
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3710
3768
 
3711
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3769
+ </xsl:if>
3770
+ <xsl:copy-of select="./node()"/>
3771
+ </fo:block>
3772
+ </fo:table-cell>
3773
+ </fo:table-row>
3774
+ </xsl:if>
3775
+ </xsl:for-each>
3776
+ </fo:table-body>
3777
+ </fo:table>
3712
3778
 
3713
- </xsl:if>
3714
- <xsl:copy-of select="./node()"/>
3715
- </fo:block>
3716
- </fo:table-cell>
3717
- </fo:table-row>
3718
- </xsl:if>
3719
- </xsl:for-each>
3720
- </fo:table-body>
3721
- </fo:table>
3722
3779
  </fo:block>
3723
3780
  </xsl:if>
3724
3781
 
@@ -3794,12 +3851,14 @@
3794
3851
 
3795
3852
  <fo:block margin-bottom="12pt" text-align="left">
3796
3853
 
3797
- <xsl:variable name="title-where">
3854
+ <!-- <xsl:variable name="title-where">
3798
3855
  <xsl:call-template name="getLocalizedString">
3799
3856
  <xsl:with-param name="key">where</xsl:with-param>
3800
3857
  </xsl:call-template>
3801
3858
  </xsl:variable>
3802
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3859
+ <xsl:value-of select="$title-where"/> -->
3860
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3861
+ <xsl:text> </xsl:text>
3803
3862
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3804
3863
  <xsl:text/>
3805
3864
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3809,12 +3868,14 @@
3809
3868
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3810
3869
  <fo:block margin-bottom="12pt" text-align="left">
3811
3870
 
3812
- <xsl:variable name="title-where">
3871
+ <!-- <xsl:variable name="title-where">
3813
3872
  <xsl:call-template name="getLocalizedString">
3814
3873
  <xsl:with-param name="key">where</xsl:with-param>
3815
3874
  </xsl:call-template>
3816
3875
  </xsl:variable>
3817
- <xsl:value-of select="$title-where"/>
3876
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3877
+ <!-- preceding 'p' with word 'where' -->
3878
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3818
3879
  </fo:block>
3819
3880
  </xsl:when> <!-- END: a few components -->
3820
3881
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -4003,6 +4064,9 @@
4003
4064
 
4004
4065
  </xsl:template> <!-- END: dl -->
4005
4066
 
4067
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
4068
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
4069
+
4006
4070
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4007
4071
  <xsl:param name="process">false</xsl:param>
4008
4072
  <xsl:if test="$process = 'true'">
@@ -4534,12 +4598,12 @@
4534
4598
  <xsl:param name="value"/>
4535
4599
  <xsl:variable name="add_width" select="string-length($value) * 20"/>
4536
4600
  <xsl:variable name="maxwidth" select="60 + $add_width"/>
4537
- <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" -->
4538
- <xsl:attribute name="height">5mm</xsl:attribute>
4601
+ <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-10%"><!-- alignment-baseline="middle" -->
4602
+ <xsl:attribute name="height">3.5mm</xsl:attribute> <!-- 5mm -->
4539
4603
  <xsl:attribute name="content-width">100%</xsl:attribute>
4540
4604
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
4541
4605
  <xsl:attribute name="scaling">uniform</xsl:attribute>
4542
- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4606
+ <!-- <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4543
4607
  <g>
4544
4608
  <xsl:if test="$type = 'closing' or $type = 'end'">
4545
4609
  <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
@@ -4553,6 +4617,27 @@
4553
4617
  </xsl:if>
4554
4618
  <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan>
4555
4619
  </text>
4620
+ </svg> -->
4621
+ <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80">
4622
+ <g>
4623
+ <xsl:if test="$type = 'closing' or $type = 'end'">
4624
+ <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute>
4625
+ </xsl:if>
4626
+ <polyline points="0,2.5 {$maxwidth},2.5 {$maxwidth + 20},40 {$maxwidth},77.5 0,77.5" stroke="black" stroke-width="5" fill="white"/>
4627
+ <line x1="9.5" y1="0" x2="9.5" y2="80" stroke="black" stroke-width="19"/>
4628
+ </g>
4629
+ <xsl:variable name="text_x">
4630
+ <xsl:choose>
4631
+ <xsl:when test="$type = 'closing' or $type = 'end'">28</xsl:when>
4632
+ <xsl:otherwise>22</xsl:otherwise>
4633
+ </xsl:choose>
4634
+ </xsl:variable>
4635
+ <text font-family="Arial" x="{$text_x}" y="50" font-size="40pt">
4636
+ <xsl:value-of select="$kind"/>
4637
+ </text>
4638
+ <text font-family="Arial" x="{$text_x + 33}" y="65" font-size="38pt">
4639
+ <xsl:value-of select="$value"/>
4640
+ </text>
4556
4641
  </svg>
4557
4642
  </fo:instream-foreign-object>
4558
4643
  </xsl:template>
@@ -4621,7 +4706,7 @@
4621
4706
  </xsl:copy>
4622
4707
  </xsl:template>
4623
4708
 
4624
- <xsl:template match="*[local-name() = 'pagebreak']" mode="landscape_portrait">
4709
+ <xsl:template match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="landscape_portrait">
4625
4710
 
4626
4711
  <!-- determine pagebreak is last element before </fo:flow> or not -->
4627
4712
  <xsl:variable name="isLast">
@@ -4633,16 +4718,18 @@
4633
4718
  <xsl:if test="contains($isLast, 'false')">
4634
4719
 
4635
4720
  <xsl:variable name="orientation" select="normalize-space(@orientation)"/>
4636
- <xsl:variable name="tree">
4721
+
4722
+ <xsl:variable name="tree_">
4637
4723
  <xsl:for-each select="ancestor::*[ancestor::fo:flow]">
4638
4724
  <element pos="{position()}">
4639
4725
  <xsl:value-of select="name()"/>
4640
4726
  </element>
4641
4727
  </xsl:for-each>
4642
4728
  </xsl:variable>
4729
+ <xsl:variable name="tree" select="xalan:nodeset($tree_)"/>
4643
4730
 
4644
4731
  <!-- close fo:page-sequence (closing preceding fo elements) -->
4645
- <xsl:for-each select="xalan:nodeset($tree)//element">
4732
+ <xsl:for-each select="$tree//element">
4646
4733
  <xsl:sort data-type="number" order="descending" select="@pos"/>
4647
4734
  <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
4648
4735
  <xsl:value-of select="."/>
@@ -4653,7 +4740,6 @@
4653
4740
 
4654
4741
  <!-- <pagebreak/> -->
4655
4742
  <!-- create a new fo:page-sequence (opening fo elements) -->
4656
-
4657
4743
  <xsl:text disable-output-escaping="yes">&lt;fo:page-sequence master-reference="document</xsl:text><xsl:if test="$orientation != ''">-<xsl:value-of select="$orientation"/></xsl:if><xsl:text disable-output-escaping="yes">"&gt;</xsl:text>
4658
4744
  <fo:static-content flow-name="xsl-footnote-separator">
4659
4745
  <fo:block>
@@ -4663,7 +4749,7 @@
4663
4749
  <xsl:call-template name="insertHeaderFooter"/>
4664
4750
  <xsl:text disable-output-escaping="yes">&lt;fo:flow flow-name="xsl-region-body"&gt;</xsl:text>
4665
4751
 
4666
- <xsl:for-each select="xalan:nodeset($tree)//element">
4752
+ <xsl:for-each select="$tree//element">
4667
4753
  <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
4668
4754
  <xsl:value-of select="."/>
4669
4755
  <xsl:for-each select="@*[local-name() != 'pos']">
@@ -4675,6 +4761,7 @@
4675
4761
  </xsl:for-each>
4676
4762
  <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
4677
4763
  </xsl:for-each>
4764
+
4678
4765
  </xsl:if>
4679
4766
  </xsl:template>
4680
4767
  <!-- ================================================================ -->
@@ -4876,18 +4963,34 @@
4876
4963
 
4877
4964
  <xsl:template name="add-zero-spaces-java">
4878
4965
  <xsl:param name="text" select="."/>
4879
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, arrow right -->
4880
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |→)','$1​')"/>
4966
+
4967
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
4968
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4969
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4970
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4971
+ <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4972
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4881
4973
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4882
- <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' -->
4974
+ <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' -->
4883
4975
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4884
- <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' -->
4976
+ <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' -->
4885
4977
  <!-- add zero-width space (#x200B) before character: { -->
4886
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4978
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4887
4979
  <!-- add zero-width space (#x200B) after character: , -->
4888
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4980
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4981
+ <!-- add zero-width space (#x200B) after character: '/' -->
4982
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4983
+
4984
+ <xsl:variable name="text9">
4985
+ <xsl:choose>
4986
+ <xsl:when test="$isGenerateTableIF = 'true'">
4987
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4988
+ </xsl:when>
4989
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4990
+ </xsl:choose>
4991
+ </xsl:variable>
4889
4992
 
4890
- <xsl:value-of select="$text5"/>
4993
+ <xsl:value-of select="$text9"/>
4891
4994
  </xsl:template>
4892
4995
 
4893
4996
  <xsl:template name="add-zero-spaces-link-java">
@@ -4895,8 +4998,10 @@
4895
4998
 
4896
4999
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4897
5000
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4898
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4899
- <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
5001
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
5002
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
5003
+ <!-- remove zero-width space at the end -->
5004
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4900
5005
  </xsl:template>
4901
5006
 
4902
5007
  <!-- add zero space after dash character (for table's entries) -->
@@ -5033,7 +5138,7 @@
5033
5138
  </xsl:copy>
5034
5139
  </xsl:template>
5035
5140
 
5036
- <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">
5141
+ <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">
5037
5142
  <xsl:copy>
5038
5143
  <xsl:copy-of select="@*"/>
5039
5144
  <p>
@@ -5109,6 +5214,14 @@
5109
5214
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
5110
5215
  </xsl:template>
5111
5216
 
5217
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'ol' or local-name() = 'ul']" mode="table-without-br">
5218
+ <xsl:apply-templates mode="table-without-br"/>
5219
+ </xsl:template>
5220
+
5221
+ <xsl:template match="*[local-name()='th' or local-name()='td']//*[local-name() = 'li']" mode="table-without-br">
5222
+ <xsl:apply-templates mode="table-without-br"/>
5223
+ </xsl:template>
5224
+
5112
5225
  <!-- mode="table-without-br" -->
5113
5226
  <!-- ================================== -->
5114
5227
  <!-- END: Step 0. replace <br/> to <p>...</p> -->
@@ -5241,9 +5354,28 @@
5241
5354
  </xsl:variable>
5242
5355
  <xsl:copy-of select="$newRow"/>
5243
5356
 
5244
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5245
- <xsl:with-param name="previousRow" select="$newRow"/>
5246
- </xsl:apply-templates>
5357
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5358
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5359
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5360
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5361
+ <xsl:choose>
5362
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5363
+ <xsl:copy-of select="following-sibling::tr"/>
5364
+ </xsl:when>
5365
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5366
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5367
+
5368
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5369
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5370
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5371
+ </xsl:apply-templates>
5372
+ </xsl:when> -->
5373
+ <xsl:otherwise>
5374
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5375
+ <xsl:with-param name="previousRow" select="$newRow"/>
5376
+ </xsl:apply-templates>
5377
+ </xsl:otherwise>
5378
+ </xsl:choose>
5247
5379
  </xsl:template>
5248
5380
  <!-- End mode simple-table-rowspan -->
5249
5381
 
@@ -5406,6 +5538,27 @@
5406
5538
  </xsl:call-template>
5407
5539
  </xsl:template>
5408
5540
 
5541
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5542
+ <xsl:variable name="link">
5543
+ <link_updated>
5544
+ <xsl:variable name="target_text">
5545
+ <xsl:choose>
5546
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5547
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5548
+ </xsl:when>
5549
+ <xsl:otherwise>
5550
+ <xsl:value-of select="normalize-space(@target)"/>
5551
+ </xsl:otherwise>
5552
+ </xsl:choose>
5553
+ </xsl:variable>
5554
+ <xsl:value-of select="$target_text"/>
5555
+ </link_updated>
5556
+ </xsl:variable>
5557
+ <xsl:for-each select="xalan:nodeset($link)/*">
5558
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5559
+ </xsl:for-each>
5560
+ </xsl:template>
5561
+
5409
5562
  <xsl:template name="getFormattingTags">
5410
5563
  <tags>
5411
5564
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5747,7 +5900,7 @@
5747
5900
  </xsl:variable>
5748
5901
  <fo:inline xsl:use-attribute-sets="link-style">
5749
5902
 
5750
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5903
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5751
5904
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5752
5905
  </xsl:if>
5753
5906
 
@@ -5922,7 +6075,7 @@
5922
6075
 
5923
6076
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5924
6077
 
5925
- <fo:block-container margin-left="0mm">
6078
+ <fo:block-container margin-left="0mm" margin-right="0mm">
5926
6079
 
5927
6080
  <fo:block>
5928
6081
 
@@ -6098,13 +6251,16 @@
6098
6251
  <xsl:with-param name="isDeleted" select="$isDeleted"/>
6099
6252
  </xsl:call-template>
6100
6253
 
6254
+ <!-- Example: Dimensions in millimeters -->
6255
+ <xsl:apply-templates select="*[local-name() = 'note'][@type = 'units']"/>
6256
+
6101
6257
  <fo:block xsl:use-attribute-sets="figure-style">
6102
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
6258
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
6103
6259
  </fo:block>
6104
- <xsl:call-template name="fn_display_figure"/>
6105
- <xsl:for-each select="*[local-name() = 'note']">
6260
+ <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
6106
6261
  <xsl:call-template name="note"/>
6107
6262
  </xsl:for-each>
6263
+ <xsl:call-template name="fn_display_figure"/>
6108
6264
 
6109
6265
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
6110
6266
 
@@ -6167,7 +6323,13 @@
6167
6323
  </xsl:choose>
6168
6324
  </xsl:variable>
6169
6325
 
6170
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6326
+ <xsl:variable name="image_width_effective">
6327
+
6328
+ <xsl:value-of select="$width_effective"/>
6329
+
6330
+ </xsl:variable>
6331
+
6332
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6171
6333
  <xsl:if test="number($scale) &lt; 100">
6172
6334
 
6173
6335
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -6359,24 +6521,47 @@
6359
6521
 
6360
6522
  </xsl:when>
6361
6523
  <xsl:otherwise>
6362
- <fo:block xsl:use-attribute-sets="image-style">
6363
- <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6364
- <xsl:attribute name="width">100%</xsl:attribute>
6365
- <xsl:attribute name="content-height">100%</xsl:attribute>
6366
- <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6367
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6368
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6369
- <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6370
- <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6371
- <!-- effective height / width = 1.48, 1.4 - with title -->
6372
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6373
- <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6374
- <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6375
- </xsl:if>
6376
- <xsl:attribute name="scaling">uniform</xsl:attribute>
6377
- <xsl:copy-of select="$svg_content"/>
6378
- </fo:instream-foreign-object>
6379
- </fo:block>
6524
+
6525
+ <xsl:variable name="element">
6526
+ <xsl:choose>
6527
+ <xsl:when test="ancestor::*[local-name() = 'tr'] and $isGenerateTableIF = 'true'">
6528
+ <fo:inline xsl:use-attribute-sets="image-style" text-align="left"/>
6529
+ </xsl:when>
6530
+ <xsl:otherwise>
6531
+ <fo:block xsl:use-attribute-sets="image-style">
6532
+ <xsl:if test="ancestor::*[local-name() = 'dt']">
6533
+ <xsl:attribute name="text-align">left</xsl:attribute>
6534
+ </xsl:if>
6535
+ </fo:block>
6536
+ </xsl:otherwise>
6537
+ </xsl:choose>
6538
+ </xsl:variable>
6539
+
6540
+ <xsl:for-each select="xalan:nodeset($element)/*">
6541
+ <xsl:copy>
6542
+ <xsl:copy-of select="@*"/>
6543
+ <!-- <fo:block xsl:use-attribute-sets="image-style"> -->
6544
+ <fo:instream-foreign-object fox:alt-text="{$alt-text}">
6545
+ <xsl:if test="$isGenerateTableIF = 'false'">
6546
+ <xsl:attribute name="width">100%</xsl:attribute>
6547
+ </xsl:if>
6548
+ <xsl:attribute name="content-height">100%</xsl:attribute>
6549
+ <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6550
+ <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6551
+ <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6552
+ <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6553
+ <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6554
+ <!-- effective height / width = 1.48, 1.4 - with title -->
6555
+ <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6556
+ <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6557
+ <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6558
+ </xsl:if>
6559
+ <xsl:attribute name="scaling">uniform</xsl:attribute>
6560
+ <xsl:copy-of select="$svg_content"/>
6561
+ </fo:instream-foreign-object>
6562
+ <!-- </fo:block> -->
6563
+ </xsl:copy>
6564
+ </xsl:for-each>
6380
6565
  </xsl:otherwise>
6381
6566
  </xsl:choose>
6382
6567
  </xsl:template>
@@ -6468,6 +6653,13 @@
6468
6653
  </xsl:for-each>
6469
6654
  </xsl:template>
6470
6655
 
6656
+ <!-- For the structures like: <dt><image src="" mimetype="image/svg+xml" height="" width=""><svg xmlns="http://www.w3.org/2000/svg" ... -->
6657
+ <xsl:template match="*[local-name() != 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
6658
+ <xsl:for-each select="*[local-name() = 'svg']">
6659
+ <xsl:call-template name="image_svg"/>
6660
+ </xsl:for-each>
6661
+ </xsl:template>
6662
+
6471
6663
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
6472
6664
  <xsl:variable name="svg_content" select="document(@src)"/>
6473
6665
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -6606,6 +6798,8 @@
6606
6798
  <xsl:value-of select="."/>
6607
6799
  </xsl:template>
6608
6800
 
6801
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="bookmarks" priority="3"/>
6802
+
6609
6803
  <xsl:template match="node()" mode="contents">
6610
6804
  <xsl:apply-templates mode="contents"/>
6611
6805
  </xsl:template>
@@ -6722,6 +6916,13 @@
6722
6916
  <xsl:when test="$contents_nodes/doc">
6723
6917
  <xsl:choose>
6724
6918
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6919
+
6920
+ <xsl:if test="$contents_nodes/collection">
6921
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6922
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6923
+ </fo:bookmark>
6924
+ </xsl:if>
6925
+
6725
6926
  <xsl:for-each select="$contents_nodes/doc">
6726
6927
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6727
6928
  <xsl:if test="@bundle = 'true'">
@@ -6913,7 +7114,15 @@
6913
7114
  <xsl:value-of select="@section"/>
6914
7115
  <xsl:text> </xsl:text>
6915
7116
  </xsl:if>
6916
- <xsl:value-of select="normalize-space(title)"/>
7117
+ <xsl:variable name="title">
7118
+ <xsl:for-each select="title/node()">
7119
+ <xsl:choose>
7120
+ <xsl:when test="local-name() = 'add' and starts-with(., $ace_tag)"><!-- skip --></xsl:when>
7121
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7122
+ </xsl:choose>
7123
+ </xsl:for-each>
7124
+ </xsl:variable>
7125
+ <xsl:value-of select="normalize-space($title)"/>
6917
7126
  </fo:bookmark-title>
6918
7127
  <xsl:apply-templates mode="bookmark"/>
6919
7128
  </fo:bookmark>
@@ -6939,6 +7148,12 @@
6939
7148
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/>
6940
7149
  <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/>
6941
7150
 
7151
+ <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note'][@type = 'units'] | *[local-name() = 'image']/*[local-name() = 'note'][@type = 'units']" priority="2">
7152
+ <fo:block text-align="right" keep-with-next="always">
7153
+ <xsl:apply-templates/>
7154
+ </fo:block>
7155
+ </xsl:template>
7156
+
6942
7157
  <!-- ====== -->
6943
7158
  <!-- ====== -->
6944
7159
  <xsl:template match="*[local-name() = 'title']" mode="contents_item">
@@ -7088,6 +7303,10 @@
7088
7303
  </xsl:for-each>
7089
7304
  </xsl:template>
7090
7305
 
7306
+ <xsl:template match="*[local-name() = 'add'][starts-with(., $ace_tag)]/text()" mode="contents_item" priority="2">
7307
+ <xsl:value-of select="."/>
7308
+ </xsl:template>
7309
+
7091
7310
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
7092
7311
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
7093
7312
  <xsl:apply-templates mode="contents_item"/>
@@ -8577,6 +8796,44 @@
8577
8796
 
8578
8797
  <fo:list-block xsl:use-attribute-sets="list-style">
8579
8798
 
8799
+ <xsl:variable name="provisional_distance_between_starts_">
8800
+ <attributes xsl:use-attribute-sets="list-style">
8801
+
8802
+ </attributes>
8803
+ </xsl:variable>
8804
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8805
+ <xsl:if test="$provisional_distance_between_starts != ''">
8806
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8807
+ </xsl:if>
8808
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8809
+
8810
+ <!-- increase provisional-distance-between-starts for long lists -->
8811
+ <xsl:if test="local-name() = 'ol'">
8812
+ <!-- Examples: xiii), xviii), xxviii) -->
8813
+ <xsl:variable name="item_numbers">
8814
+ <xsl:for-each select="*[local-name() = 'li']">
8815
+ <item><xsl:call-template name="getListItemFormat"/></item>
8816
+ </xsl:for-each>
8817
+ </xsl:variable>
8818
+
8819
+ <xsl:variable name="max_length">
8820
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8821
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8822
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8823
+ </xsl:for-each>
8824
+ </xsl:variable>
8825
+
8826
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8827
+ <xsl:variable name="addon" select="$max_length - 4"/>
8828
+ <xsl:if test="$addon &gt; 0">
8829
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8830
+ </xsl:if>
8831
+ <!-- DEBUG -->
8832
+ <!-- <xsl:copy-of select="$item_numbers"/>
8833
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8834
+ <addon><xsl:value-of select="$addon"/></addon> -->
8835
+ </xsl:if>
8836
+
8580
8837
  <xsl:if test="*[local-name() = 'name']">
8581
8838
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
8582
8839
  </xsl:if>
@@ -9533,7 +9790,7 @@
9533
9790
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9534
9791
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9535
9792
  <!-- add &lt; and &gt; to \S -->
9536
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9793
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9537
9794
  <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>
9538
9795
  <xsl:variable name="text3">
9539
9796
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9555,7 +9812,8 @@
9555
9812
  <xsl:choose>
9556
9813
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9557
9814
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9558
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9815
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9816
+ <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>
9559
9817
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9560
9818
  <xsl:choose>
9561
9819
  <xsl:when test="self::text()">
@@ -10158,6 +10416,23 @@
10158
10416
  </xsl:if>
10159
10417
  </xsl:template>
10160
10418
 
10419
+ <xsl:template name="setBlockAttributes">
10420
+ <xsl:param name="text_align_default">left</xsl:param>
10421
+ <xsl:call-template name="setTextAlignment">
10422
+ <xsl:with-param name="default" select="$text_align_default"/>
10423
+ </xsl:call-template>
10424
+
10425
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10426
+ <!-- Example: keep-lines-together="true" -->
10427
+ <xsl:if test="@keep-lines-together = 'true'">
10428
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10429
+ </xsl:if>
10430
+ <!-- Example: keep-with-next="true" -->
10431
+ <xsl:if test="@keep-with-next = 'true'">
10432
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10433
+ </xsl:if>
10434
+ </xsl:template>
10435
+
10161
10436
  <xsl:template name="number-to-words">
10162
10437
  <xsl:param name="number"/>
10163
10438
  <xsl:param name="first"/>