metanorma-iho 0.7.5 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1373,6 +1373,7 @@
1373
1373
 
1374
1374
  0.5pt solid black
1375
1375
 
1376
+
1376
1377
  </xsl:variable>
1377
1378
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
1378
1379
 
@@ -1432,7 +1433,6 @@
1432
1433
 
1433
1434
  <xsl:attribute-set name="table-header-cell-style">
1434
1435
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1435
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1436
1436
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1437
1437
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1438
1438
  <xsl:attribute name="display-align">center</xsl:attribute>
@@ -1447,7 +1447,6 @@
1447
1447
 
1448
1448
  <xsl:attribute-set name="table-cell-style">
1449
1449
  <xsl:attribute name="display-align">center</xsl:attribute>
1450
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1451
1450
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1452
1451
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1453
1452
 
@@ -1661,6 +1660,7 @@
1661
1660
  <xsl:attribute-set name="term-name-style">
1662
1661
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1663
1662
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1663
+
1664
1664
  </xsl:attribute-set>
1665
1665
 
1666
1666
  <xsl:attribute-set name="figure-block-style">
@@ -2205,7 +2205,7 @@
2205
2205
  <xsl:apply-templates select="." mode="contents"/>
2206
2206
  </xsl:for-each>
2207
2207
 
2208
- <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')]]">
2208
+ <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]">
2209
2209
  <xsl:sort select="@displayorder" data-type="number"/>
2210
2210
  <xsl:apply-templates select="." mode="contents"/>
2211
2211
  </xsl:for-each>
@@ -2611,7 +2611,7 @@
2611
2611
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2612
2612
  </xsl:when>
2613
2613
  <xsl:otherwise>
2614
- <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 -->
2614
+ <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 -->
2615
2615
  </xsl:otherwise>
2616
2616
  </xsl:choose>
2617
2617
 
@@ -3114,7 +3114,7 @@
3114
3114
  <xsl:param name="colwidths"/>
3115
3115
  <xsl:param name="colgroup"/>
3116
3116
 
3117
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3117
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3118
3118
 
3119
3119
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3120
3120
 
@@ -3133,6 +3133,10 @@
3133
3133
  </xsl:choose>
3134
3134
  </xsl:variable>
3135
3135
 
3136
+ <xsl:variable name="table_fn_block">
3137
+ <xsl:call-template name="table_fn_display"/>
3138
+ </xsl:variable>
3139
+
3136
3140
  <xsl:variable name="tableWithNotesAndFootnotes">
3137
3141
 
3138
3142
  <fo:table keep-with-previous="always">
@@ -3178,13 +3182,28 @@
3178
3182
 
3179
3183
  <!-- except gb and bsi -->
3180
3184
 
3185
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
3181
3186
  <xsl:apply-templates select="../*[local-name()='note']"/>
3182
3187
 
3188
+ <xsl:variable name="isDisplayRowSeparator">
3189
+
3190
+ </xsl:variable>
3191
+
3183
3192
  <!-- horizontal row separator -->
3193
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3194
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3195
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3196
+
3197
+ <xsl:call-template name="setBordersTableArray"/>
3198
+ <fo:block font-size="1pt"> </fo:block>
3199
+ </fo:block-container>
3200
+ </xsl:if>
3201
+ </xsl:if>
3184
3202
 
3185
3203
  <!-- fn processing -->
3186
3204
 
3187
- <xsl:call-template name="table_fn_display"/>
3205
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3206
+ <xsl:copy-of select="$table_fn_block"/>
3188
3207
 
3189
3208
  <!-- for PAS display Notes after footnotes -->
3190
3209
 
@@ -3289,7 +3308,7 @@
3289
3308
  <!-- ===================== -->
3290
3309
  <!-- Table's row processing -->
3291
3310
  <!-- ===================== -->
3292
- <!-- row in table header (thead) -->
3311
+ <!-- row in table header (thead) thead/tr -->
3293
3312
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3294
3313
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3295
3314
 
@@ -3301,7 +3320,29 @@
3301
3320
  </fo:table-row>
3302
3321
  </xsl:template>
3303
3322
 
