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.
@@ -1309,7 +1309,6 @@
1309
1309
 
1310
1310
  <xsl:attribute-set name="table-header-cell-style">
1311
1311
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1312
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1313
1312
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1314
1313
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1315
1314
  <xsl:attribute name="display-align">center</xsl:attribute>
@@ -1328,7 +1327,6 @@
1328
1327
 
1329
1328
  <xsl:attribute-set name="table-cell-style">
1330
1329
  <xsl:attribute name="display-align">center</xsl:attribute>
1331
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
1332
1330
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
1333
1331
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
1334
1332
 
@@ -1517,6 +1515,7 @@
1517
1515
  <xsl:attribute-set name="term-name-style">
1518
1516
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
1519
1517
  <xsl:attribute name="font-weight">bold</xsl:attribute>
1518
+
1520
1519
  </xsl:attribute-set>
1521
1520
 
1522
1521
  <xsl:attribute-set name="figure-block-style">
@@ -2053,7 +2052,7 @@
2053
2052
  <xsl:apply-templates select="." mode="contents"/>
2054
2053
  </xsl:for-each>
2055
2054
 
2056
- <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2055
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true') and not(*[local-name()='references'][@normative='true'])][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]][count(.//*[local-name() = 'bibitem'][not(@hidden) = 'true']) &gt; 0]">
2057
2056
  <xsl:sort select="@displayorder" data-type="number"/>
2058
2057
  <xsl:apply-templates select="." mode="contents"/>
2059
2058
  </xsl:for-each>
@@ -2473,7 +2472,7 @@
2473
2472
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
2474
2473
  </xsl:when>
2475
2474
  <xsl:otherwise>
2476
- <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 -->
2475
+ <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 -->
2477
2476
  </xsl:otherwise>
2478
2477
  </xsl:choose>
2479
2478
 
@@ -2973,7 +2972,7 @@
2973
2972
  <xsl:param name="colwidths"/>
2974
2973
  <xsl:param name="colgroup"/>
2975
2974
 
2976
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2975
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
2977
2976
 
2978
2977
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
2979
2978
 
@@ -2992,6 +2991,10 @@
2992
2991
  </xsl:choose>
2993
2992
  </xsl:variable>
2994
2993
 
2994
+ <xsl:variable name="table_fn_block">
2995
+ <xsl:call-template name="table_fn_display"/>
2996
+ </xsl:variable>
2997
+
2995
2998
  <xsl:variable name="tableWithNotesAndFootnotes">
2996
2999
 
2997
3000
  <fo:table keep-with-previous="always">
@@ -3037,13 +3040,28 @@
3037
3040
 
3038
3041
  <!-- except gb and bsi -->
3039
3042
 
3043
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
3040
3044
  <xsl:apply-templates select="../*[local-name()='note']"/>
3041
3045
 
3046
+ <xsl:variable name="isDisplayRowSeparator">
3047
+
3048
+ </xsl:variable>
3049
+
3042
3050
  <!-- horizontal row separator -->
3051
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
3052
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
3053
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
3054
+
3055
+ <xsl:call-template name="setBordersTableArray"/>
3056
+ <fo:block font-size="1pt"> </fo:block>
3057
+ </fo:block-container>
3058
+ </xsl:if>
3059
+ </xsl:if>
3043
3060
 
3044
3061
  <!-- fn processing -->
3045
3062
 
3046
- <xsl:call-template name="table_fn_display"/>
3063
+ <!-- <xsl:call-template name="table_fn_display" /> -->
3064
+ <xsl:copy-of select="$table_fn_block"/>
3047
3065
 
3048
3066
  <!-- for PAS display Notes after footnotes -->
3049
3067
 
@@ -3148,7 +3166,7 @@
3148
3166
  <!-- ===================== -->
3149
3167
  <!-- Table's row processing -->
3150
3168
  <!-- ===================== -->
3151
- <!-- row in table header (thead) -->
3169
+ <!-- row in table header (thead) thead/tr -->
3152
3170
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
3153
3171
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
3154
3172
 
@@ -3160,7 +3178,29 @@
3160
3178
  </fo:table-row>
3161
3179
  </xsl:template>
3162
3180
 
3163
- <!-- row in table footer (tfoot) -->
3181
+ <xsl:template name="setBorderUnderRow">
3182
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
3183
+ <xsl:choose>
3184
+ <xsl:when test="$border_under_row_ != ''">
3185
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
3186
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
3187
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
3188
+ <xsl:variable name="border_under_row">
3189
+ <xsl:call-template name="split">
3190
+ <xsl:with-param name="pText" select="$border_under_row_"/>
3191
+ </xsl:call-template>
3192
+ </xsl:variable>
3193
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
3194
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3195
+ </xsl:if>
3196
+ </xsl:when>
3197
+ <xsl:otherwise>
3198
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
3199
+ </xsl:otherwise>
3200
+ </xsl:choose>
3201
+ </xsl:template>
3202
+
3203
+ <!-- row in table footer (tfoot), tfoot/tr -->
3164
3204
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
3165
3205
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
3166
3206
 
