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.
@@ -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>
@@ -3069,6 +3069,10 @@
3069
3069
  </xsl:choose>
3070
3070
  </xsl:variable>
3071
3071
 
3072
+ <xsl:variable name="table_fn_block">
3073
+ <xsl:call-template name="table_fn_display"/>
3074
+ </xsl:variable>
3075
+
3072
3076
  <xsl:variable name="tableWithNotesAndFootnotes">
3073
3077
 
3074
3078
  <fo:table keep-with-previous="always">
@@ -3116,11 +3120,25 @@
3116
3120
 
3117
3121
  <xsl:apply-templates select="../*[local-name()='note']"/>
3118
3122
 
3123
+ <xsl:variable name="isDisplayRowSeparator">
3124
+
3125
+ </xsl:variable>
3126
+
3119
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>
3120
3137
 
3121
3138
  <!-- fn processing -->
3122
3139
 
3123
- <xsl:call-template name="table_fn_display"/>
3140
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3141
+ <xsl:copy-of select="$table_fn_block"/>
3124
3142
 
3125
3143
  <!-- for PAS display Notes after footnotes -->
3126
3144
 
@@ -3237,6 +3255,28 @@
3237
3255
  </fo:table-row>
3238
3256
  </xsl:template>
3239
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
+
3240
3280
  <!-- row in table footer (tfoot) -->
3241
3281
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3242
3282
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -3589,8 +3629,16 @@
3589
3629
  <!-- figure's footnotes rendering -->
3590
3630
  <xsl:template name="fn_display_figure">
3591
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 -->
3592
3640
  <xsl:variable name="references">
3593
- <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]]">
3594
3642
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3595
3643
  <xsl:apply-templates/>
3596
3644
  </fn>
@@ -3603,91 +3651,93 @@
3603
3651
 
3604
3652
  </xsl:variable>
3605
3653
 
3606
- <!-- current hierarchy is 'figure' element -->
3607
- <xsl:variable name="following_dl_colwidths">
3608
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3609
- <xsl:variable name="simple-table">
3610
- <!-- <xsl:variable name="doc_ns">
3611
- <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>
3687
+ </xsl:variable>
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>
3612
3693
  </xsl:variable>
3613
- <xsl:variable name="ns">
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>
3614
3700
  <xsl:choose>
3615
- <xsl:when test="normalize-space($doc_ns) != ''">
3616
- <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>
3617
3707
  </xsl:when>
3618
3708
  <xsl:otherwise>
3619
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3709
+ <fo:table-column column-width="5%"/>
3710
+ <fo:table-column column-width="95%"/>
3620
3711
  </xsl:otherwise>
3621
3712
  </xsl:choose>
3622
- </xsl:variable> -->
3623
-
3624
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3625
- <tbody>
3626
- <xsl:apply-templates mode="dl"/>
3627
- </tbody>
3628
- </xsl:for-each>
3629
- </xsl:variable>
3630
-
3631
- <xsl:call-template name="calculate-column-widths">
3632
- <xsl:with-param name="cols-count" select="2"/>
3633
- <xsl:with-param name="table" select="$simple-table"/>
3634
- </xsl:call-template>
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'">
3635
3728
 
3636
- </xsl:if>
3637
- </xsl:variable>
3729
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3638
3730
 
3639
- <xsl:variable name="maxlength_dt">
3640
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3641
- <xsl:call-template name="getMaxLength_dt"/>
3642
- </xsl:for-each>
3643
- </xsl:variable>
3644
-
3645
- <fo:block>
3646
- <fo:table width="95%" table-layout="fixed">
3647
- <xsl:if test="normalize-space($key_iso) = 'true'">
3648
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3649
-
3650
- </xsl:if>
3651
- <xsl:choose>
3652
- <!-- if there 'dl', then set same columns width -->
3653
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3654
- <xsl:call-template name="setColumnWidth_dl">
3655
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3656
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3657
- </xsl:call-template>
3658
- </xsl:when>
3659
- <xsl:otherwise>
3660
- <fo:table-column column-width="15%"/>
3661
- <fo:table-column column-width="85%"/>
3662
- </xsl:otherwise>
3663
- </xsl:choose>
3664
- <fo:table-body>
3665
- <xsl:for-each select="xalan:nodeset($references)//fn">
3666
- <xsl:variable name="reference" select="@reference"/>
3667
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3668
- <fo:table-row>
3669
- <fo:table-cell>
3670
- <fo:block>
3671
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3672
- <xsl:value-of select="@reference"/>
3673
- </fo:inline>
3674
- </fo:block>
3675
- </fo:table-cell>
3676
- <fo:table-cell>
3677
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3678
- <xsl:if test="normalize-space($key_iso) = 'true'">
3679
-
3680
- <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>
3681
3740
 
3682
- </xsl:if>
3683
- <xsl:copy-of select="./node()"/>
3684
- </fo:block>
3685
- </fo:table-cell>
3686
- </fo:table-row>
3687
- </xsl:if>
3688
- </xsl:for-each>
3689
- </fo:table-body>
3690
- </fo:table>
3691
3741
  </fo:block>
3692
3742
  </xsl:if>
3693
3743
 
@@ -3763,12 +3813,14 @@
3763
3813
 
3764
3814
  <fo:block margin-bottom="12pt" text-align="left">
3765
3815
 
3766
- <xsl:variable name="title-where">
3816
+ <!-- <xsl:variable name="title-where">
3767
3817
  <xsl:call-template name="getLocalizedString">