3304
- <!-- row in table footer (tfoot) -->
3323
+ <xsl:template name="setBorderUnderRow">
3324
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3325
+ <xsl:choose>
3326
+ <xsl:when test="$border_under_row_ != ''">
3327
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3328
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3329
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3330
+ <xsl:variable name="border_under_row">
3331
+ <xsl:call-template name="split">
3332
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3333
+ </xsl:call-template>
3334
+ </xsl:variable>
3335
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3336
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3337
+ </xsl:if>
3338
+ </xsl:when>
3339
+ <xsl:otherwise>
3340
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3341
+ </xsl:otherwise>
3342
+ </xsl:choose>
3343
+ </xsl:template>
3344
+
3345
+ <!-- row in table footer (tfoot), tfoot/tr -->
3305
3346
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3306
3347
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3307
3348
 
@@ -3629,8 +3670,16 @@
3629
3670
  <!-- figure's footnotes rendering -->
3630
3671
  <xsl:template name="fn_display_figure">
3631
3672
 
3673
+ <!-- current figure id -->
3674
+ <xsl:variable name="figure_id_">
3675
+ <xsl:value-of select="@id"/>
3676
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3677
+ </xsl:variable>
3678
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3679
+
3680
+ <!-- all footnotes relates to the current figure -->
3632
3681
  <xsl:variable name="references">
3633
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3682
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3634
3683
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3635
3684
  <xsl:apply-templates/>
3636
3685
  </fn>
@@ -3643,91 +3692,93 @@
3643
3692
 
3644
3693
  </xsl:variable>
3645
3694
 
3646
- <!-- current hierarchy is 'figure' element -->
3647
- <xsl:variable name="following_dl_colwidths">
3648
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3649
- <xsl:variable name="simple-table">
3650
- <!-- <xsl:variable name="doc_ns">
3651
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3695
+ <fo:block>
3696
+
3697
+ <!-- current hierarchy is 'figure' element -->
3698
+ <xsl:variable name="following_dl_colwidths">
3699
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3700
+ <xsl:variable name="simple-table">
3701
+ <!-- <xsl:variable name="doc_ns">
3702
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3703
+ </xsl:variable>
3704
+ <xsl:variable name="ns">
3705
+ <xsl:choose>
3706
+ <xsl:when test="normalize-space($doc_ns) != ''">
3707
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3708
+ </xsl:when>
3709
+ <xsl:otherwise>
3710
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3711
+ </xsl:otherwise>
3712
+ </xsl:choose>
3713
+ </xsl:variable> -->
3714
+
3715
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3716
+ <tbody>
3717
+ <xsl:apply-templates mode="dl"/>
3718
+ </tbody>
3719
+ </xsl:for-each>
3720
+ </xsl:variable>
3721
+
3722
+ <xsl:call-template name="calculate-column-widths">
3723
+ <xsl:with-param name="cols-count" select="2"/>
3724
+ <xsl:with-param name="table" select="$simple-table"/>
3725
+ </xsl:call-template>
3726
+
3727
+ </xsl:if>
3652
3728
  </xsl:variable>
3653
- <xsl:variable name="ns">
3729
+
3730
+ <xsl:variable name="maxlength_dt">
3731
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3732
+ <xsl:call-template name="getMaxLength_dt"/>
3733
+ </xsl:for-each>
3734
+ </xsl:variable>
3735
+
3736
+ <fo:table width="95%" table-layout="fixed">
3737
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3738
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3739
+
3740
+ </xsl:if>
3654
3741
  <xsl:choose>
3655
- <xsl:when test="normalize-space($doc_ns) != ''">
3656
- <xsl:value-of select="normalize-space($doc_ns)"/>
3742
+ <!-- if there 'dl', then set same columns width -->
3743
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3744
+ <xsl:call-template name="setColumnWidth_dl">
3745
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3746
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3747
+ </xsl:call-template>
3657
3748
  </xsl:when>
3658
3749
  <xsl:otherwise>
3659
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3750
+ <fo:table-column column-width="5%"/>
3751
+ <fo:table-column column-width="95%"/>
3660
3752
  </xsl:otherwise>
3661
3753
  </xsl:choose>