@@ -3496,8 +3536,16 @@
3496
3536
  <!-- figure's footnotes rendering -->
3497
3537
  <xsl:template name="fn_display_figure">
3498
3538
 
3539
+ <!-- current figure id -->
3540
+ <xsl:variable name="figure_id_">
3541
+ <xsl:value-of select="@id"/>
3542
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
3543
+ </xsl:variable>
3544
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
3545
+
3546
+ <!-- all footnotes relates to the current figure -->
3499
3547
  <xsl:variable name="references">
3500
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
3548
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
3501
3549
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
3502
3550
  <xsl:apply-templates/>
3503
3551
  </fn>
@@ -3510,91 +3558,93 @@
3510
3558
 
3511
3559
  </xsl:variable>
3512
3560
 
3513
- <!-- current hierarchy is 'figure' element -->
3514
- <xsl:variable name="following_dl_colwidths">
3515
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3516
- <xsl:variable name="simple-table">
3517
- <!-- <xsl:variable name="doc_ns">
3518
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3561
+ <fo:block>
3562
+
3563
+ <!-- current hierarchy is 'figure' element -->
3564
+ <xsl:variable name="following_dl_colwidths">
3565
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
3566
+ <xsl:variable name="simple-table">
3567
+ <!-- <xsl:variable name="doc_ns">
3568
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
3569
+ </xsl:variable>
3570
+ <xsl:variable name="ns">
3571
+ <xsl:choose>
3572
+ <xsl:when test="normalize-space($doc_ns) != ''">
3573
+ <xsl:value-of select="normalize-space($doc_ns)"/>
3574
+ </xsl:when>
3575
+ <xsl:otherwise>
3576
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
3577
+ </xsl:otherwise>
3578
+ </xsl:choose>
3579
+ </xsl:variable> -->
3580
+
3581
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3582
+ <tbody>
3583
+ <xsl:apply-templates mode="dl"/>
3584
+ </tbody>
3585
+ </xsl:for-each>
3586
+ </xsl:variable>
3587
+
3588
+ <xsl:call-template name="calculate-column-widths">
3589
+ <xsl:with-param name="cols-count" select="2"/>
3590
+ <xsl:with-param name="table" select="$simple-table"/>
3591
+ </xsl:call-template>
3592
+
3593
+ </xsl:if>
3594
+ </xsl:variable>
3595
+
3596
+ <xsl:variable name="maxlength_dt">
3597
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
3598
+ <xsl:call-template name="getMaxLength_dt"/>
3599
+ </xsl:for-each>
3519
3600
  </xsl:variable>
3520
- <xsl:variable name="ns">
3601
+
3602
+ <fo:table width="95%" table-layout="fixed">
3603
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3604
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
3605
+
3606
+ </xsl:if>
3521
3607
  <xsl:choose>
3522
- <xsl:when test="normalize-space($doc_ns) != ''">
3523
- <xsl:value-of select="normalize-space($doc_ns)"/>
3608
+ <!-- if there 'dl', then set same columns width -->
3609
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3610
+ <xsl:call-template name="setColumnWidth_dl">
3611
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3612
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3613
+ </xsl:call-template>
3524
3614
  </xsl:when>
3525
3615
  <xsl:otherwise>
3526
- <xsl:value-of select="substring-before(name(/*), '-')"/>
3616
+ <fo:table-column column-width="5%"/>
3617
+ <fo:table-column column-width="95%"/>
3527
3618
  </xsl:otherwise>
3528
3619
  </xsl:choose>
