metanorma-un 0.10.4 → 0.10.6

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 -->
@@ -1582,6 +1582,7 @@
1582
1582
  <xsl:attribute-set name="term-name-style">
1583
1583
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1584
1584
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1585
+
1585
1586
  </xsl:attribute-set>
1586
1587
 
1587
1588
  <xsl:attribute-set name="figure-block-style">
@@ -2121,7 +2122,7 @@
2121
2122
  <xsl:apply-templates select="." mode="contents"/>
2122
2123
  </xsl:for-each>
2123
2124
 
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')]]">
2125
+ <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
2126
  <xsl:sort select="@displayorder" data-type="number"/>
2126
2127
  <xsl:apply-templates select="." mode="contents"/>
2127
2128
  </xsl:for-each>
@@ -2550,7 +2551,7 @@
2550
2551
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2551
2552
  </xsl:when>
2552
2553
  <xsl:otherwise>
2553
- <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
2554
+ <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note and dl which render separaterely -->
2554
2555
  </xsl:otherwise>
2555
2556
  </xsl:choose>
2556
2557
 
@@ -3050,7 +3051,7 @@
3050
3051
  <xsl:param name="colwidths"/>
3051
3052
  <xsl:param name="colgroup"/>
3052
3053
 
3053
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3054
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3054
3055
 
3055
3056
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3056
3057
 
@@ -3069,6 +3070,10 @@
3069
3070
  </xsl:choose>
3070
3071
  </xsl:variable>
3071
3072
 
3073
+ <xsl:variable name="table_fn_block">
3074
+ <xsl:call-template name="table_fn_display"/>
3075
+ </xsl:variable>
3076
+
3072
3077
  <xsl:variable name="tableWithNotesAndFootnotes">
3073
3078
 
3074
3079
  <fo:table keep-with-previous="always">
@@ -3114,13 +3119,28 @@
3114
3119
 
3115
3120
  <!-- except gb and bsi -->
3116
3121
 
3122
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
3117
3123
  <xsl:apply-templates select="../*[local-name()='note']"/>
3118
3124
 
3125
+ <xsl:variable name="isDisplayRowSeparator">
3126
+
3127
+ </xsl:variable>
3128
+
3119
3129
  <!-- horizontal row separator -->
3130
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3131
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3132
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3133
+
3134
+ <xsl:call-template name="setBordersTableArray"/>
3135
+ <fo:block font-size="1pt"> </fo:block>
3136
+ </fo:block-container>
3137
+ </xsl:if>
3138
+ </xsl:if>
3120
3139
 
3121
3140
  <!-- fn processing -->
3122
3141
 
3123
- <xsl:call-template name="table_fn_display"/>
3142
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3143
+ <xsl:copy-of select="$table_fn_block"/>
3124
3144
 
3125
3145
  <!-- for PAS display Notes after footnotes -->
3126
3146
 
@@ -3225,7 +3245,7 @@
3225
3245
  <!-- ===================== -->
3226
3246
  <!-- Table's row processing -->
3227
3247
  <!-- ===================== -->
3228
- <!-- row in table header (thead) -->
3248
+ <!-- row in table header (thead) thead/tr -->
3229
3249
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3230
3250
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3231
3251
 
@@ -3237,7 +3257,29 @@
3237
3257
  </fo:table-row>
3238
3258
  </xsl:template>
3239
3259
 
3240
- <!-- row in table footer (tfoot) -->
3260
+ <xsl:template name="setBorderUnderRow">
3261
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3262
+ <xsl:choose>
3263
+ <xsl:when test="$border_under_row_ != ''">
3264
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3265
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3266
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3267
+ <xsl:variable name="border_under_row">
3268
+ <xsl:call-template name="split">
3269
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3270
+ </xsl:call-template>
3271
+ </xsl:variable>
3272
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3273
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3274
+ </xsl:if>
3275
+ </xsl:when>
3276
+ <xsl:otherwise>
3277
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3278
+ </xsl:otherwise>
3279
+ </xsl:choose>
3280
+ </xsl:template>
3281
+
3282
+ <!-- row in table footer (tfoot), tfoot/tr -->
3241
3283
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3242
3284
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3243
3285
 