3662
- </xsl:variable> -->
3663
-
3664
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3665
- <tbody>
3666
- <xsl:apply-templates mode="dl"/>
3667
- </tbody>
3668
- </xsl:for-each>
3669
- </xsl:variable>
3670
-
3671
- <xsl:call-template name="calculate-column-widths">
3672
- <xsl:with-param name="cols-count" select="2"/>
3673
- <xsl:with-param name="table" select="$simple-table"/>
3674
- </xsl:call-template>
3675
-
3676
- </xsl:if>
3677
- </xsl:variable>
3678
-
3679
- <xsl:variable name="maxlength_dt">
3680
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3681
- <xsl:call-template name="getMaxLength_dt"/>
3682
- </xsl:for-each>
3683
- </xsl:variable>
3684
-
3685
- <fo:block>
3686
- <fo:table width="95%" table-layout="fixed">
3687
- <xsl:if test="normalize-space($key_iso) = 'true'">
3688
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3754
+ <fo:table-body>
3755
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3756
+ <xsl:variable name="reference" select="@reference"/>
3757
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3758
+ <fo:table-row>
3759
+ <fo:table-cell>
3760
+ <fo:block>
3761
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3762
+ <xsl:value-of select="@reference"/>
3763
+ </fo:inline>
3764
+ </fo:block>
3765
+ </fo:table-cell>
3766
+ <fo:table-cell>
3767
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3768
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3689
3769
 
3690
- </xsl:if>
3691
- <xsl:choose>
3692
- <!-- if there 'dl', then set same columns width -->
3693
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3694
- <xsl:call-template name="setColumnWidth_dl">
3695
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3696
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3697
- </xsl:call-template>
3698
- </xsl:when>
3699
- <xsl:otherwise>
3700
- <fo:table-column column-width="15%"/>
3701
- <fo:table-column column-width="85%"/>
3702
- </xsl:otherwise>
3703
- </xsl:choose>
3704
- <fo:table-body>
3705
- <xsl:for-each select="xalan:nodeset($references)//fn">
3706
- <xsl:variable name="reference" select="@reference"/>
3707
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3708
- <fo:table-row>
3709
- <fo:table-cell>
3710
- <fo:block>
3711
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3712
- <xsl:value-of select="@reference"/>
3713
- </fo:inline>
3714
- </fo:block>
3715
- </fo:table-cell>
3716
- <fo:table-cell>
3717
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3718
- <xsl:if test="normalize-space($key_iso) = 'true'">
3770
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3719
3771
 
3720
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3772
+ </xsl:if>
3773
+ <xsl:copy-of select="./node()"/>
3774
+ </fo:block>
3775
+ </fo:table-cell>
3776
+ </fo:table-row>
3777
+ </xsl:if>
3778
+ </xsl:for-each>
3779
+ </fo:table-body>
3780
+ </fo:table>
3721
3781
 
3722
- </xsl:if>
3723
- <xsl:copy-of select="./node()"/>
3724
- </fo:block>
3725
- </fo:table-cell>
3726
- </fo:table-row>
3727
- </xsl:if>
3728
- </xsl:for-each>
3729
- </fo:table-body>
3730
- </fo:table>
3731
3782
  </fo:block>
3732
3783
  </xsl:if>
3733
3784
 
@@ -3767,6 +3818,8 @@
3767
3818
  <!-- <dl><xsl:copy-of select="."/></dl> -->
3768
3819
  <fo:block-container>
3769
3820
 
3821
+ <xsl:call-template name="setBlockSpanAll"/>
3822
+
3770
3823
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
3771
3824
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
3772
3825
  </xsl:if>
@@ -3803,12 +3856,14 @@
3803
3856
 
3804
3857
  <fo:block margin-bottom="12pt" text-align="left">
3805
3858
 
3806
- <xsl:variable name="title-where">
3859
+ <!-- <xsl:variable name="title-where">
3807
3860
  <xsl:call-template name="getLocalizedString">
3808
3861
  <xsl:with-param name="key">where</xsl:with-param>
3809
3862
  </xsl:call-template>
3810
3863
  </xsl:variable>
3811
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3864
+ <xsl:value-of select="$title-where"/> -->
3865
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3866
+ <xsl:text> </xsl:text>
3812
3867
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3813
3868
  <xsl:text/>
3814
3869
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3818,12 +3873,14 @@
3818
3873
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3819
3874
  <fo:block margin-bottom="12pt" text-align="left">
3820
3875
 
3821
- <xsl:variable name="title-where">
3876
+ <!-- <xsl:variable name="title-where">
3822
3877
  <xsl:call-template name="getLocalizedString">
3823
3878
  <xsl:with-param name="key">where</xsl:with-param>
3824
3879
  </xsl:call-template>
3825
3880
  </xsl:variable>
3826
- <xsl:value-of select="$title-where"/>
3881
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3882
+ <!-- preceding 'p' with word 'where' -->
3883
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3827
3884
  </fo:block>
3828
3885
  </xsl:when> <!-- END: a few components -->
