metanorma-un 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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>
@@ -2992,6 +2990,10 @@
2992
2990
  </xsl:choose>
2993
2991
  </xsl:variable>
2994
2992
 
2993
+ <xsl:variable name="table_fn_block">
2994
+ <xsl:call-template name="table_fn_display"/>
2995
+ </xsl:variable>
2996
+
2995
2997
  <xsl:variable name="tableWithNotesAndFootnotes">
2996
2998
 
2997
2999
  <fo:table keep-with-previous="always">
@@ -3039,11 +3041,25 @@
3039
3041
 
3040
3042
  <xsl:apply-templates select="../*[local-name()='note']"/>
3041
3043
 
3044
+ <xsl:variable name="isDisplayRowSeparator">
3045
+
3046
+ </xsl:variable>
3047
+
3042
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>
3043
3058
 
3044
3059
  <!-- fn processing -->
3045
3060
 
3046
- <xsl:call-template name="table_fn_display"/>
3061
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3062
+ <xsl:copy-of select="$table_fn_block"/>
3047
3063
 
3048
3064
  <!-- for PAS display Notes after footnotes -->
3049
3065
 
@@ -3160,6 +3176,28 @@
3160
3176
  </fo:table-row>
3161
3177
  </xsl:template>
3162
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
+
3163
3201
  <!-- row in table footer (tfoot) -->
3164
3202
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3165
3203
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -3496,8 +3534,16 @@
3496
3534
  <!-- figure's footnotes rendering -->
3497
3535
  <xsl:template name="fn_display_figure">
3498
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 -->
3499
3545
  <xsl:variable name="references">
3500
- <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]]">
3501
3547
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3502
3548
  <xsl:apply-templates/>
3503
3549
  </fn>
@@ -3510,91 +3556,93 @@
3510
3556
 
3511
3557
  </xsl:variable>
3512
3558
 
3513
- <!-- current hierarchy is 'figure' element -->
3514
- <xsl:variable name="following_dl_colwidths">
3515
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3516
- <xsl:variable name="simple-table">
3517
- <!-- <xsl:variable name="doc_ns">
3518
- <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>
3519
3592
  </xsl:variable>
3520
- <xsl:variable name="ns">
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>
3598
+ </xsl:variable>
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>
3521
3605
  <xsl:choose>
3522
- <xsl:when test="normalize-space($doc_ns) != ''">
3523
- <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>
3524
3612
  </xsl:when>
3525
3613
  <xsl:otherwise>
3526
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3614
+ <fo:table-column column-width="5%"/>
3615
+ <fo:table-column column-width="95%"/>
3527
3616
  </xsl:otherwise>
3528
3617
  </xsl:choose>
3529
- </xsl:variable> -->
3530
-
3531
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3532
- <tbody>
3533
- <xsl:apply-templates mode="dl"/>
3534
- </tbody>
3535
- </xsl:for-each>
3536
- </xsl:variable>
3537
-
3538
- <xsl:call-template name="calculate-column-widths">
3539
- <xsl:with-param name="cols-count" select="2"/>
3540
- <xsl:with-param name="table" select="$simple-table"/>
3541
- </xsl:call-template>
3542
-
3543
- </xsl:if>
3544
- </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'">
3545
3633
 
3546
- <xsl:variable name="maxlength_dt">
3547
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3548
- <xsl:call-template name="getMaxLength_dt"/>
3549
- </xsl:for-each>
3550
- </xsl:variable>
3634
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3551
3635
 
3552
- <fo:block>
3553
- <fo:table width="95%" table-layout="fixed">
3554
- <xsl:if test="normalize-space($key_iso) = 'true'">
3555
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3556
-
3557
- </xsl:if>
3558
- <xsl:choose>
3559
- <!-- if there 'dl', then set same columns width -->
3560
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3561
- <xsl:call-template name="setColumnWidth_dl">
3562
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3563
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3564
- </xsl:call-template>
3565
- </xsl:when>
3566
- <xsl:otherwise>
3567
- <fo:table-column column-width="15%"/>
3568
- <fo:table-column column-width="85%"/>
3569
- </xsl:otherwise>
3570
- </xsl:choose>
3571
- <fo:table-body>
3572
- <xsl:for-each select="xalan:nodeset($references)//fn">
3573
- <xsl:variable name="reference" select="@reference"/>
3574
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3575
- <fo:table-row>
3576
- <fo:table-cell>
3577
- <fo:block>
3578
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3579
- <xsl:value-of select="@reference"/>
3580
- </fo:inline>
3581
- </fo:block>
3582
- </fo:table-cell>
3583
- <fo:table-cell>
3584
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3585
- <xsl:if test="normalize-space($key_iso) = 'true'">
3586
-
3587
- <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>
3588
3645
 
3589
- </xsl:if>
3590
- <xsl:copy-of select="./node()"/>
3591
- </fo:block>
3592
- </fo:table-cell>
3593
- </fo:table-row>
3594
- </xsl:if>
3595
- </xsl:for-each>
3596
- </fo:table-body>
3597
- </fo:table>
3598
3646
  </fo:block>
3599
3647
  </xsl:if>
3600
3648
 
@@ -3670,12 +3718,14 @@
3670
3718
 
3671
3719
  <fo:block margin-bottom="12pt" text-align="left">
3672
3720
 
3673
- <xsl:variable name="title-where">
3721
+ <!-- <xsl:variable name="title-where">
3674
3722
  <xsl:call-template name="getLocalizedString">
3675
3723
  <xsl:with-param name="key">where</xsl:with-param>