@@ -3589,8 +3631,16 @@
3589
3631
  <!-- figure's footnotes rendering -->
3590
3632
  <xsl:template name="fn_display_figure">
3591
3633
 
3634
+ <!-- current figure id -->
3635
+ <xsl:variable name="figure_id_">
3636
+ <xsl:value-of select="@id"/>
3637
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3638
+ </xsl:variable>
3639
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3640
+
3641
+ <!-- all footnotes relates to the current figure -->
3592
3642
  <xsl:variable name="references">
3593
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3643
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3594
3644
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3595
3645
  <xsl:apply-templates/>
3596
3646
  </fn>
@@ -3603,91 +3653,93 @@
3603
3653
 
3604
3654
  </xsl:variable>
3605
3655
 
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>
3656
+ <fo:block>
3657
+
3658
+ <!-- current hierarchy is 'figure' element -->
3659
+ <xsl:variable name="following_dl_colwidths">
3660
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3661
+ <xsl:variable name="simple-table">
3662
+ <!-- <xsl:variable name="doc_ns">
3663
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3664
+ </xsl:variable>
3665
+ <xsl:variable name="ns">
3666
+ <xsl:choose>
3667
+ <xsl:when test="normalize-space($doc_ns) != ''">
3668
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3669
+ </xsl:when>
3670
+ <xsl:otherwise>
3671
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3672
+ </xsl:otherwise>
3673
+ </xsl:choose>
3674
+ </xsl:variable> -->
3675
+
3676
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3677
+ <tbody>
3678
+ <xsl:apply-templates mode="dl"/>
3679
+ </tbody>
3680
+ </xsl:for-each>
3681
+ </xsl:variable>
3682
+
3683
+ <xsl:call-template name="calculate-column-widths">
3684
+ <xsl:with-param name="cols-count" select="2"/>
3685
+ <xsl:with-param name="table" select="$simple-table"/>
3686
+ </xsl:call-template>
3687
+
3688
+ </xsl:if>
3612
3689
  </xsl:variable>
3613
- <xsl:variable name="ns">
3690
+
3691
+ <xsl:variable name="maxlength_dt">
3692
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3693
+ <xsl:call-template name="getMaxLength_dt"/>
3694
+ </xsl:for-each>
3695
+ </xsl:variable>
3696
+
3697
+ <fo:table width="95%" table-layout="fixed">
3698
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3699
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3700
+
3701
+ </xsl:if>
3614
3702
  <xsl:choose>
3615
- <xsl:when test="normalize-space($doc_ns) != ''">
3616
- <xsl:value-of select="normalize-space($doc_ns)"/>
3703
+ <!-- if there 'dl', then set same columns width -->
3704
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3705
+ <xsl:call-template name="setColumnWidth_dl">
3706
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3707
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3708
+ </xsl:call-template>
3617
3709
  </xsl:when>
3618
3710
  <xsl:otherwise>
3619
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3711
+ <fo:table-column column-width="5%"/>
3712
+ <fo:table-column column-width="95%"/>
3620
3713
  </xsl:otherwise>
3621
3714
  </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>
3635
-
3636
- </xsl:if>
3637
- </xsl:variable>
3638
-
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>
3715
+ <fo:table-body>
3716
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3717
+ <xsl:variable name="reference" select="@reference"/>
3718
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3719
+ <fo:table-row>
3720
+ <fo:table-cell>
3721
+ <fo:block>
3722
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3723
+ <xsl:value-of select="@reference"/>
3724
+ </fo:inline>
3725
+ </fo:block>
3726
+ </fo:table-cell>
3727
+ <fo:table-cell>
3728
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3729
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3649
3730
 
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'">
3731
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3679
3732
 
3680
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3733
+ </xsl:if>
3734
+ <xsl:copy-of select="./node()"/>
3735
+ </fo:block>
3736
+ </fo:table-cell>
3737
+ </fo:table-row>
3738
+ </xsl:if>
3739
+ </xsl:for-each>
3740
+ </fo:table-body>
3741
+ </fo:table>
3681
3742
 
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
3743
  </fo:block>
3692
3744
  </xsl:if>
3693
3745
 
@@ -3727,6 +3779,8 @@
3727
3779
  <!-- <dl><xsl:copy-of select="."/></dl> -->