3829
3886
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -4012,6 +4069,9 @@
4012
4069
 
4013
4070
  </xsl:template> <!-- END: dl -->
4014
4071
 
4072
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
4073
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
4074
+
4015
4075
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4016
4076
  <xsl:param name="process">false</xsl:param>
4017
4077
  <xsl:if test="$process = 'true'">
@@ -4911,8 +4971,8 @@
4911
4971
 
4912
4972
  <!-- add zero-width space (#x200B) after dot with next non-digit -->
4913
4973
  <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4914
- <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right -->
4915
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→)','$1​')"/>
4974
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4975
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4916
4976
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4917
4977
  <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4918
4978
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
@@ -4923,8 +4983,19 @@
4923
4983
  <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4924
4984
  <!-- add zero-width space (#x200B) after character: , -->
4925
4985
  <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4986
+ <!-- add zero-width space (#x200B) after character: '/' -->
4987
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4926
4988
 
4927
- <xsl:value-of select="$text7"/>
4989
+ <xsl:variable name="text9">
4990
+ <xsl:choose>
4991
+ <xsl:when test="$isGenerateTableIF = 'true'">
4992
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4993
+ </xsl:when>
4994
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4995
+ </xsl:choose>
4996
+ </xsl:variable>
4997
+
4998
+ <xsl:value-of select="$text9"/>
4928
4999
  </xsl:template>
4929
5000
 
4930
5001
  <xsl:template name="add-zero-spaces-link-java">
@@ -4932,8 +5003,8 @@
4932
5003
 
4933
5004
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4934
5005
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4935
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4936
- <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
5006
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
5007
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
4937
5008
  <!-- remove zero-width space at the end -->
4938
5009
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4939
5010
  </xsl:template>
@@ -5288,9 +5359,28 @@
5288
5359
  </xsl:variable>
5289
5360
  <xsl:copy-of select="$newRow"/>
5290
5361
 
5291
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5292
- <xsl:with-param name="previousRow" select="$newRow"/>
5293
- </xsl:apply-templates>
5362
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5363
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5364
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5365
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5366
+ <xsl:choose>
5367
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5368
+ <xsl:copy-of select="following-sibling::tr"/>
5369
+ </xsl:when>
5370
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5371
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5372
+
5373
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5374
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5375
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5376
+ </xsl:apply-templates>
5377
+ </xsl:when> -->
5378
+ <xsl:otherwise>
5379
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5380
+ <xsl:with-param name="previousRow" select="$newRow"/>
5381
+ </xsl:apply-templates>
5382
+ </xsl:otherwise>
5383
+ </xsl:choose>
5294
5384
  </xsl:template>
5295
5385
  <!-- End mode simple-table-rowspan -->
5296
5386
 
@@ -5453,6 +5543,27 @@
5453
5543
  </xsl:call-template>
5454
5544
  </xsl:template>
5455
5545
 
5546
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5547
+ <xsl:variable name="link">
5548
+ <link_updated>
5549
+ <xsl:variable name="target_text">
5550
+ <xsl:choose>
5551
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5552
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5553
+ </xsl:when>
5554
+ <xsl:otherwise>
5555
+ <xsl:value-of select="normalize-space(@target)"/>
5556
+ </xsl:otherwise>
5557
+ </xsl:choose>
5558
+ </xsl:variable>
5559
+ <xsl:value-of select="$target_text"/>
5560
+ </link_updated>
5561
+ </xsl:variable>
5562
+ <xsl:for-each select="xalan:nodeset($link)/*">
5563
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5564
+ </xsl:for-each>
5565
+ </xsl:template>
5566
+
5456
5567
  <xsl:template name="getFormattingTags">
5457
5568
  <tags>
5458
5569
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5794,7 +5905,7 @@
5794
5905
  </xsl:variable>
5795
5906
  <fo:inline xsl:use-attribute-sets="link-style">
5796
5907
 
5797
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5908
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5798
5909
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5799
5910
  </xsl:if>
5800
5911
 
@@ -5849,13 +5960,17 @@
5849
5960
  </xsl:template>
5850
5961
 
5851
5962
  <xsl:template match="*[local-name() = 'callout']">
5852
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5963
+ <xsl:choose>
5964
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
5965
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
5966
+ </xsl:choose>
5853
5967
  </xsl:template>
5854
5968
 
5855
5969
  <xsl:template match="*[local-name() = 'annotation']">
5856
5970
  <xsl:variable name="annotation-id" select="@id"/>
5857
5971
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
5858
5972
  <fo:block id="{$annotation-id}" white-space="nowrap">
5973
+
5859
5974
  <fo:inline>
5860
5975
  <xsl:apply-templates>
5861
5976
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -5960,6 +6075,10 @@
5960
6075
  <!-- ====== -->
5961
6076
  <!-- ====== -->
5962
6077
 
6078
+ <xsl:template name="setBlockSpanAll">
6079
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
6080
+ </xsl:template>
6081
+
5963
6082
  <!-- ====== -->
5964
6083
  <!-- note -->
5965
6084
  <!-- termnote -->
@@ -5969,6 +6088,8 @@
5969
6088
 
5970
6089
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5971
6090
 
6091
+ <xsl:call-template name="setBlockSpanAll"/>
6092
+
5972
6093
  <fo:block-container margin-left="0mm" margin-right="0mm">
5973
6094
 
5974
6095
  <fo:block>
@@ -6019,6 +6140,8 @@
6019
6140
  <xsl:template match="*[local-name() = 'termnote']">
6020
6141
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
6021
6142
 
6143
+ <xsl:call-template name="setBlockSpanAll"/>
6144
+
6022
6145
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
6023
6146
 
6024
6147
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -6151,10 +6274,10 @@
6151
6274
  <fo:block xsl:use-attribute-sets="figure-style">
6152
6275
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
6153
6276
  </fo:block>
6154
- <xsl:call-template name="fn_display_figure"/>
6155
6277
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
6156
6278
  <xsl:call-template name="note"/>
6157
6279
  </xsl:for-each>
6280
+ <xsl:call-template name="fn_display_figure"/>
6158
6281
 
6159
6282
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
6160
6283
 
@@ -6217,7 +6340,13 @@
6217
6340
  </xsl:choose>
6218
6341
  </xsl:variable>
6219
6342
 
6220
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6343
+ <xsl:variable name="image_width_effective">
6344
+
6345
+ <xsl:value-of select="$width_effective"/>
6346
+
6347
+ </xsl:variable>
6348
+
6349
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6221
6350
  <xsl:if test="number($scale) &lt; 100">
6222
6351
 
6223
6352
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -6804,6 +6933,13 @@
6804
6933
  <xsl:when test="$contents_nodes/doc">
6805
6934
  <xsl:choose>
6806
6935
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6936
+
6937
+ <xsl:if test="$contents_nodes/collection">
6938
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6939
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6940
+ </fo:bookmark>
6941
+ </xsl:if>
6942
+
6807
6943
  <xsl:for-each select="$contents_nodes/doc">
6808
6944
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6809
6945
  <xsl:if test="@bundle = 'true'">
@@ -7916,6 +8052,9 @@
7916
8052
  <!-- ====== -->
7917
8053
  <xsl:template match="*[local-name() = 'termexample']">
7918
8054
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
8055
+
8056
+ <xsl:call-template name="setBlockSpanAll"/>
8057
+
7919
8058
  <xsl:apply-templates select="*[local-name()='name']"/>
7920
8059
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7921
8060
  </fo:block>
@@ -7967,6 +8106,8 @@
7967
8106
 
7968
8107
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7969
8108
 
8109
+ <xsl:call-template name="setBlockSpanAll"/>
8110
+
7970
8111
  <xsl:variable name="fo_element">
7971
8112
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7972
8113
  inline
@@ -7994,6 +8135,35 @@
7994
8135
  </fo:block-container>
7995
8136
  </xsl:when> <!-- end block -->
7996
8137
 
8138
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
8139
+
8140
+ <xsl:variable name="provisional_distance_between_starts">
8141
+ 7
8142
+ </xsl:variable>
8143
+ <xsl:variable name="indent">
8144
+ 0
8145
+ </xsl:variable>
8146
+
8147
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
8148
+ <fo:list-item>
8149
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
8150
+ <fo:block>
8151
+ <xsl:apply-templates select="*[local-name()='name']">
8152
+ <xsl:with-param name="fo_element">block</xsl:with-param>
8153
+ </xsl:apply-templates>
8154
+ </fo:block>
8155
+ </fo:list-item-label>
8156
+ <fo:list-item-body start-indent="body-start()">
8157
+ <fo:block>
8158
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
8159
+ <xsl:with-param name="fo_element" select="$fo_element"/>
8160
+ </xsl:apply-templates>
8161
+ </fo:block>
8162
+ </fo:list-item-body>
8163
+ </fo:list-item>
8164
+ </fo:list-block>
8165
+ </xsl:when> <!-- end list -->
8166
+
7997
8167
  <xsl:otherwise> <!-- inline -->
7998
8168
 
7999
8169
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -8069,6 +8239,11 @@
8069
8239
  </fo:block>
8070
8240
  </fo:block-container>
8071
8241
  </xsl:when>
8242
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
8243
+ <fo:block xsl:use-attribute-sets="example-p-style">
8244
+ <xsl:apply-templates/>
8245
+ </fo:block>
8246
+ </xsl:when>
8072
8247
  <xsl:otherwise>
8073
8248
  <fo:inline xsl:use-attribute-sets="example-p-style">
8074
8249
  <xsl:apply-templates/>
@@ -8186,6 +8361,9 @@
8186
8361
  <!-- ====== -->
8187
8362
  <xsl:template match="*[local-name() = 'quote']">
8188
8363
  <fo:block-container margin-left="0mm">
8364
+
8365
+ <xsl:call-template name="setBlockSpanAll"/>
8366
+
8189
8367
  <xsl:if test="parent::*[local-name() = 'note']">
8190
8368
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
8191
8369
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -8472,6 +8650,8 @@
8472
8650
  <fo:block>
8473
8651
  <xsl:call-template name="setId"/>
8474
8652
 
8653
+ <xsl:call-template name="setBlockSpanAll"/>
8654
+
8475
8655
  <xsl:apply-templates/>
8476
8656
  </fo:block>
8477
8657
  </xsl:template>
@@ -8486,6 +8666,8 @@
8486
8666
  <fo:block break-after="page"/>
8487
8667
  <fo:block id="{@id}">
8488
8668
 
8669
+ <xsl:call-template name="setBlockSpanAll"/>
8670
+
8489
8671
  </fo:block>
8490
8672
  <xsl:apply-templates/>
8491
8673
  </xsl:template>
@@ -8677,6 +8859,44 @@
8677
8859
 
8678
8860
  <fo:list-block xsl:use-attribute-sets="list-style">
8679
8861
 
8862
+ <xsl:variable name="provisional_distance_between_starts_">
8863
+ <attributes xsl:use-attribute-sets="list-style">
8864
+
8865
+ </attributes>
8866
+ </xsl:variable>
8867
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8868
+ <xsl:if test="$provisional_distance_between_starts != ''">
8869
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8870
+ </xsl:if>
8871
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8872
+
8873
+ <!-- increase provisional-distance-between-starts for long lists -->
8874
+ <xsl:if test="local-name() = 'ol'">
8875
+ <!-- Examples: xiii), xviii), xxviii) -->
8876
+ <xsl:variable name="item_numbers">
8877
+ <xsl:for-each select="*[local-name() = 'li']">
8878
+ <item><xsl:call-template name="getListItemFormat"/></item>
8879
+ </xsl:for-each>
8880
+ </xsl:variable>
8881
+
8882
+ <xsl:variable name="max_length">
8883
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8884
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8885
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8886
+ </xsl:for-each>
8887
+ </xsl:variable>
8888
+
8889
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8890
+ <xsl:variable name="addon" select="$max_length - 4"/>
8891
+ <xsl:if test="$addon &gt; 0">
8892
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8893
+ </xsl:if>
8894
+ <!-- DEBUG -->
8895
+ <!-- <xsl:copy-of select="$item_numbers"/>
8896
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8897
+ <addon><xsl:value-of select="$addon"/></addon> -->
8898
+ </xsl:if>
8899
+
8680
8900
  <xsl:if test="*[local-name() = 'name']">