3768
3818
  <xsl:with-param name="key">where</xsl:with-param>
3769
3819
  </xsl:call-template>
3770
3820
  </xsl:variable>
3771
- <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>
3772
3824
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3773
3825
  <xsl:text/>
3774
3826
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3778,12 +3830,14 @@
3778
3830
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3779
3831
  <fo:block margin-bottom="12pt" text-align="left">
3780
3832
 
3781
- <xsl:variable name="title-where">
3833
+ <!-- <xsl:variable name="title-where">
3782
3834
  <xsl:call-template name="getLocalizedString">
3783
3835
  <xsl:with-param name="key">where</xsl:with-param>
3784
3836
  </xsl:call-template>
3785
3837
  </xsl:variable>
3786
- <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()"/>
3787
3841
  </fo:block>
3788
3842
  </xsl:when> <!-- END: a few components -->
3789
3843
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3966,6 +4020,9 @@
3966
4020
 
3967
4021
  </xsl:template> <!-- END: dl -->
3968
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
+
3969
4026
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3970
4027
  <xsl:param name="process">false</xsl:param>
3971
4028
  <xsl:if test="$process = 'true'">
@@ -4790,20 +4847,34 @@
4790
4847
 
4791
4848
  <xsl:template name="add-zero-spaces-java">
4792
4849
  <xsl:param name="text" select="."/>
4793
- <!-- add zero-width space (#x200B) after characters: dash, dot, equal, underscore, em dash, thin space, arrow right -->
4794
- <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​')"/>
4795
4855
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4796
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1​$2')"/>
4856
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4797
4857
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4798
- <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' -->
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' -->
4799
4859
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4800
- <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' -->
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' -->
4801
4861
  <!-- add zero-width space (#x200B) before character: { -->
4802
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&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' -->
4803
4863
  <!-- add zero-width space (#x200B) after character: , -->
4804
- <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\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>
4805
4876
 
4806
- <xsl:value-of select="$text6"/>
4877
+ <xsl:value-of select="$text9"/>
4807
4878
  </xsl:template>
4808
4879
 
4809
4880
  <xsl:template name="add-zero-spaces-link-java">
@@ -4811,8 +4882,8 @@
4811
4882
 
4812
4883
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4813
4884
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4814
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4815
- <xsl:variable name="url" 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​')"/>
4816
4887
  <!-- remove zero-width space at the end -->
4817
4888
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4818
4889
  </xsl:template>
@@ -5167,9 +5238,28 @@
5167
5238
  </xsl:variable>
5168
5239
  <xsl:copy-of select="$newRow"/>
5169
5240
 
5170
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5171
- <xsl:with-param name="previousRow" select="$newRow"/>
5172
- </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>
5173
5263
  </xsl:template>
5174
5264
  <!-- End mode simple-table-rowspan -->
5175
5265
 
@@ -5332,6 +5422,27 @@
5332
5422
  </xsl:call-template>
5333
5423
  </xsl:template>
5334
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
+
5335
5446
  <xsl:template name="getFormattingTags">
5336
5447
  <tags>
5337
5448
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5673,7 +5784,7 @@
5673
5784
  </xsl:variable>
5674
5785
  <fo:inline xsl:use-attribute-sets="link-style">
5675
5786
 
5676
- <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'])">
5677
5788
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5678
5789
  </xsl:if>
5679
5790
 
@@ -6050,10 +6161,10 @@
6050
6161
  <fo:block xsl:use-attribute-sets="figure-style">
6051
6162
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
6052
6163
  </fo:block>
6053
- <xsl:call-template name="fn_display_figure"/>
6054
6164
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
6055
6165
  <xsl:call-template name="note"/>
6056
6166
  </xsl:for-each>
6167
+ <xsl:call-template name="fn_display_figure"/>
6057
6168
 
6058
6169
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
6059
6170
 
@@ -6121,7 +6232,13 @@
6121
6232
  </xsl:choose>
6122
6233
  </xsl:variable>
6123
6234
 
6124
- <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)"/>
6125
6242
  <xsl:if test="number($scale) &lt; 100">
6126
6243
 
6127
6244
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -6708,6 +6825,13 @@
6708
6825
  <xsl:when test="$contents_nodes/doc">
6709
6826
  <xsl:choose>
6710
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
+
6711
6835
  <xsl:for-each select="$contents_nodes/doc">
6712
6836
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6713
6837
  <xsl:if test="@bundle = 'true'">
@@ -8590,9 +8714,47 @@
8590
8714
 
8591
8715
  <fo:list-block xsl:use-attribute-sets="list-style">
8592
8716
 
8593
- <xsl:if test="local-name() = 'ol'">
8594
- <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>
8595
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>
8596
8758
 
8597
8759
  <xsl:if test="*[local-name() = 'name']">
8598
8760
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9531,7 +9693,7 @@
9531
9693
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9532
9694
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9533
9695
  <!-- add &lt; and &gt; to \S -->
9534
- <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>
9535
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>
9536
9698
  <xsl:variable name="text3">
9537
9699
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9553,7 +9715,8 @@
9553
9715
  <xsl:choose>
9554
9716
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9555
9717
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9556
- <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>
9557
9720
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9558
9721
  <xsl:choose>
9559
9722
  <xsl:when test="self::text()">
@@ -10156,6 +10319,23 @@
10156
10319
  </xsl:if>
10157
10320
  </xsl:template>
10158
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
+
10159
10339
  <xsl:template name="number-to-words">
10160
10340
  <xsl:param name="number"/>
10161
10341
  <xsl:param name="first"/>