3728
3780
  <fo:block-container>
3729
3781
 
3782
+ <xsl:call-template name="setBlockSpanAll"/>
3783
+
3730
3784
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
3731
3785
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
3732
3786
  </xsl:if>
@@ -3763,12 +3817,14 @@
3763
3817
 
3764
3818
  <fo:block margin-bottom="12pt" text-align="left">
3765
3819
 
3766
- <xsl:variable name="title-where">
3820
+ <!-- <xsl:variable name="title-where">
3767
3821
  <xsl:call-template name="getLocalizedString">
3768
3822
  <xsl:with-param name="key">where</xsl:with-param>
3769
3823
  </xsl:call-template>
3770
3824
  </xsl:variable>
3771
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3825
+ <xsl:value-of select="$title-where"/> -->
3826
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3827
+ <xsl:text> </xsl:text>
3772
3828
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3773
3829
  <xsl:text/>
3774
3830
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3778,12 +3834,14 @@
3778
3834
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3779
3835
  <fo:block margin-bottom="12pt" text-align="left">
3780
3836
 
3781
- <xsl:variable name="title-where">
3837
+ <!-- <xsl:variable name="title-where">
3782
3838
  <xsl:call-template name="getLocalizedString">
3783
3839
  <xsl:with-param name="key">where</xsl:with-param>
3784
3840
  </xsl:call-template>
3785
3841
  </xsl:variable>
3786
- <xsl:value-of select="$title-where"/>
3842
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3843
+ <!-- preceding 'p' with word 'where' -->
3844
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3787
3845
  </fo:block>
3788
3846
  </xsl:when> <!-- END: a few components -->
3789
3847
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3966,6 +4024,9 @@
3966
4024
 
3967
4025
  </xsl:template> <!-- END: dl -->
3968
4026
 
4027
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
4028
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
4029
+
3969
4030
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3970
4031
  <xsl:param name="process">false</xsl:param>
3971
4032
  <xsl:if test="$process = 'true'">
@@ -4790,20 +4851,34 @@
4790
4851
 
4791
4852
  <xsl:template name="add-zero-spaces-java">
4792
4853
  <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​')"/>
4854
+
4855
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
4856
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4857
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4858
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4795
4859
  <!-- 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')"/>
4860
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4797
4861
  <!-- 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' -->
4862
+ <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
4863
  <!-- 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' -->
4864
+ <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
4865
  <!-- 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' -->
4866
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4803
4867
  <!-- 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 -->