3529
- </xsl:variable> -->
3530
-
3531
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3532
- <tbody>
3533
- <xsl:apply-templates mode="dl"/>
3534
- </tbody>
3535
- </xsl:for-each>
3536
- </xsl:variable>
3537
-
3538
- <xsl:call-template name="calculate-column-widths">
3539
- <xsl:with-param name="cols-count" select="2"/>
3540
- <xsl:with-param name="table" select="$simple-table"/>
3541
- </xsl:call-template>
3542
-
3543
- </xsl:if>
3544
- </xsl:variable>
3545
-
3546
- <xsl:variable name="maxlength_dt">
3547
- <xsl:for-each select="*[local-name() = 'dl'][1]">
3548
- <xsl:call-template name="getMaxLength_dt"/>
3549
- </xsl:for-each>
3550
- </xsl:variable>
3551
-
3552
- <fo:block>
3553
- <fo:table width="95%" table-layout="fixed">
3554
- <xsl:if test="normalize-space($key_iso) = 'true'">
3555
- <xsl:attribute name="font-size">10pt</xsl:attribute>
3620
+ <fo:table-body>
3621
+ <xsl:for-each select="xalan:nodeset($references)//fn">
3622
+ <xsl:variable name="reference" select="@reference"/>
3623
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3624
+ <fo:table-row>
3625
+ <fo:table-cell>
3626
+ <fo:block>
3627
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3628
+ <xsl:value-of select="@reference"/>
3629
+ </fo:inline>
3630
+ </fo:block>
3631
+ </fo:table-cell>
3632
+ <fo:table-cell>
3633
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3634
+ <xsl:if test="normalize-space($key_iso) = 'true'">
3556
3635
 
3557
- </xsl:if>
3558
- <xsl:choose>
3559
- <!-- if there 'dl', then set same columns width -->
3560
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
3561
- <xsl:call-template name="setColumnWidth_dl">
3562
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
3563
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
3564
- </xsl:call-template>
3565
- </xsl:when>
3566
- <xsl:otherwise>
3567
- <fo:table-column column-width="15%"/>
3568
- <fo:table-column column-width="85%"/>
3569
- </xsl:otherwise>
3570
- </xsl:choose>
3571
- <fo:table-body>
3572
- <xsl:for-each select="xalan:nodeset($references)//fn">
3573
- <xsl:variable name="reference" select="@reference"/>
3574
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
3575
- <fo:table-row>
3576
- <fo:table-cell>
3577
- <fo:block>
3578
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
3579
- <xsl:value-of select="@reference"/>
3580
- </fo:inline>
3581
- </fo:block>
3582
- </fo:table-cell>
3583
- <fo:table-cell>
3584
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
3585
- <xsl:if test="normalize-space($key_iso) = 'true'">
3636
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
3586
3637
 
3587
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
3638
+ </xsl:if>
3639
+ <xsl:copy-of select="./node()"/>
3640
+ </fo:block>
3641
+ </fo:table-cell>
3642
+ </fo:table-row>
3643
+ </xsl:if>
3644
+ </xsl:for-each>
3645
+ </fo:table-body>
3646
+ </fo:table>
3588
3647
 
3589
- </xsl:if>
3590
- <xsl:copy-of select="./node()"/>
3591
- </fo:block>
3592
- </fo:table-cell>
3593
- </fo:table-row>
3594
- </xsl:if>
3595
- </xsl:for-each>
3596
- </fo:table-body>
3597
- </fo:table>
3598
3648
  </fo:block>
3599
3649
  </xsl:if>
3600
3650
 
@@ -3634,6 +3684,8 @@
3634
3684
  <!-- <dl><xsl:copy-of select="."/></dl> -->
3635
3685
  <fo:block-container>
3636
3686
 
3687
+ <xsl:call-template name="setBlockSpanAll"/>
3688
+
3637
3689
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
3638
3690
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
3639
3691
  </xsl:if>
@@ -3670,12 +3722,14 @@
3670
3722
 
3671
3723
  <fo:block margin-bottom="12pt" text-align="left">
3672
3724
 
3673
- <xsl:variable name="title-where">
3725
+ <!-- <xsl:variable name="title-where">
3674
3726
  <xsl:call-template name="getLocalizedString">
3675
3727
  <xsl:with-param name="key">where</xsl:with-param>
3676
3728
  </xsl:call-template>
3677
3729
  </xsl:variable>
3678
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
3730
+ <xsl:value-of select="$title-where"/> -->
3731
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3732
+ <xsl:text> </xsl:text>
3679
3733
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3680
3734
  <xsl:text/>
3681
3735
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -3685,12 +3739,14 @@
3685
3739
  <xsl:when test="$parent = 'formula'"> <!-- a few components -->
3686
3740
  <fo:block margin-bottom="12pt" text-align="left">
3687
3741
 
3688
- <xsl:variable name="title-where">
3742
+ <!-- <xsl:variable name="title-where">
3689
3743
  <xsl:call-template name="getLocalizedString">
3690
3744
  <xsl:with-param name="key">where</xsl:with-param>
3691
3745
  </xsl:call-template>
3692
3746
  </xsl:variable>
3693
- <xsl:value-of select="$title-where"/>
3747
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
3748
+ <!-- preceding 'p' with word 'where' -->
3749
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3694
3750
  </fo:block>
3695
3751
  </xsl:when> <!-- END: a few components -->
3696
3752
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -3873,6 +3929,9 @@
3873
3929
 
3874
3930
  </xsl:template> <!-- END: dl -->