8681
8901
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
8682
8902
  </xsl:if>
@@ -9407,6 +9627,8 @@
9407
9627
  <!-- text in the box -->
9408
9628
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
9409
9629
 
9630
+ <xsl:call-template name="setBlockSpanAll"/>
9631
+
9410
9632
  <fo:block-container xsl:use-attribute-sets="admonition-container-style">
9411
9633
 
9412
9634
  <fo:block xsl:use-attribute-sets="admonition-name-style">
@@ -9582,6 +9804,16 @@
9582
9804
  <xsl:apply-templates mode="update_xml_step1"/>
9583
9805
  </xsl:copy>
9584
9806
  </xsl:template>
9807
+
9808
+ <!-- remove semantic xml -->
9809
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
9810
+
9811
+ <!-- remove image/emf -->
9812
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
9813
+
9814
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
9815
+ <xsl:copy-of select="."/>
9816
+ </xsl:template>
9585
9817
  <!-- =========================================================================== -->
9586
9818
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9587
9819
  <!-- =========================================================================== -->
@@ -9603,7 +9835,7 @@
9603
9835
 
9604
9836
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
9605
9837
 
9606
- <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">
9838
+ <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">
9607
9839
 
9608
9840
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9609
9841
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -9633,7 +9865,7 @@
9633
9865
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9634
9866
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9635
9867
  <!-- add &lt; and &gt; to \S -->