4868
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4869
+ <!-- add zero-width space (#x200B) after character: '/' -->
4870
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4805
4871
 
4806
- <xsl:value-of select="$text6"/>
4872
+ <xsl:variable name="text9">
4873
+ <xsl:choose>
4874
+ <xsl:when test="$isGenerateTableIF = 'true'">
4875
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4876
+ </xsl:when>
4877
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4878
+ </xsl:choose>
4879
+ </xsl:variable>
4880
+
4881
+ <xsl:value-of select="$text9"/>
4807
4882
  </xsl:template>
4808
4883
 
4809
4884
  <xsl:template name="add-zero-spaces-link-java">
@@ -4811,8 +4886,8 @@
4811
4886
 
4812
4887
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4813
4888
  <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​')"/>
4889
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
4890
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
4816
4891
  <!-- remove zero-width space at the end -->
4817
4892
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4818
4893
  </xsl:template>
@@ -5167,9 +5242,28 @@
5167
5242
  </xsl:variable>
5168
5243
  <xsl:copy-of select="$newRow"/>
5169
5244
 
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>
5245
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5246
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5247
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5248
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5249
+ <xsl:choose>
5250
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5251
+ <xsl:copy-of select="following-sibling::tr"/>
5252
+ </xsl:when>
5253
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5254
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5255
+
5256
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5257
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5258
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5259
+ </xsl:apply-templates>
5260
+ </xsl:when> -->
5261
+ <xsl:otherwise>
5262
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5263
+ <xsl:with-param name="previousRow" select="$newRow"/>
5264
+ </xsl:apply-templates>
5265
+ </xsl:otherwise>
5266
+ </xsl:choose>
5173
5267
  </xsl:template>
5174
5268
  <!-- End mode simple-table-rowspan -->
5175
5269
 
@@ -5332,6 +5426,27 @@
5332
5426
  </xsl:call-template>
5333
5427
  </xsl:template>
5334
5428
 
5429
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5430
+ <xsl:variable name="link">
5431
+ <link_updated>
5432
+ <xsl:variable name="target_text">
5433
+ <xsl:choose>
5434
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5435
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5436
+ </xsl:when>
5437
+ <xsl:otherwise>
5438
+ <xsl:value-of select="normalize-space(@target)"/>
5439
+ </xsl:otherwise>
5440
+ </xsl:choose>
5441
+ </xsl:variable>
5442
+ <xsl:value-of select="$target_text"/>
5443
+ </link_updated>
5444
+ </xsl:variable>
5445
+ <xsl:for-each select="xalan:nodeset($link)/*">
5446
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5447
+ </xsl:for-each>
5448
+ </xsl:template>
5449
+
5335
5450
  <xsl:template name="getFormattingTags">
5336
5451
  <tags>
5337
5452
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5673,7 +5788,7 @@
5673
5788
  </xsl:variable>
5674
5789
  <fo:inline xsl:use-attribute-sets="link-style">
5675
5790
 
5676
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5791
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5677
5792
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5678
5793
  </xsl:if>
5679
5794
 
@@ -5728,13 +5843,17 @@
5728
5843
  </xsl:template>
5729
5844
 
5730
5845
  <xsl:template match="*[local-name() = 'callout']">
5731
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5846
+ <xsl:choose>
5847
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
5848
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
5849
+ </xsl:choose>
5732
5850
  </xsl:template>
5733
5851
 
5734
5852
  <xsl:template match="*[local-name() = 'annotation']">
5735
5853
  <xsl:variable name="annotation-id" select="@id"/>
5736
5854
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
5737
5855
  <fo:block id="{$annotation-id}" white-space="nowrap">
5856
+
5738
5857
  <fo:inline>
5739
5858
  <xsl:apply-templates>
5740
5859
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -5844,6 +5963,10 @@
5844
5963
  <!-- ====== -->
5845
5964
  <!-- ====== -->
5846
5965
 
5966
+ <xsl:template name="setBlockSpanAll">
5967
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
5968
+ </xsl:template>
5969
+
5847
5970
  <!-- ====== -->
5848
5971
  <!-- note -->
5849
5972
  <!-- termnote -->
@@ -5853,6 +5976,8 @@
5853
5976
 
5854
5977
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5855
5978
 
5979
+ <xsl:call-template name="setBlockSpanAll"/>
5980
+
5856
5981
  <xsl:if test="../@type = 'source' or ../@type = 'abbreviation'">
5857
5982
  <xsl:attribute name="border-top">0pt solid black</xsl:attribute>
5858
5983
  </xsl:if>
@@ -5916,6 +6041,8 @@
5916
6041
  <xsl:template match="*[local-name() = 'termnote']">
5917
6042
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
5918
6043
 
6044
+ <xsl:call-template name="setBlockSpanAll"/>
6045
+
5919
6046
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5920
6047
 
5921
6048
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -6050,10 +6177,10 @@
6050
6177
  <fo:block xsl:use-attribute-sets="figure-style">
6051
6178
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
6052
6179
  </fo:block>
6053
- <xsl:call-template name="fn_display_figure"/>
6054
6180
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
6055
6181
  <xsl:call-template name="note"/>
6056
6182
  </xsl:for-each>
6183
+ <xsl:call-template name="fn_display_figure"/>
6057
6184
 
6058
6185
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
6059
6186
 
@@ -6121,7 +6248,13 @@
6121
6248
  </xsl:choose>
6122
6249
  </xsl:variable>
6123
6250
 
6124
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6251
+ <xsl:variable name="image_width_effective">
6252
+
6253
+ <xsl:value-of select="$width_effective"/>
6254
+
6255
+ </xsl:variable>
6256
+
6257
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6125
6258
  <xsl:if test="number($scale) &lt; 100">
6126
6259
 
6127
6260
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -6708,6 +6841,13 @@
6708
6841
  <xsl:when test="$contents_nodes/doc">
6709
6842
  <xsl:choose>
6710
6843
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6844
+
6845
+ <xsl:if test="$contents_nodes/collection">
6846
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6847
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6848
+ </fo:bookmark>
6849
+ </xsl:if>
6850
+
6711
6851
  <xsl:for-each select="$contents_nodes/doc">
6712
6852
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6713
6853
  <xsl:if test="@bundle = 'true'">
@@ -7820,6 +7960,9 @@
7820
7960
  <!-- ====== -->
7821
7961
  <xsl:template match="*[local-name() = 'termexample']">
7822
7962
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
7963
+
7964
+ <xsl:call-template name="setBlockSpanAll"/>
7965
+
7823
7966
  <xsl:apply-templates select="*[local-name()='name']"/>
7824
7967
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7825
7968
  </fo:block>
@@ -7871,6 +8014,8 @@
7871
8014
 
7872
8015
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7873
8016
 
8017
+ <xsl:call-template name="setBlockSpanAll"/>
8018
+
7874
8019
  <xsl:variable name="fo_element">
7875
8020
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7876
8021
  block
@@ -7898,6 +8043,35 @@
7898
8043
  </fo:block-container>
7899
8044
  </xsl:when> <!-- end block -->
7900
8045
 
8046
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
8047
+
8048
+ <xsl:variable name="provisional_distance_between_starts">
8049
+ 7
8050
+ </xsl:variable>
8051
+ <xsl:variable name="indent">
8052
+ 0
8053
+ </xsl:variable>
8054
+
8055
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
8056
+ <fo:list-item>
8057
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
8058
+ <fo:block>
8059
+ <xsl:apply-templates select="*[local-name()='name']">
8060
+ <xsl:with-param name="fo_element">block</xsl:with-param>
8061
+ </xsl:apply-templates>
8062
+ </fo:block>
8063
+ </fo:list-item-label>
8064
+ <fo:list-item-body start-indent="body-start()">
8065
+ <fo:block>
8066
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8067
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8068
+ </xsl:apply-templates>
8069
+ </fo:block>
8070
+ </fo:list-item-body>
8071
+ </fo:list-item>
8072
+ </fo:list-block>
8073
+ </xsl:when> <!-- end list -->
8074
+
7901
8075
  <xsl:otherwise> <!-- inline -->
7902
8076
 
7903
8077
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -7977,6 +8151,11 @@
7977
8151
  </fo:block>
7978
8152
  </fo:block-container>
7979
8153
  </xsl:when>
8154
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
8155
+ <fo:block xsl:use-attribute-sets="example-p-style">
8156
+ <xsl:apply-templates/>
8157
+ </fo:block>
8158
+ </xsl:when>
7980
8159
  <xsl:otherwise>
7981
8160
  <fo:inline xsl:use-attribute-sets="example-p-style">
7982
8161
  <xsl:apply-templates/>
@@ -8094,6 +8273,9 @@
8094
8273
  <!-- ====== -->
8095
8274
  <xsl:template match="*[local-name() = 'quote']">
8096
8275
  <fo:block-container margin-left="0mm">
8276
+
8277
+ <xsl:call-template name="setBlockSpanAll"/>
8278
+
8097
8279
  <xsl:if test="parent::*[local-name() = 'note']">
8098
8280
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
8099
8281
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -8383,6 +8565,8 @@
8383
8565
  <fo:block>
8384
8566
  <xsl:call-template name="setId"/>
8385
8567
 
8568
+ <xsl:call-template name="setBlockSpanAll"/>
8569
+
8386
8570
  <xsl:apply-templates/>
8387
8571
  </fo:block>
8388
8572
  </xsl:template>
@@ -8397,6 +8581,8 @@
8397
8581
  <fo:block break-after="page"/>
8398
8582
  <fo:block id="{@id}">
8399
8583
 
8584
+ <xsl:call-template name="setBlockSpanAll"/>
8585
+
8400
8586
  <xsl:variable name="num"><xsl:number/></xsl:variable>
8401
8587
  <xsl:if test="$num = 1">
8402
8588
  <xsl:attribute name="margin-top">3pt</xsl:attribute>
@@ -8590,9 +8776,47 @@
8590
8776
 
8591
8777
  <fo:list-block xsl:use-attribute-sets="list-style">
8592
8778
 
8593
- <xsl:if test="local-name() = 'ol'">
8594
- <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8779
+ <xsl:variable name="provisional_distance_between_starts_">
8780
+ <attributes xsl:use-attribute-sets="list-style">
8781
+
8782
+ <xsl:if test="local-name() = 'ol'">
8783
+ <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8784
+ </xsl:if>
8785
+
8786
+ </attributes>
8787
+ </xsl:variable>
8788
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8789
+ <xsl:if test="$provisional_distance_between_starts != ''">
8790
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8791
+ </xsl:if>
8792
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8793
+
8794
+ <!-- increase provisional-distance-between-starts for long lists -->
8795
+ <xsl:if test="local-name() = 'ol'">
8796
+ <!-- Examples: xiii), xviii), xxviii) -->
8797
+ <xsl:variable name="item_numbers">
8798
+ <xsl:for-each select="*[local-name() = 'li']">
8799
+ <item><xsl:call-template name="getListItemFormat"/></item>
8800
+ </xsl:for-each>
8801
+ </xsl:variable>
8802
+
8803
+ <xsl:variable name="max_length">
8804
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8805
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8806
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8807
+ </xsl:for-each>
8808
+ </xsl:variable>
8809
+
8810
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8811
+ <xsl:variable name="addon" select="$max_length - 4"/>
8812
+ <xsl:if test="$addon &gt; 0">
8813
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8595
8814
  </xsl:if>