3875
3931
 
3932
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
3933
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
3934
+
3876
3935
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
3877
3936
  <xsl:param name="process">false</xsl:param>
3878
3937
  <xsl:if test="$process = 'true'">
@@ -4697,20 +4756,34 @@
4697
4756
 
4698
4757
  <xsl:template name="add-zero-spaces-java">
4699
4758
  <xsl:param name="text" select="."/>
4700
- <!-- add zero-width space (#x200B) after characters: dash, dot, equal, underscore, em dash, thin space, arrow right -->
4701
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|=|_|—| |→)','$1​')"/>
4759
+
4760
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
4761
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
4762
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
4763
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
4702
4764
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
4703
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1​$2')"/>
4765
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
4704
4766
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
4705
- <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
4767
+ <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(\u003e)(?!\u003e)', '$1​')"/><!-- negative lookahead: 'great than' not followed by 'great than' -->
4706
4768
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
4707
- <xsl:variable name="text4" select="java:replaceAll(java:java.lang.String.new($text3), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
4769
+ <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\u003c)(\u003c)', '​$1')"/> <!-- (?<!\u003c)(\u003c) --> <!-- negative lookbehind: 'less than' not preceeded by 'less than' -->
4708
4770
  <!-- add zero-width space (#x200B) before character: { -->
4709
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4771
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
4710
4772
  <!-- add zero-width space (#x200B) after character: , -->
4711
- <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4773
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
4774
+ <!-- add zero-width space (#x200B) after character: '/' -->
4775
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
4776
+
4777
+ <xsl:variable name="text9">
4778
+ <xsl:choose>
4779
+ <xsl:when test="$isGenerateTableIF = 'true'">
4780
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
4781
+ </xsl:when>
4782
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
4783
+ </xsl:choose>
4784
+ </xsl:variable>
4712
4785
 
4713
- <xsl:value-of select="$text6"/>
4786
+ <xsl:value-of select="$text9"/>
4714
4787
  </xsl:template>
4715
4788
 
4716
4789
  <xsl:template name="add-zero-spaces-link-java">
@@ -4718,8 +4791,8 @@
4718
4791
 
4719
4792
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
4720
4793
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
4721
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
4722
- <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
4794
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
4795
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
4723
4796
  <!-- remove zero-width space at the end -->
4724
4797
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
4725
4798
  </xsl:template>
@@ -5074,9 +5147,28 @@
5074
5147
  </xsl:variable>
5075
5148
  <xsl:copy-of select="$newRow"/>
5076
5149
 
5077
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5078
- <xsl:with-param name="previousRow" select="$newRow"/>
5079
- </xsl:apply-templates>
5150
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
5151
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
5152
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
5153
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
5154
+ <xsl:choose>
5155
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
5156
+ <xsl:copy-of select="following-sibling::tr"/>
5157
+ </xsl:when>
5158
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
5159
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
5160
+
5161
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5162
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
5163
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
5164
+ </xsl:apply-templates>
5165
+ </xsl:when> -->
5166
+ <xsl:otherwise>
5167
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
5168
+ <xsl:with-param name="previousRow" select="$newRow"/>
5169
+ </xsl:apply-templates>
5170
+ </xsl:otherwise>
5171
+ </xsl:choose>
5080
5172
  </xsl:template>
5081
5173
  <!-- End mode simple-table-rowspan -->
5082
5174
 
@@ -5239,6 +5331,27 @@
5239
5331
  </xsl:call-template>
5240
5332
  </xsl:template>
5241
5333
 
5334
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
5335
+ <xsl:variable name="link">
5336
+ <link_updated>
5337
+ <xsl:variable name="target_text">
5338
+ <xsl:choose>
5339
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
5340
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
5341
+ </xsl:when>
5342
+ <xsl:otherwise>
5343
+ <xsl:value-of select="normalize-space(@target)"/>
5344
+ </xsl:otherwise>
5345
+ </xsl:choose>
5346
+ </xsl:variable>
5347
+ <xsl:value-of select="$target_text"/>
5348
+ </link_updated>
5349
+ </xsl:variable>
5350
+ <xsl:for-each select="xalan:nodeset($link)/*">
5351
+ <xsl:apply-templates mode="td_text_with_formatting"/>
5352
+ </xsl:for-each>
5353
+ </xsl:template>
5354
+
5242
5355
  <xsl:template name="getFormattingTags">
5243
5356
  <tags>
5244
5357
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -5580,7 +5693,7 @@
5580
5693
  </xsl:variable>
5581
5694
  <fo:inline xsl:use-attribute-sets="link-style">
5582
5695
 
5583
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
5696
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
5584
5697
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
5585
5698
  </xsl:if>
5586
5699
 
@@ -5635,13 +5748,17 @@
5635
5748
  </xsl:template>
5636
5749
 
5637
5750
  <xsl:template match="*[local-name() = 'callout']">
5638
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
5751
+ <xsl:choose>
5752
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
5753
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
5754
+ </xsl:choose>
5639
5755
  </xsl:template>
5640
5756
 
5641
5757
  <xsl:template match="*[local-name() = 'annotation']">
5642
5758
  <xsl:variable name="annotation-id" select="@id"/>
5643
5759
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
5644
5760
  <fo:block id="{$annotation-id}" white-space="nowrap">
5761
+
5645
5762
  <fo:inline>
5646
5763
  <xsl:apply-templates>
5647
5764
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -5751,6 +5868,10 @@
5751
5868
  <!-- ====== -->
5752
5869
  <!-- ====== -->
5753
5870
 
5871
+ <xsl:template name="setBlockSpanAll">
5872
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
5873
+ </xsl:template>
5874
+
5754
5875
  <!-- ====== -->
5755
5876
  <!-- note -->
5756
5877
  <!-- termnote -->
@@ -5760,6 +5881,8 @@
5760
5881
 
5761
5882
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
5762
5883
 
5884
+ <xsl:call-template name="setBlockSpanAll"/>
5885
+
5763
5886
  <fo:block-container margin-left="0mm" margin-right="0mm">
5764
5887
 
5765
5888
  <fo:block>
@@ -5819,6 +5942,8 @@
5819
5942
  <xsl:template match="*[local-name() = 'termnote']">
5820
5943
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
5821
5944
 
5945
+ <xsl:call-template name="setBlockSpanAll"/>
5946
+
5822
5947
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
5823
5948
 
5824
5949
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -5953,10 +6078,10 @@
5953
6078
  <fo:block xsl:use-attribute-sets="figure-style">
5954
6079
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
5955
6080
  </fo:block>
5956
- <xsl:call-template name="fn_display_figure"/>
5957
6081
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
5958
6082
  <xsl:call-template name="note"/>
5959
6083
  </xsl:for-each>
6084
+ <xsl:call-template name="fn_display_figure"/>
5960
6085
 
5961
6086
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
5962
6087
 
@@ -6019,7 +6144,13 @@
6019
6144
  </xsl:choose>
6020
6145
  </xsl:variable>
6021
6146
 
6022
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
6147
+ <xsl:variable name="image_width_effective">
6148
+
6149
+ <xsl:value-of select="$width_effective"/>
6150
+
6151
+ </xsl:variable>
6152
+
6153
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
6023
6154
  <xsl:if test="number($scale) &lt; 100">
6024
6155
 
6025
6156
  <xsl:attribute name="content-width"><xsl:value-of select="$scale * 0.985"/>%</xsl:attribute><!-- 0.985 due border around image -->
@@ -6606,6 +6737,13 @@
6606
6737
  <xsl:when test="$contents_nodes/doc">
6607
6738
  <xsl:choose>
6608
6739
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
6740
+
6741
+ <xsl:if test="$contents_nodes/collection">
6742
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
6743
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
6744
+ </fo:bookmark>
6745
+ </xsl:if>
6746
+
6609
6747
  <xsl:for-each select="$contents_nodes/doc">
6610
6748
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
6611
6749
  <xsl:if test="@bundle = 'true'">
@@ -7718,6 +7856,9 @@
7718
7856
  <!-- ====== -->
7719
7857
  <xsl:template match="*[local-name() = 'termexample']">
7720
7858
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
7859
+
7860
+ <xsl:call-template name="setBlockSpanAll"/>
7861
+
7721
7862
  <xsl:apply-templates select="*[local-name()='name']"/>
7722
7863
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
7723
7864
  </fo:block>
@@ -7769,6 +7910,8 @@
7769
7910
 
7770
7911
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
7771
7912
 
7913
+ <xsl:call-template name="setBlockSpanAll"/>
7914
+
7772
7915
  <xsl:variable name="fo_element">
7773
7916
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
7774
7917
  block
@@ -7796,6 +7939,35 @@
7796
7939
  </fo:block-container>
7797
7940
  </xsl:when> <!-- end block -->
7798
7941
 
7942
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
7943
+
7944
+ <xsl:variable name="provisional_distance_between_starts">
7945
+ 7
7946
+ </xsl:variable>
7947
+ <xsl:variable name="indent">
7948
+ 0
7949
+ </xsl:variable>
7950
+
7951
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
7952
+ <fo:list-item>
7953
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
7954
+ <fo:block>
7955
+ <xsl:apply-templates select="*[local-name()='name']">
7956
+ <xsl:with-param name="fo_element">block</xsl:with-param>
7957
+ </xsl:apply-templates>
7958
+ </fo:block>
7959
+ </fo:list-item-label>
7960
+ <fo:list-item-body start-indent="body-start()">
7961
+ <fo:block>
7962
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
7963
+ <xsl:with-param name="fo_element" select="$fo_element"/>
7964
+ </xsl:apply-templates>
7965
+ </fo:block>
7966
+ </fo:list-item-body>
7967
+ </fo:list-item>
7968
+ </fo:list-block>
7969
+ </xsl:when> <!-- end list -->
7970
+
7799
7971
  <xsl:otherwise> <!-- inline -->
7800
7972
 
7801
7973
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -7875,6 +8047,11 @@
7875
8047
  </fo:block>
7876
8048
  </fo:block-container>
7877
8049
  </xsl:when>
8050
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
8051
+ <fo:block xsl:use-attribute-sets="example-p-style">
8052
+ <xsl:apply-templates/>
8053
+ </fo:block>
8054
+ </xsl:when>
7878
8055
  <xsl:otherwise>
7879
8056
  <fo:inline xsl:use-attribute-sets="example-p-style">
7880
8057
  <xsl:apply-templates/>
@@ -7992,6 +8169,9 @@
7992
8169
  <!-- ====== -->
7993
8170
  <xsl:template match="*[local-name() = 'quote']">
7994
8171
  <fo:block-container margin-left="0mm">
8172
+
8173
+ <xsl:call-template name="setBlockSpanAll"/>
8174
+
7995
8175
  <xsl:if test="parent::*[local-name() = 'note']">
7996
8176
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
7997
8177
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -8281,6 +8461,8 @@
8281
8461
  <fo:block>
8282
8462
  <xsl:call-template name="setId"/>
8283
8463
 
8464
+ <xsl:call-template name="setBlockSpanAll"/>
8465
+
8284
8466
  <xsl:apply-templates/>
8285
8467
  </fo:block>
8286
8468
  </xsl:template>
@@ -8295,6 +8477,8 @@
8295
8477
  <fo:block break-after="page"/>
8296
8478
  <fo:block id="{@id}">
8297
8479
 
8480
+ <xsl:call-template name="setBlockSpanAll"/>
8481
+
8298
8482
  <xsl:variable name="num"><xsl:number/></xsl:variable>
8299
8483
  <xsl:if test="$num = 1">
8300
8484
  <xsl:attribute name="margin-top">3pt</xsl:attribute>
@@ -8488,9 +8672,47 @@
8488
8672
 
8489
8673
  <fo:list-block xsl:use-attribute-sets="list-style">
8490
8674
 
8491
- <xsl:if test="local-name() = 'ol'">
8492
- <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8675
+ <xsl:variable name="provisional_distance_between_starts_">
8676
+ <attributes xsl:use-attribute-sets="list-style">
8677
+
8678
+ <xsl:if test="local-name() = 'ol'">
8679
+ <xsl:attribute name="provisional-distance-between-starts">6mm</xsl:attribute>
8680
+ </xsl:if>
8681
+
8682
+ </attributes>
8683
+ </xsl:variable>
8684
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
8685
+ <xsl:if test="$provisional_distance_between_starts != ''">
8686
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
8687
+ </xsl:if>
8688
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
8689
+
8690
+ <!-- increase provisional-distance-between-starts for long lists -->
8691
+ <xsl:if test="local-name() = 'ol'">
8692
+ <!-- Examples: xiii), xviii), xxviii) -->
8693
+ <xsl:variable name="item_numbers">
8694
+ <xsl:for-each select="*[local-name() = 'li']">
8695
+ <item><xsl:call-template name="getListItemFormat"/></item>
8696
+ </xsl:for-each>
8697
+ </xsl:variable>
8698
+
8699
+ <xsl:variable name="max_length">
8700
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
8701
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
8702
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
8703
+ </xsl:for-each>
8704
+ </xsl:variable>
8705
+
8706
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
8707
+ <xsl:variable name="addon" select="$max_length - 4"/>
8708
+ <xsl:if test="$addon &gt; 0">
8709
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
8493
8710
  </xsl:if>