9636
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9868
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9637
9869
  <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>
9638
9870
  <xsl:variable name="text3">
9639
9871
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9655,7 +9887,8 @@
9655
9887
  <xsl:choose>
9656
9888
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9657
9889
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9658
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9890
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9891
+ <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>
9659
9892
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9660
9893
  <xsl:choose>
9661
9894
  <xsl:when test="self::text()">
@@ -9676,6 +9909,10 @@
9676
9909
 
9677
9910
  </xsl:template>
9678
9911
 
9912
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
9913
+ <xsl:copy-of select="."/>
9914
+ </xsl:template>
9915
+
9679
9916
  <xsl:template name="replace_text_tags">
9680
9917
  <xsl:param name="tag_open"/>
9681
9918
  <xsl:param name="tag_close"/>
@@ -9702,6 +9939,194 @@
9702
9939
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
9703
9940
  <!-- ===================================== -->
9704
9941
 
9942
+ <!-- ===================================== -->
9943
+ <!-- ===================================== -->
9944
+ <!-- Make linear XML (need for landscape orientation) -->
9945
+ <!-- ===================================== -->
9946
+ <!-- ===================================== -->
9947
+ <xsl:template match="@*|node()" mode="linear_xml">
9948
+ <xsl:copy>
9949
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
9950
+ </xsl:copy>
9951
+ </xsl:template>
9952
+
9953
+ <xsl:template match="processing-instruction()" mode="linear_xml">
9954
+ <xsl:copy-of select="."/>
9955
+ </xsl:template>
9956
+
9957
+ <!-- From:
9958
+ <clause>
9959
+ <title>...</title>
9960
+ <p>...</p>
9961
+ </clause>
9962
+ To:
9963
+ <clause/>
9964
+ <title>...</title>
9965
+ <p>...</p>
9966
+ -->
9967
+ <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">
9968
+
9969
+ <xsl:copy>
9970
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9971
+
9972
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9973
+
9974
+ <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'">
9975
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9976
+ </xsl:if>
9977
+ </xsl:copy>
9978
+
9979
+ <xsl:apply-templates mode="linear_xml"/>
9980
+ </xsl:template>
9981
+
9982
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
9983
+ <xsl:copy>
9984
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9985
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9986
+ <xsl:variable name="level">
9987
+ <xsl:call-template name="getLevel"/>
9988
+ </xsl:variable>
9989
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9990
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
9991
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
9992
+ </xsl:copy>
9993
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
9994
+ </xsl:template>
9995
+
9996
+ <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">
9997
+ <xsl:copy>
9998
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9999
+
10000
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10001
+
10002
+ <xsl:variable name="level">
10003
+ <xsl:call-template name="getLevel"/>
10004
+ </xsl:variable>
10005
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
10006
+
10007
+ <xsl:if test="parent::*[local-name() = 'annex']">
10008
+ <xsl:attribute name="depth">1</xsl:attribute>
10009
+ </xsl:if>
10010
+
10011
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
10012
+ <xsl:copy-of select="../@inline-header"/>
10013
+ </xsl:if>
10014
+
10015
+ <xsl:attribute name="ancestor">
10016
+ <xsl:choose>
10017
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
10018
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
10019
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
10020
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
10021
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
10022
+ </xsl:choose>
10023
+ </xsl:attribute>
10024
+
10025
+ <xsl:apply-templates mode="linear_xml"/>
10026
+ </xsl:copy>
10027
+ </xsl:template>
10028
+
10029
+ <!-- add @to = figure, table, clause -->
10030
+ <!-- add @depth = from -->
10031
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
10032
+ <xsl:copy>
10033
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10034
+ <xsl:variable name="target" select="@target"/>
10035
+ <xsl:attribute name="to">
10036
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
10037
+ </xsl:attribute>
10038
+ <xsl:attribute name="depth">
10039
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
10040
+ </xsl:attribute>
10041
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10042
+ </xsl:copy>
10043
+ </xsl:template>
10044
+
10045
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
10046
+ <xsl:choose>
10047
+ <xsl:when test="contains(., $non_breaking_hyphen)">
10048
+ <xsl:call-template name="replaceChar">
10049
+ <xsl:with-param name="text" select="."/>
10050
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
10051
+ <xsl:with-param name="by" select="'-'"/>
10052
+ </xsl:call-template>
10053
+ </xsl:when>
10054
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10055
+ </xsl:choose>
10056
+ </xsl:template>
10057
+
10058
+ <xsl:template name="replaceChar">
10059
+ <xsl:param name="text"/>
10060
+ <xsl:param name="replace"/>
10061
+ <xsl:param name="by"/>
10062
+ <xsl:choose>
10063
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
10064
+ <xsl:value-of select="$text"/>
10065
+ </xsl:when>
10066
+ <xsl:when test="contains($text, $replace)">
10067
+ <xsl:value-of select="substring-before($text,$replace)"/>
10068
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
10069
+ <xsl:call-template name="replaceChar">
10070
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
10071
+ <xsl:with-param name="replace" select="$replace"/>
10072
+ <xsl:with-param name="by" select="$by"/>
10073
+ </xsl:call-template>
10074
+ </xsl:when>
10075
+ <xsl:otherwise>
10076
+ <xsl:value-of select="$text"/>
10077
+ </xsl:otherwise>
10078
+ </xsl:choose>
10079
+ </xsl:template>
10080
+
10081
+ <xsl:template match="*[local-name() = 'inlineChar']">
10082
+ <fo:inline><xsl:value-of select="."/></fo:inline>
10083
+ </xsl:template>
10084
+
10085
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
10086
+ <!--
10087
+ <fn reference="1">
10088
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
10089
+ </fn>
10090
+ -->
10091
+ <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">
10092
+ <xsl:variable name="p_fn_">
10093
+ <xsl:call-template name="get_fn_list"/>
10094
+ </xsl:variable>
10095
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
10096
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
10097
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
10098
+ <xsl:variable name="reference" select="@reference"/>
10099
+ <!-- fn sequence number in document -->
10100
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
10101
+
10102
+ <xsl:copy>
10103
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10104
+ <!-- put actual reference number -->
10105
+ <xsl:attribute name="current_fn_number">
10106
+ <xsl:value-of select="$current_fn_number"/>
10107
+ </xsl:attribute>
10108
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
10109
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
10110
+ </xsl:attribute>
10111
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10112
+ </xsl:copy>
10113
+ </xsl:template>
10114
+
10115
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
10116
+ <xsl:copy>
10117
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10118
+ <xsl:if test="@depth = '1'">
10119
+ <xsl:attribute name="mainsection">true</xsl:attribute>
10120
+ </xsl:if>
10121
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10122
+ </xsl:copy>
10123
+ </xsl:template>
10124
+ <!-- ===================================== -->
10125
+ <!-- ===================================== -->
10126
+ <!-- END: Make linear XML (need for landscape orientation) -->
10127
+ <!-- ===================================== -->
10128
+ <!-- ===================================== -->
10129
+
9705
10130
  <!-- for correct rendering combining chars -->
9706
10131
  <xsl:template match="*[local-name() = 'lang_none']">
9707
10132
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -10258,6 +10683,23 @@
10258
10683
  </xsl:if>
10259
10684
  </xsl:template>
10260
10685
 
10686
+ <xsl:template name="setBlockAttributes">
10687
+ <xsl:param name="text_align_default">left</xsl:param>
10688
+ <xsl:call-template name="setTextAlignment">
10689
+ <xsl:with-param name="default" select="$text_align_default"/>
10690
+ </xsl:call-template>
10691
+
10692
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10693
+ <!-- Example: keep-lines-together="true" -->
10694
+ <xsl:if test="@keep-lines-together = 'true'">
10695
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10696
+ </xsl:if>
10697
+ <!-- Example: keep-with-next="true" -->
10698
+ <xsl:if test="@keep-with-next = 'true'">
10699
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10700
+ </xsl:if>
10701
+ </xsl:template>
10702
+
10261
10703
  <xsl:template name="number-to-words">
10262
10704
  <xsl:param name="number"/>
10263
10705
  <xsl:param name="first"/>