8815
+ <!-- DEBUG -->
8816
+ <!-- <xsl:copy-of select="$item_numbers"/>
8817
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8818
+ <addon><xsl:value-of select="$addon"/></addon> -->
8819
+ </xsl:if>
8596
8820
 
8597
8821
  <xsl:if test="*[local-name() = 'name']">
8598
8822
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9299,6 +9523,8 @@
9299
9523
  <!-- text in the box -->
9300
9524
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
9301
9525
 
9526
+ <xsl:call-template name="setBlockSpanAll"/>
9527
+
9302
9528
  <fo:block xsl:use-attribute-sets="admonition-name-style">
9303
9529
  <xsl:call-template name="displayAdmonitionName"/>
9304
9530
  </fo:block>
@@ -9480,6 +9706,16 @@
9480
9706
  <xsl:apply-templates mode="update_xml_step1"/>
9481
9707
  </xsl:copy>
9482
9708
  </xsl:template>
9709
+
9710
+ <!-- remove semantic xml -->
9711
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
9712
+
9713
+ <!-- remove image/emf -->
9714
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
9715
+
9716
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
9717
+ <xsl:copy-of select="."/>
9718
+ </xsl:template>
9483
9719
  <!-- =========================================================================== -->
9484
9720
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9485
9721
  <!-- =========================================================================== -->