8711
+ <!-- DEBUG -->
8712
+ <!-- <xsl:copy-of select="$item_numbers"/>
8713
+ <max_length><xsl:value-of select="$max_length"/></max_length>
8714
+ <addon><xsl:value-of select="$addon"/></addon> -->
8715
+ </xsl:if>
8494
8716
 
8495
8717
  <xsl:if test="*[local-name() = 'name']">
8496
8718
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
@@ -9200,6 +9422,8 @@
9200
9422
  <!-- text in the box -->
9201
9423
  <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style">
9202
9424
 
9425
+ <xsl:call-template name="setBlockSpanAll"/>
9426
+
9203
9427
  <fo:block-container xsl:use-attribute-sets="admonition-container-style">
9204
9428
 
9205
9429
  <fo:block-container margin-left="0mm" margin-right="0mm">
@@ -9377,6 +9601,16 @@
9377
9601
  <xsl:apply-templates mode="update_xml_step1"/>
9378
9602
  </xsl:copy>
9379
9603
  </xsl:template>
9604
+
9605
+ <!-- remove semantic xml -->
9606
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
9607
+
9608
+ <!-- remove image/emf -->
9609
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
9610
+
9611
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
9612
+ <xsl:copy-of select="."/>
9613
+ </xsl:template>
9380
9614
  <!-- =========================================================================== -->