3676
3724
  </xsl:call-template>
3677
3725
  </xsl:variable>
3678
- <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>
3679
3729
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3680
3730
  <xsl:text/>
3681
3731
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3685,12 +3735,14 @@
3685
3735
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3686
3736
  <fo:block margin-bottom="12pt" text-align="left">
3687
3737
 
3688
- <xsl:variable name="title-where">
3738
+ <!-- <xsl:variable name="title-where">
3689
3739
  <xsl:call-template name="getLocalizedString">
3690
3740
  <xsl:with-param name="key">where</xsl:with-param>
3691
3741
  </xsl:call-template>
3692
3742
  </xsl:variable>
3693
- <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()"/>
3694
3746
  </fo:block>
3695
3747
  </xsl:when> <!-- END: a few components -->
3696
3748
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3873,6 +3925,9 @@
3873
3925
 
3874
3926
  </xsl:template> <!-- END: dl -->
3875
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
+
3876
3931
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3877
3932
  <xsl:param name="process">false</xsl:param>
3878
3933
  <xsl:if test="$process = 'true'">
@@ -4697,20 +4752,34 @@
4697
4752
 
4698
4753
  <xsl:template name="add-zero-spaces-java">
4699
4754
  <xsl:param name="text" select="."/>
4700
- <!-- add zero-width space (#x200B) after characters: dash, dot, equal, underscore, em dash, thin space, arrow right -->
4701
- <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​')"/>
4702
4760
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4703
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1​$2')"/>
4761
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4704
4762
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4705
- <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(\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' -->
4706
4764
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4707
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&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' -->
4708
4766
  <!-- add zero-width space (#x200B) before character: { -->
4709
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&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' -->
4710
4768
  <!-- add zero-width space (#x200B) after character: , -->
4711
- <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\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 '/' -->
4712
4772
 
4713
- <xsl:value-of select="$text6"/>
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>
4781
+
4782
+ <xsl:value-of select="$text9"/>
4714
4783
  </xsl:template>
4715
4784
 
4716
4785
  <xsl:template name="add-zero-spaces-link-java">
@@ -4718,8 +4787,8 @@
4718
4787
 
4719
4788
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4720
4789
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4721
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4722
- <xsl:variable name="url" 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​')"/>
4723
4792
  <!-- remove zero-width space at the end -->
4724
4793
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4725
4794
  </xsl:template>
@@ -5074,9 +5143,28 @@
5074
5143
  </xsl:variable>
5075
5144
  <xsl:copy-of select="$newRow"/>
5076
5145
 
5077
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5078
- <xsl:with-param name="previousRow" select="$newRow"/>
5079
- </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>
5080
5168
  </xsl:template>
5081
5169
  <!-- End mode simple-table-rowspan -->
5082
5170
 
@@ -5239,6 +5327,27 @@
5239
5327
  </xsl:call-template>
5240
5328
  </xsl:template>
5241
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
+
5242
5351
  <xsl:template name="getFormattingTags">
5243
5352
  <tags>
5244
5353
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5580,7 +5689,7 @@
5580
5689
  </xsl:variable>
5581
5690
  <fo:inline xsl:use-attribute-sets="link-style">
5582
5691
 
5583
- <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'])">
5584
5693
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5585
5694
  </xsl:if>
5586
5695
 
@@ -5953,10 +6062,10 @@
5953
6062
  <fo:block xsl:use-attribute-sets="figure-style">
5954
6063
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
5955
6064
  </fo:block>
5956
- <xsl:call-template name="fn_display_figure"/>
5957
6065
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
5958
6066
  <xsl:call-template name="note"/>
5959
6067
  </xsl:for-each>
6068
+ <xsl:call-template name="fn_display_figure"/>
5960
6069
 
5961
6070
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
5962
6071
 
@@ -6019,7 +6128,13 @@
6019
6128
  </xsl:choose>
6020
6129
  </xsl:variable>
6021
6130
 
6022
- <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)"/>
6023
6138
  <xsl:if test="number($scale) &lt; 100">
6024
6139
 
6025
6140
  <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
@@ -6606,6 +6721,13 @@
6606
6721
  <xsl:when test="$contents_nodes/doc">
6607
6722
  <xsl:choose>
6608
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
+
6609
6731
  <xsl:for-each select="$contents_nodes/doc">
6610
6732
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6611
6733
  <xsl:if test="@bundle = 'true'">
@@ -8488,9 +8610,47 @@
8488
8610
 
8489
8611
  <fo:list-block xsl:use-attribute-sets="list-style">
8490
8612
 
8491
- <xsl:if test="local-name() = 'ol'">
8492
- <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>
8493
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>
8494
8654
 
8495
8655
  <xsl:if test="*[local-name() = 'name']">
8496
8656
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9428,7 +9588,7 @@
9428
9588
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9429
9589
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9430
9590
  <!-- add &lt; and &gt; to \S -->
9431
- <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>
9432
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>
9433
9593
  <xsl:variable name="text3">
9434
9594
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9450,7 +9610,8 @@
9450
9610
  <xsl:choose>
9451
9611
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9452
9612
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9453
- <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>
9454
9615
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9455
9616
  <xsl:choose>
9456
9617
  <xsl:when test="self::text()">
@@ -10053,6 +10214,23 @@
10053
10214
  </xsl:if>
10054
10215
  </xsl:template>
10055
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
+
10056
10234
  <xsl:template name="number-to-words">
10057
10235
  <xsl:param name="number"/>
10058
10236
  <xsl:param name="first"/>