@@ -9501,7 +9737,7 @@
9501
9737
 
9502
9738
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
9503
9739
 
9504
- <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
9740
+ <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
9505
9741
 
9506
9742
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9507
9743
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -9531,7 +9767,7 @@
9531
9767
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9532
9768
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9533
9769
  <!-- add &lt; and &gt; to \S -->
9534
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9770
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9535
9771
  <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
9772
  <xsl:variable name="text3">
9537
9773
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9553,7 +9789,8 @@
9553
9789
  <xsl:choose>
9554
9790
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9555
9791
  <!-- 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>
9792
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9793
+ <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
9794
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9558
9795
  <xsl:choose>
9559
9796
  <xsl:when test="self::text()">
@@ -9574,6 +9811,10 @@
9574
9811
 
9575
9812
  </xsl:template>
9576
9813
 
9814
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
9815
+ <xsl:copy-of select="."/>
9816
+ </xsl:template>
9817
+
9577
9818
  <xsl:template name="replace_text_tags">
9578
9819
  <xsl:param name="tag_open"/>
9579
9820
  <xsl:param name="tag_close"/>
@@ -9600,6 +9841,194 @@
9600
9841
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
9601
9842
  <!-- ===================================== -->
9602
9843
 
9844
+ <!-- ===================================== -->
9845
+ <!-- ===================================== -->
9846
+ <!-- Make linear XML (need for landscape orientation) -->
9847
+ <!-- ===================================== -->
9848
+ <!-- ===================================== -->
9849
+ <xsl:template match="@*|node()" mode="linear_xml">
9850
+ <xsl:copy>
9851
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
9852
+ </xsl:copy>
9853
+ </xsl:template>
9854
+
9855
+ <xsl:template match="processing-instruction()" mode="linear_xml">
9856
+ <xsl:copy-of select="."/>
9857
+ </xsl:template>
9858
+
9859
+ <!-- From:
9860
+ <clause>
9861
+ <title>...</title>
9862
+ <p>...</p>
9863
+ </clause>
9864
+ To:
9865
+ <clause/>
9866
+ <title>...</title>
9867
+ <p>...</p>
9868
+ -->
9869
+ <xsl:template match="*[local-name() = 'foreword'] | *[local-name() = 'foreword']//*[local-name() = 'clause'] | *[local-name() = 'preface']//*[local-name() = 'clause'][not(@type = 'corrigenda') and not(@type = 'policy') and not(@type = 'related-refs')] | *[local-name() = 'introduction'] | *[local-name() = 'introduction']//*[local-name() = 'clause'] | *[local-name() = 'sections']//*[local-name() = 'clause'] | *[local-name() = 'annex'] | *[local-name() = 'annex']//*[local-name() = 'clause'] | *[local-name() = 'references'][not(@hidden = 'true')] | *[local-name() = 'bibliography']/*[local-name() = 'clause'] | *[local-name() = 'colophon'] | *[local-name() = 'colophon']//*[local-name() = 'clause'] | *[local-name()='sections']//*[local-name()='terms'] | *[local-name()='sections']//*[local-name()='definitions'] | *[local-name()='annex']//*[local-name()='definitions']" mode="linear_xml" name="clause_linear">
9870
+
9871
+ <xsl:copy>
9872
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9873
+
9874
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9875
+
9876
+ <xsl:if test="local-name() = 'foreword' or local-name() = 'introduction' or local-name(..) = 'preface' or local-name(..) = 'sections' or (local-name() = 'references' and parent::*[local-name() = 'bibliography']) or (local-name() = 'clause' and parent::*[local-name() = 'bibliography']) or local-name() = 'annex' or local-name(..) = 'annex' or local-name(..) = 'colophon'">
9877
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9878
+ </xsl:if>
9879
+ </xsl:copy>
9880
+
9881
+ <xsl:apply-templates mode="linear_xml"/>
9882
+ </xsl:template>
9883
+
9884
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
9885
+ <xsl:copy>
9886
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9887
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9888
+ <xsl:variable name="level">
9889
+ <xsl:call-template name="getLevel"/>
9890
+ </xsl:variable>
9891
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9892
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
9893
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
9894
+ </xsl:copy>
9895
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
9896
+ </xsl:template>
9897
+
9898
+ <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2">
9899
+ <xsl:copy>
9900
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9901
+
9902
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9903
+
9904
+ <xsl:variable name="level">
9905
+ <xsl:call-template name="getLevel"/>
9906
+ </xsl:variable>
9907
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9908
+
9909
+ <xsl:if test="parent::*[local-name() = 'annex']">
9910
+ <xsl:attribute name="depth">1</xsl:attribute>
9911
+ </xsl:if>
9912
+
9913
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
9914
+ <xsl:copy-of select="../@inline-header"/>
9915
+ </xsl:if>
9916
+
9917
+ <xsl:attribute name="ancestor">
9918
+ <xsl:choose>
9919
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
9920
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
9921
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
9922
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
9923
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
9924
+ </xsl:choose>
9925
+ </xsl:attribute>
9926
+
9927
+ <xsl:apply-templates mode="linear_xml"/>
9928
+ </xsl:copy>
9929
+ </xsl:template>
9930
+
9931
+ <!-- add @to = figure, table, clause -->
9932
+ <!-- add @depth = from -->
9933
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
9934
+ <xsl:copy>
9935
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9936
+ <xsl:variable name="target" select="@target"/>
9937
+ <xsl:attribute name="to">
9938
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
9939
+ </xsl:attribute>
9940
+ <xsl:attribute name="depth">
9941
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
9942
+ </xsl:attribute>
9943
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9944
+ </xsl:copy>
9945
+ </xsl:template>
9946
+
9947
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
9948
+ <xsl:choose>
9949
+ <xsl:when test="contains(., $non_breaking_hyphen)">
9950
+ <xsl:call-template name="replaceChar">
9951
+ <xsl:with-param name="text" select="."/>
9952
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
9953
+ <xsl:with-param name="by" select="'-'"/>
9954
+ </xsl:call-template>
9955
+ </xsl:when>
9956
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
9957
+ </xsl:choose>
9958
+ </xsl:template>
9959
+
9960
+ <xsl:template name="replaceChar">
9961
+ <xsl:param name="text"/>
9962
+ <xsl:param name="replace"/>
9963
+ <xsl:param name="by"/>
9964
+ <xsl:choose>
9965
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
9966
+ <xsl:value-of select="$text"/>
9967
+ </xsl:when>
9968
+ <xsl:when test="contains($text, $replace)">
9969
+ <xsl:value-of select="substring-before($text,$replace)"/>
9970
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
9971
+ <xsl:call-template name="replaceChar">
9972
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
9973
+ <xsl:with-param name="replace" select="$replace"/>
9974
+ <xsl:with-param name="by" select="$by"/>
9975
+ </xsl:call-template>
9976
+ </xsl:when>
9977
+ <xsl:otherwise>
9978
+ <xsl:value-of select="$text"/>
9979
+ </xsl:otherwise>
9980
+ </xsl:choose>
9981
+ </xsl:template>
9982
+
9983
+ <xsl:template match="*[local-name() = 'inlineChar']">
9984
+ <fo:inline><xsl:value-of select="."/></fo:inline>
9985
+ </xsl:template>
9986
+
9987
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
9988
+ <!--
9989
+ <fn reference="1">
9990
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
9991
+ </fn>
9992
+ -->
9993
+ <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" mode="linear_xml" name="linear_xml_fn">
9994
+ <xsl:variable name="p_fn_">
9995
+ <xsl:call-template name="get_fn_list"/>
9996
+ </xsl:variable>
9997
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9998
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9999
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
10000
+ <xsl:variable name="reference" select="@reference"/>
10001
+ <!-- fn sequence number in document -->
10002
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
10003
+
10004
+ <xsl:copy>
10005
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10006
+ <!-- put actual reference number -->
10007
+ <xsl:attribute name="current_fn_number">
10008
+ <xsl:value-of select="$current_fn_number"/>
10009
+ </xsl:attribute>
10010
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
10011
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
10012
+ </xsl:attribute>
10013
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10014
+ </xsl:copy>
10015
+ </xsl:template>
10016
+
10017
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
10018
+ <xsl:copy>
10019
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10020
+ <xsl:if test="@depth = '1'">
10021
+ <xsl:attribute name="mainsection">true</xsl:attribute>
10022
+ </xsl:if>
10023
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10024
+ </xsl:copy>
10025
+ </xsl:template>
10026
+ <!-- ===================================== -->
10027
+ <!-- ===================================== -->
10028
+ <!-- END: Make linear XML (need for landscape orientation) -->
10029
+ <!-- ===================================== -->
10030
+ <!-- ===================================== -->
10031
+
9603
10032
  <!-- for correct rendering combining chars -->
9604
10033
  <xsl:template match="*[local-name() = 'lang_none']">
9605
10034
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -10156,6 +10585,23 @@
10156
10585
  </xsl:if>
10157
10586
  </xsl:template>
10158
10587
 
10588
+ <xsl:template name="setBlockAttributes">
10589
+ <xsl:param name="text_align_default">left</xsl:param>
10590
+ <xsl:call-template name="setTextAlignment">
10591
+ <xsl:with-param name="default" select="$text_align_default"/>
10592
+ </xsl:call-template>
10593
+
10594
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10595
+ <!-- Example: keep-lines-together="true" -->
10596
+ <xsl:if test="@keep-lines-together = 'true'">
10597
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10598
+ </xsl:if>
10599
+ <!-- Example: keep-with-next="true" -->
10600
+ <xsl:if test="@keep-with-next = 'true'">
10601
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10602
+ </xsl:if>
10603
+ </xsl:template>
10604
+
10159
10605
  <xsl:template name="number-to-words">
10160
10606
  <xsl:param name="number"/>
10161
10607
  <xsl:param name="first"/>