9381
9615
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
9382
9616
  <!-- =========================================================================== -->
@@ -9398,7 +9632,7 @@
9398
9632
 
9399
9633
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
9400
9634
 
9401
- <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">
9635
+ <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">
9402
9636
 
9403
9637
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
9404
9638
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -9428,7 +9662,7 @@
9428
9662
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
9429
9663
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
9430
9664
  <!-- add &lt; and &gt; to \S -->
9431
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
9665
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
9432
9666
  <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable>
9433
9667
  <xsl:variable name="text3">
9434
9668
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -9450,7 +9684,8 @@
9450
9684
  <xsl:choose>
9451
9685
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
9452
9686
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
9453
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
9687
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
9688
+ <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable>
9454
9689
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
9455
9690
  <xsl:choose>
9456
9691
  <xsl:when test="self::text()">
@@ -9471,6 +9706,10 @@
9471
9706
 
9472
9707
  </xsl:template>
9473
9708
 
9709
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
9710
+ <xsl:copy-of select="."/>
9711
+ </xsl:template>
9712
+
9474
9713
  <xsl:template name="replace_text_tags">
9475
9714
  <xsl:param name="tag_open"/>
9476
9715
  <xsl:param name="tag_close"/>
@@ -9497,6 +9736,194 @@
9497
9736
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
9498
9737
  <!-- ===================================== -->
9499
9738
 
9739
+ <!-- ===================================== -->
9740
+ <!-- ===================================== -->
9741
+ <!-- Make linear XML (need for landscape orientation) -->
9742
+ <!-- ===================================== -->
9743
+ <!-- ===================================== -->
9744
+ <xsl:template match="@*|node()" mode="linear_xml">
9745
+ <xsl:copy>
9746
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
9747
+ </xsl:copy>
9748
+ </xsl:template>
9749
+
9750
+ <xsl:template match="processing-instruction()" mode="linear_xml">
9751
+ <xsl:copy-of select="."/>
9752
+ </xsl:template>
9753
+
9754
+ <!-- From:
9755
+ <clause>
9756
+ <title>...</title>
9757
+ <p>...</p>
9758
+ </clause>
9759
+ To:
9760
+ <clause/>
9761
+ <title>...</title>
9762
+ <p>...</p>
9763
+ -->
9764
+ <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">
9765
+
9766
+ <xsl:copy>
9767
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9768
+
9769
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9770
+
9771
+ <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'">
9772
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9773
+ </xsl:if>
9774
+ </xsl:copy>
9775
+
9776
+ <xsl:apply-templates mode="linear_xml"/>
9777
+ </xsl:template>
9778
+
9779
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
9780
+ <xsl:copy>
9781
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9782
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9783
+ <xsl:variable name="level">
9784
+ <xsl:call-template name="getLevel"/>
9785
+ </xsl:variable>
9786
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9787
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
9788
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
9789
+ </xsl:copy>
9790
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
9791
+ </xsl:template>
9792
+
9793
+ <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">
9794
+ <xsl:copy>
9795
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9796
+
9797
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
9798
+
9799
+ <xsl:variable name="level">
9800
+ <xsl:call-template name="getLevel"/>
9801
+ </xsl:variable>
9802
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
9803
+
9804
+ <xsl:if test="parent::*[local-name() = 'annex']">
9805
+ <xsl:attribute name="depth">1</xsl:attribute>
9806
+ </xsl:if>
9807
+
9808
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
9809
+ <xsl:copy-of select="../@inline-header"/>
9810
+ </xsl:if>
9811
+
9812
+ <xsl:attribute name="ancestor">
9813
+ <xsl:choose>
9814
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
9815
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
9816
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
9817
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
9818
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
9819
+ </xsl:choose>
9820
+ </xsl:attribute>
9821
+
9822
+ <xsl:apply-templates mode="linear_xml"/>
9823
+ </xsl:copy>
9824
+ </xsl:template>
9825
+
9826
+ <!-- add @to = figure, table, clause -->
9827
+ <!-- add @depth = from -->
9828
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
9829
+ <xsl:copy>
9830
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9831
+ <xsl:variable name="target" select="@target"/>
9832
+ <xsl:attribute name="to">
9833
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
9834
+ </xsl:attribute>
9835
+ <xsl:attribute name="depth">
9836
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
9837
+ </xsl:attribute>
9838
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9839
+ </xsl:copy>
9840
+ </xsl:template>
9841
+
9842
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
9843
+ <xsl:choose>
9844
+ <xsl:when test="contains(., $non_breaking_hyphen)">
9845
+ <xsl:call-template name="replaceChar">
9846
+ <xsl:with-param name="text" select="."/>
9847
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
9848
+ <xsl:with-param name="by" select="'-'"/>
9849
+ </xsl:call-template>
9850
+ </xsl:when>
9851
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
9852
+ </xsl:choose>
9853
+ </xsl:template>
9854
+
9855
+ <xsl:template name="replaceChar">
9856
+ <xsl:param name="text"/>
9857
+ <xsl:param name="replace"/>
9858
+ <xsl:param name="by"/>
9859
+ <xsl:choose>
9860
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
9861
+ <xsl:value-of select="$text"/>
9862
+ </xsl:when>
9863
+ <xsl:when test="contains($text, $replace)">
9864
+ <xsl:value-of select="substring-before($text,$replace)"/>
9865
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
9866
+ <xsl:call-template name="replaceChar">
9867
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
9868
+ <xsl:with-param name="replace" select="$replace"/>
9869
+ <xsl:with-param name="by" select="$by"/>
9870
+ </xsl:call-template>
9871
+ </xsl:when>
9872
+ <xsl:otherwise>
9873
+ <xsl:value-of select="$text"/>
9874
+ </xsl:otherwise>
9875
+ </xsl:choose>
9876
+ </xsl:template>
9877
+
9878
+ <xsl:template match="*[local-name() = 'inlineChar']">
9879
+ <fo:inline><xsl:value-of select="."/></fo:inline>
9880
+ </xsl:template>
9881
+
9882
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
9883
+ <!--
9884
+ <fn reference="1">
9885
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
9886
+ </fn>
9887
+ -->
9888
+ <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">
9889
+ <xsl:variable name="p_fn_">
9890
+ <xsl:call-template name="get_fn_list"/>
9891
+ </xsl:variable>
9892
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
9893
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
9894
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
9895
+ <xsl:variable name="reference" select="@reference"/>
9896
+ <!-- fn sequence number in document -->
9897
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
9898
+
9899
+ <xsl:copy>
9900
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9901
+ <!-- put actual reference number -->
9902
+ <xsl:attribute name="current_fn_number">
9903
+ <xsl:value-of select="$current_fn_number"/>
9904
+ </xsl:attribute>
9905
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
9906
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
9907
+ </xsl:attribute>
9908
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9909
+ </xsl:copy>
9910
+ </xsl:template>
9911
+
9912
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
9913
+ <xsl:copy>
9914
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
9915
+ <xsl:if test="@depth = '1'">
9916
+ <xsl:attribute name="mainsection">true</xsl:attribute>
9917
+ </xsl:if>
9918
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
9919
+ </xsl:copy>
9920
+ </xsl:template>
9921
+ <!-- ===================================== -->
9922
+ <!-- ===================================== -->
9923
+ <!-- END: Make linear XML (need for landscape orientation) -->
9924
+ <!-- ===================================== -->
9925
+ <!-- ===================================== -->
9926
+
9500
9927
  <!-- for correct rendering combining chars -->
9501
9928
  <xsl:template match="*[local-name() = 'lang_none']">
9502
9929
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -10053,6 +10480,23 @@
10053
10480
  </xsl:if>
10054
10481
  </xsl:template>
10055
10482
 
10483
+ <xsl:template name="setBlockAttributes">
10484
+ <xsl:param name="text_align_default">left</xsl:param>
10485
+ <xsl:call-template name="setTextAlignment">
10486
+ <xsl:with-param name="default" select="$text_align_default"/>
10487
+ </xsl:call-template>
10488
+
10489
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
10490
+ <!-- Example: keep-lines-together="true" -->
10491
+ <xsl:if test="@keep-lines-together = 'true'">
10492
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
10493
+ </xsl:if>
10494
+ <!-- Example: keep-with-next="true" -->
10495
+ <xsl:if test="@keep-with-next = 'true'">
10496
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10497
+ </xsl:if>
10498
+ </xsl:template>
10499
+
10056
10500
  <xsl:template name="number-to-words">
10057
10501
  <xsl:param name="number"/>
10058
10502
  <xsl:param name="first"/>