metanorma-iso 2.3.6 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2824,6 +2824,7 @@
2824
2824
  <xsl:variable name="table-border_">
2825
2825
 
2826
2826
  1pt solid black
2827
+
2827
2828
  </xsl:variable>
2828
2829
  <xsl:variable name="table-border" select="normalize-space($table-border_)"/>
2829
2830
 
@@ -2887,11 +2888,11 @@
2887
2888
 
2888
2889
  <xsl:attribute-set name="table-header-cell-style">
2889
2890
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2890
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2891
2891
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2892
2892
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2893
2893
  <xsl:attribute name="display-align">center</xsl:attribute>
2894
2894
 
2895
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2895
2896
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
2896
2897
  <xsl:attribute name="border-left"><xsl:value-of select="$table-cell-border"/></xsl:attribute>
2897
2898
  <xsl:attribute name="border-right"><xsl:value-of select="$table-cell-border"/></xsl:attribute>
@@ -2900,7 +2901,6 @@
2900
2901
 
2901
2902
  <xsl:attribute-set name="table-cell-style">
2902
2903
  <xsl:attribute name="display-align">center</xsl:attribute>
2903
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2904
2904
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2905
2905
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2906
2906
 
@@ -3113,6 +3113,7 @@
3113
3113
  <xsl:attribute-set name="term-name-style">
3114
3114
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
3115
3115
  <xsl:attribute name="font-weight">bold</xsl:attribute>
3116
+
3116
3117
  </xsl:attribute-set>
3117
3118
 
3118
3119
  <xsl:attribute-set name="figure-block-style">
@@ -3652,7 +3653,7 @@
3652
3653
  <xsl:apply-templates select="." mode="contents"/>
3653
3654
  </xsl:for-each>
3654
3655
 
3655
- <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')]]">
3656
+ <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]">
3656
3657
  <xsl:sort select="@displayorder" data-type="number"/>
3657
3658
  <xsl:apply-templates select="." mode="contents"/>
3658
3659
  </xsl:for-each>
@@ -4070,7 +4071,7 @@
4070
4071
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
4071
4072
  </xsl:when>
4072
4073
  <xsl:otherwise>
4073
- <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 -->
4074
+ <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 -->
4074
4075
  </xsl:otherwise>
4075
4076
  </xsl:choose>
4076
4077
 
@@ -4606,7 +4607,7 @@
4606
4607
  <xsl:param name="colwidths"/>
4607
4608
  <xsl:param name="colgroup"/>
4608
4609
 
4609
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4610
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
4610
4611
 
4611
4612
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
4612
4613
 
@@ -4625,6 +4626,10 @@
4625
4626
  </xsl:choose>
4626
4627
  </xsl:variable>
4627
4628
 
4629
+ <xsl:variable name="table_fn_block">
4630
+ <xsl:call-template name="table_fn_display"/>
4631
+ </xsl:variable>
4632
+
4628
4633
  <xsl:variable name="tableWithNotesAndFootnotes">
4629
4634
 
4630
4635
  <fo:table keep-with-previous="always">
@@ -4670,13 +4675,28 @@
4670
4675
 
4671
4676
  <!-- except gb and bsi -->
4672
4677
 
4678
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
4673
4679
  <xsl:apply-templates select="../*[local-name()='note']"/>
4674
4680
 
4681
+ <xsl:variable name="isDisplayRowSeparator">
4682
+
4683
+ </xsl:variable>
4684
+
4675
4685
  <!-- horizontal row separator -->
4686
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4687
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
4688
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4689
+
4690
+ <xsl:call-template name="setBordersTableArray"/>
4691
+ <fo:block font-size="1pt"> </fo:block>
4692
+ </fo:block-container>
4693
+ </xsl:if>
4694
+ </xsl:if>
4676
4695
 
4677
4696
  <!-- fn processing -->
4678
4697
 
4679
- <xsl:call-template name="table_fn_display"/>
4698
+ <!-- <xsl:call-template name="table_fn_display" /> -->
4699
+ <xsl:copy-of select="$table_fn_block"/>
4680
4700
 
4681
4701
  <!-- for PAS display Notes after footnotes -->
4682
4702
 
@@ -4825,7 +4845,7 @@
4825
4845
  <!-- ===================== -->
4826
4846
  <!-- Table's row processing -->
4827
4847
  <!-- ===================== -->
4828
- <!-- row in table header (thead) -->
4848
+ <!-- row in table header (thead) thead/tr -->
4829
4849
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4830
4850
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4831
4851
 
@@ -4848,7 +4868,29 @@
4848
4868
  </fo:table-row>
4849
4869
  </xsl:template>
4850
4870
 
4851
- <!-- row in table footer (tfoot) -->
4871
+ <xsl:template name="setBorderUnderRow">
4872
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
4873
+ <xsl:choose>
4874
+ <xsl:when test="$border_under_row_ != ''">
4875
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
4876
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
4877
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
4878
+ <xsl:variable name="border_under_row">
4879
+ <xsl:call-template name="split">
4880
+ <xsl:with-param name="pText" select="$border_under_row_"/>
4881
+ </xsl:call-template>
4882
+ </xsl:variable>
4883
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
4884
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4885
+ </xsl:if>
4886
+ </xsl:when>
4887
+ <xsl:otherwise>
4888
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4889
+ </xsl:otherwise>
4890
+ </xsl:choose>
4891
+ </xsl:template>
4892
+
4893
+ <!-- row in table footer (tfoot), tfoot/tr -->
4852
4894
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4853
4895
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
4854
4896
 
@@ -5198,8 +5240,16 @@
5198
5240
  <!-- figure's footnotes rendering -->
5199
5241
  <xsl:template name="fn_display_figure">
5200
5242
 
5243
+ <!-- current figure id -->
5244
+ <xsl:variable name="figure_id_">
5245
+ <xsl:value-of select="@id"/>
5246
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
5247
+ </xsl:variable>
5248
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
5249
+
5250
+ <!-- all footnotes relates to the current figure -->
5201
5251
  <xsl:variable name="references">
5202
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
5252
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
5203
5253
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
5204
5254
  <xsl:apply-templates/>
5205
5255
  </fn>
@@ -5212,91 +5262,93 @@
5212
5262
  true
5213
5263
  </xsl:variable>
5214
5264
 
5215
- <!-- current hierarchy is 'figure' element -->
5216
- <xsl:variable name="following_dl_colwidths">
5217
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
5218
- <xsl:variable name="simple-table">
5219
- <!-- <xsl:variable name="doc_ns">
5220
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
5265
+ <fo:block>
5266
+
5267
+ <!-- current hierarchy is 'figure' element -->
5268
+ <xsl:variable name="following_dl_colwidths">
5269
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
5270
+ <xsl:variable name="simple-table">
5271
+ <!-- <xsl:variable name="doc_ns">
5272
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
5273
+ </xsl:variable>
5274
+ <xsl:variable name="ns">
5275
+ <xsl:choose>
5276
+ <xsl:when test="normalize-space($doc_ns) != ''">
5277
+ <xsl:value-of select="normalize-space($doc_ns)"/>
5278
+ </xsl:when>
5279
+ <xsl:otherwise>
5280
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
5281
+ </xsl:otherwise>
5282
+ </xsl:choose>
5283
+ </xsl:variable> -->
5284
+
5285
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
5286
+ <tbody>
5287
+ <xsl:apply-templates mode="dl"/>
5288
+ </tbody>
5289
+ </xsl:for-each>
5290
+ </xsl:variable>
5291
+
5292
+ <xsl:call-template name="calculate-column-widths">
5293
+ <xsl:with-param name="cols-count" select="2"/>
5294
+ <xsl:with-param name="table" select="$simple-table"/>
5295
+ </xsl:call-template>
5296
+
5297
+ </xsl:if>
5298
+ </xsl:variable>
5299
+
5300
+ <xsl:variable name="maxlength_dt">
5301
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
5302
+ <xsl:call-template name="getMaxLength_dt"/>
5303
+ </xsl:for-each>
5221
5304
  </xsl:variable>
5222
- <xsl:variable name="ns">
5305
+
5306
+ <fo:table width="95%" table-layout="fixed">
5307
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5308
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
5309
+
5310
+ </xsl:if>
5223
5311
  <xsl:choose>
5224
- <xsl:when test="normalize-space($doc_ns) != ''">
5225
- <xsl:value-of select="normalize-space($doc_ns)"/>
5312
+ <!-- if there 'dl', then set same columns width -->
5313
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
5314
+ <xsl:call-template name="setColumnWidth_dl">
5315
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
5316
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5317
+ </xsl:call-template>
5226
5318
  </xsl:when>
5227
5319
  <xsl:otherwise>
5228
- <xsl:value-of select="substring-before(name(/*), '-')"/>
5320
+ <fo:table-column column-width="5%"/>
5321
+ <fo:table-column column-width="95%"/>
5229
5322
  </xsl:otherwise>
5230
5323
  </xsl:choose>
5231
- </xsl:variable> -->
5232
-
5233
- <xsl:for-each select="*[local-name() = 'dl'][1]">
5234
- <tbody>
5235
- <xsl:apply-templates mode="dl"/>
5236
- </tbody>
5237
- </xsl:for-each>
5238
- </xsl:variable>
5239
-
5240
- <xsl:call-template name="calculate-column-widths">
5241
- <xsl:with-param name="cols-count" select="2"/>
5242
- <xsl:with-param name="table" select="$simple-table"/>
5243
- </xsl:call-template>
5244
-
5245
- </xsl:if>
5246
- </xsl:variable>
5247
-
5248
- <xsl:variable name="maxlength_dt">
5249
- <xsl:for-each select="*[local-name() = 'dl'][1]">
5250
- <xsl:call-template name="getMaxLength_dt"/>
5251
- </xsl:for-each>
5252
- </xsl:variable>
5253
-
5254
- <fo:block>
5255
- <fo:table width="95%" table-layout="fixed">
5256
- <xsl:if test="normalize-space($key_iso) = 'true'">
5257
- <xsl:attribute name="font-size">10pt</xsl:attribute>
5324
+ <fo:table-body>
5325
+ <xsl:for-each select="xalan:nodeset($references)//fn">
5326
+ <xsl:variable name="reference" select="@reference"/>
5327
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
5328
+ <fo:table-row>
5329
+ <fo:table-cell>
5330
+ <fo:block>
5331
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
5332
+ <xsl:value-of select="@reference"/>
5333
+ </fo:inline>
5334
+ </fo:block>
5335
+ </fo:table-cell>
5336
+ <fo:table-cell>
5337
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
5338
+ <xsl:if test="normalize-space($key_iso) = 'true'">
5258
5339
 
5259
- </xsl:if>
5260
- <xsl:choose>
5261
- <!-- if there 'dl', then set same columns width -->
5262
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
5263
- <xsl:call-template name="setColumnWidth_dl">
5264
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
5265
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
5266
- </xsl:call-template>
5267
- </xsl:when>
5268
- <xsl:otherwise>
5269
- <fo:table-column column-width="15%"/>
5270
- <fo:table-column column-width="85%"/>
5271
- </xsl:otherwise>
5272
- </xsl:choose>
5273
- <fo:table-body>
5274
- <xsl:for-each select="xalan:nodeset($references)//fn">
5275
- <xsl:variable name="reference" select="@reference"/>
5276
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
5277
- <fo:table-row>
5278
- <fo:table-cell>
5279
- <fo:block>
5280
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
5281
- <xsl:value-of select="@reference"/>
5282
- </fo:inline>
5283
- </fo:block>
5284
- </fo:table-cell>
5285
- <fo:table-cell>
5286
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
5287
- <xsl:if test="normalize-space($key_iso) = 'true'">
5340
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
5288
5341
 
5289
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
5342
+ </xsl:if>
5343
+ <xsl:copy-of select="./node()"/>
5344
+ </fo:block>
5345
+ </fo:table-cell>
5346
+ </fo:table-row>
5347
+ </xsl:if>
5348
+ </xsl:for-each>
5349
+ </fo:table-body>
5350
+ </fo:table>
5290
5351
 
5291
- </xsl:if>
5292
- <xsl:copy-of select="./node()"/>
5293
- </fo:block>
5294
- </fo:table-cell>
5295
- </fo:table-row>
5296
- </xsl:if>
5297
- </xsl:for-each>
5298
- </fo:table-body>
5299
- </fo:table>
5300
5352
  </fo:block>
5301
5353
  </xsl:if>
5302
5354
 
@@ -5341,6 +5393,8 @@
5341
5393
  <!-- <dl><xsl:copy-of select="."/></dl> -->
5342
5394
  <fo:block-container>
5343
5395
 
5396
+ <xsl:call-template name="setBlockSpanAll"/>
5397
+
5344
5398
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
5345
5399
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
5346
5400
  </xsl:if>
@@ -5381,12 +5435,14 @@
5381
5435
 
5382
5436
  <xsl:attribute name="margin-bottom">0</xsl:attribute>
5383
5437
 
5384
- <xsl:variable name="title-where">
5438
+ <!-- <xsl:variable name="title-where">
5385
5439
  <xsl:call-template name="getLocalizedString">
5386
5440
  <xsl:with-param name="key">where</xsl:with-param>
5387
5441
  </xsl:call-template>
5388
5442
  </xsl:variable>
5389
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
5443
+ <xsl:value-of select="$title-where"/> -->
5444
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
5445
+ <xsl:text> </xsl:text>
5390
5446
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
5391
5447
  <xsl:text/>
5392
5448
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -5398,12 +5454,14 @@
5398
5454
 
5399
5455
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
5400
5456
 
5401
- <xsl:variable name="title-where">
5457
+ <!-- <xsl:variable name="title-where">
5402
5458
  <xsl:call-template name="getLocalizedString">
5403
5459
  <xsl:with-param name="key">where</xsl:with-param>
5404
5460
  </xsl:call-template>
5405
5461
  </xsl:variable>
5406
- <xsl:value-of select="$title-where"/>
5462
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
5463
+ <!-- preceding 'p' with word 'where' -->
5464
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
5407
5465
  </fo:block>
5408
5466
  </xsl:when> <!-- END: a few components -->
5409
5467
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -5598,6 +5656,9 @@
5598
5656
 
5599
5657
  </xsl:template> <!-- END: dl -->
5600
5658
 
5659
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
5660
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
5661
+
5601
5662
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
5602
5663
  <xsl:param name="process">false</xsl:param>
5603
5664
  <xsl:if test="$process = 'true'">
@@ -6496,8 +6557,8 @@
6496
6557
 
6497
6558
  <!-- add zero-width space (#x200B) after dot with next non-digit -->
6498
6559
  <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
6499
- <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right -->
6500
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→)','$1​')"/>
6560
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
6561
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
6501
6562
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
6502
6563
  <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
6503
6564
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
@@ -6508,8 +6569,19 @@
6508
6569
  <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
6509
6570
  <!-- add zero-width space (#x200B) after character: , -->
6510
6571
  <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
6572
+ <!-- add zero-width space (#x200B) after character: '/' -->
6573
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
6511
6574
 
6512
- <xsl:value-of select="$text7"/>
6575
+ <xsl:variable name="text9">
6576
+ <xsl:choose>
6577
+ <xsl:when test="$isGenerateTableIF = 'true'">
6578
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
6579
+ </xsl:when>
6580
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
6581
+ </xsl:choose>
6582
+ </xsl:variable>
6583
+
6584
+ <xsl:value-of select="$text9"/>
6513
6585
  </xsl:template>
6514
6586
 
6515
6587
  <xsl:template name="add-zero-spaces-link-java">
@@ -6517,8 +6589,8 @@
6517
6589
 
6518
6590
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
6519
6591
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
6520
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
6521
- <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
6592
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
6593
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
6522
6594
  <!-- remove zero-width space at the end -->
6523
6595
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
6524
6596
  </xsl:template>
@@ -6873,9 +6945,28 @@
6873
6945
  </xsl:variable>
6874
6946
  <xsl:copy-of select="$newRow"/>
6875
6947
 
6876
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6877
- <xsl:with-param name="previousRow" select="$newRow"/>
6878
- </xsl:apply-templates>
6948
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
6949
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
6950
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
6951
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
6952
+ <xsl:choose>
6953
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
6954
+ <xsl:copy-of select="following-sibling::tr"/>
6955
+ </xsl:when>
6956
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
6957
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
6958
+
6959
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6960
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
6961
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6962
+ </xsl:apply-templates>
6963
+ </xsl:when> -->
6964
+ <xsl:otherwise>
6965
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6966
+ <xsl:with-param name="previousRow" select="$newRow"/>
6967
+ </xsl:apply-templates>
6968
+ </xsl:otherwise>
6969
+ </xsl:choose>
6879
6970
  </xsl:template>
6880
6971
  <!-- End mode simple-table-rowspan -->
6881
6972
 
@@ -7038,6 +7129,27 @@
7038
7129
  </xsl:call-template>
7039
7130
  </xsl:template>
7040
7131
 
7132
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
7133
+ <xsl:variable name="link">
7134
+ <link_updated>
7135
+ <xsl:variable name="target_text">
7136
+ <xsl:choose>
7137
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
7138
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
7139
+ </xsl:when>
7140
+ <xsl:otherwise>
7141
+ <xsl:value-of select="normalize-space(@target)"/>
7142
+ </xsl:otherwise>
7143
+ </xsl:choose>
7144
+ </xsl:variable>
7145
+ <xsl:value-of select="$target_text"/>
7146
+ </link_updated>
7147
+ </xsl:variable>
7148
+ <xsl:for-each select="xalan:nodeset($link)/*">
7149
+ <xsl:apply-templates mode="td_text_with_formatting"/>
7150
+ </xsl:for-each>
7151
+ </xsl:template>
7152
+
7041
7153
  <xsl:template name="getFormattingTags">
7042
7154
  <tags>
7043
7155
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -7386,7 +7498,7 @@
7386
7498
  </xsl:variable>
7387
7499
  <fo:inline xsl:use-attribute-sets="link-style">
7388
7500
 
7389
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
7501
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
7390
7502
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
7391
7503
  </xsl:if>
7392
7504
 
@@ -7441,13 +7553,17 @@
7441
7553
  </xsl:template>
7442
7554
 
7443
7555
  <xsl:template match="*[local-name() = 'callout']">
7444
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
7556
+ <xsl:choose>
7557
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
7558
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
7559
+ </xsl:choose>
7445
7560
  </xsl:template>
7446
7561
 
7447
7562
  <xsl:template match="*[local-name() = 'annotation']">
7448
7563
  <xsl:variable name="annotation-id" select="@id"/>
7449
7564
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
7450
7565
  <fo:block id="{$annotation-id}" white-space="nowrap">
7566
+
7451
7567
  <fo:inline>
7452
7568
  <xsl:apply-templates>
7453
7569
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -7552,6 +7668,10 @@
7552
7668
  <!-- ====== -->
7553
7669
  <!-- ====== -->
7554
7670
 
7671
+ <xsl:template name="setBlockSpanAll">
7672
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
7673
+ </xsl:template>
7674
+
7555
7675
  <!-- ====== -->
7556
7676
  <!-- note -->
7557
7677
  <!-- termnote -->
@@ -7561,6 +7681,8 @@
7561
7681
 
7562
7682
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
7563
7683
 
7684
+ <xsl:call-template name="setBlockSpanAll"/>
7685
+
7564
7686
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7565
7687
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7566
7688
  </xsl:if>
@@ -7615,6 +7737,8 @@
7615
7737
  <xsl:template match="*[local-name() = 'termnote']">
7616
7738
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
7617
7739
 
7740
+ <xsl:call-template name="setBlockSpanAll"/>
7741
+
7618
7742
  <xsl:if test="$doctype = 'amendment' and parent::*[local-name() = 'quote']">
7619
7743
  <xsl:attribute name="font-size">inherit</xsl:attribute>
7620
7744
  </xsl:if>
@@ -7753,10 +7877,10 @@
7753
7877
  <fo:block xsl:use-attribute-sets="figure-style">
7754
7878
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
7755
7879
  </fo:block>
7756
- <xsl:call-template name="fn_display_figure"/>
7757
7880
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
7758
7881
  <xsl:call-template name="note"/>
7759
7882
  </xsl:for-each>
7883
+ <xsl:call-template name="fn_display_figure"/>
7760
7884
 
7761
7885
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
7762
7886
 
@@ -7819,7 +7943,13 @@
7819
7943
  </xsl:choose>
7820
7944
  </xsl:variable>
7821
7945
 
7822
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7946
+ <xsl:variable name="image_width_effective">
7947
+
7948
+ <xsl:value-of select="$width_effective"/>
7949
+
7950
+ </xsl:variable>
7951
+
7952
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7823
7953
  <xsl:if test="number($scale) &lt; 100">
7824
7954
 
7825
7955
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -8406,6 +8536,13 @@
8406
8536
  <xsl:when test="$contents_nodes/doc">
8407
8537
  <xsl:choose>
8408
8538
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
8539
+
8540
+ <xsl:if test="$contents_nodes/collection">
8541
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
8542
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
8543
+ </fo:bookmark>
8544
+ </xsl:if>
8545
+
8409
8546
  <xsl:for-each select="$contents_nodes/doc">
8410
8547
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
8411
8548
  <xsl:if test="@bundle = 'true'">
@@ -9519,6 +9656,9 @@
9519
9656
  <!-- ====== -->
9520
9657
  <xsl:template match="*[local-name() = 'termexample']">
9521
9658
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
9659
+
9660
+ <xsl:call-template name="setBlockSpanAll"/>
9661
+
9522
9662
  <xsl:apply-templates select="*[local-name()='name']"/>
9523
9663
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
9524
9664
  </fo:block>
@@ -9570,6 +9710,8 @@
9570
9710
 
9571
9711
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
9572
9712
 
9713
+ <xsl:call-template name="setBlockSpanAll"/>
9714
+
9573
9715
  <xsl:variable name="fo_element">
9574
9716
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
9575
9717
  inline
@@ -9597,6 +9739,35 @@
9597
9739
  </fo:block-container>
9598
9740
  </xsl:when> <!-- end block -->
9599
9741
 
9742
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
9743
+
9744
+ <xsl:variable name="provisional_distance_between_starts">
9745
+ 7
9746
+ </xsl:variable>
9747
+ <xsl:variable name="indent">
9748
+ 0
9749
+ </xsl:variable>
9750
+
9751
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
9752
+ <fo:list-item>
9753
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
9754
+ <fo:block>
9755
+ <xsl:apply-templates select="*[local-name()='name']">
9756
+ <xsl:with-param name="fo_element">block</xsl:with-param>
9757
+ </xsl:apply-templates>
9758
+ </fo:block>
9759
+ </fo:list-item-label>
9760
+ <fo:list-item-body start-indent="body-start()">
9761
+ <fo:block>
9762
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9763
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9764
+ </xsl:apply-templates>
9765
+ </fo:block>
9766
+ </fo:list-item-body>
9767
+ </fo:list-item>
9768
+ </fo:list-block>
9769
+ </xsl:when> <!-- end list -->
9770
+
9600
9771
  <xsl:otherwise> <!-- inline -->
9601
9772
 
9602
9773
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -9677,6 +9848,11 @@
9677
9848
  </fo:block>
9678
9849
  </fo:block-container>
9679
9850
  </xsl:when>
9851
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
9852
+ <fo:block xsl:use-attribute-sets="example-p-style">
9853
+ <xsl:apply-templates/>
9854
+ </fo:block>
9855
+ </xsl:when>
9680
9856
  <xsl:otherwise>
9681
9857
  <fo:inline xsl:use-attribute-sets="example-p-style">
9682
9858
  <xsl:apply-templates/>
@@ -9794,6 +9970,9 @@
9794
9970
  <!-- ====== -->
9795
9971
  <xsl:template match="*[local-name() = 'quote']">
9796
9972
  <fo:block-container margin-left="0mm">
9973
+
9974
+ <xsl:call-template name="setBlockSpanAll"/>
9975
+
9797
9976
  <xsl:if test="parent::*[local-name() = 'note']">
9798
9977
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
9799
9978
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -10086,6 +10265,8 @@
10086
10265
  <fo:block>
10087
10266
  <xsl:call-template name="setId"/>
10088
10267
 
10268
+ <xsl:call-template name="setBlockSpanAll"/>
10269
+
10089
10270
  <xsl:apply-templates/>
10090
10271
  </fo:block>
10091
10272
  </xsl:template>
@@ -10100,6 +10281,8 @@
10100
10281
  <fo:block break-after="page"/>
10101
10282
  <fo:block id="{@id}">
10102
10283
 
10284
+ <xsl:call-template name="setBlockSpanAll"/>
10285
+
10103
10286
  </fo:block>
10104
10287
  <xsl:apply-templates/>
10105
10288
  </xsl:template>
@@ -10288,6 +10471,44 @@
10288
10471
 
10289
10472
  <fo:list-block xsl:use-attribute-sets="list-style">
10290
10473
 
10474
+ <xsl:variable name="provisional_distance_between_starts_">
10475
+ <attributes xsl:use-attribute-sets="list-style">
10476
+
10477
+ </attributes>
10478
+ </xsl:variable>
10479
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
10480
+ <xsl:if test="$provisional_distance_between_starts != ''">
10481
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
10482
+ </xsl:if>
10483
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
10484
+
10485
+ <!-- increase provisional-distance-between-starts for long lists -->
10486
+ <xsl:if test="local-name() = 'ol'">
10487
+ <!-- Examples: xiii), xviii), xxviii) -->
10488
+ <xsl:variable name="item_numbers">
10489
+ <xsl:for-each select="*[local-name() = 'li']">
10490
+ <item><xsl:call-template name="getListItemFormat"/></item>
10491
+ </xsl:for-each>
10492
+ </xsl:variable>
10493
+
10494
+ <xsl:variable name="max_length">
10495
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
10496
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
10497
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
10498
+ </xsl:for-each>
10499
+ </xsl:variable>
10500
+
10501
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
10502
+ <xsl:variable name="addon" select="$max_length - 4"/>
10503
+ <xsl:if test="$addon &gt; 0">
10504
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
10505
+ </xsl:if>
10506
+ <!-- DEBUG -->
10507
+ <!-- <xsl:copy-of select="$item_numbers"/>
10508
+ <max_length><xsl:value-of select="$max_length"/></max_length>
10509
+ <addon><xsl:value-of select="$addon"/></addon> -->
10510
+ </xsl:if>
10511
+
10291
10512
  <xsl:if test="not(ancestor::*[local-name() = 'ul' or local-name() = 'ol'])">
10292
10513
  <xsl:attribute name="margin-bottom">8pt</xsl:attribute>
10293
10514
  </xsl:if>
@@ -11015,6 +11236,8 @@
11015
11236
 
11016
11237
  <fo:block xsl:use-attribute-sets="admonition-style">
11017
11238
 
11239
+ <xsl:call-template name="setBlockSpanAll"/>
11240
+
11018
11241
  <xsl:if test="@type = 'editorial'">
11019
11242
  <xsl:attribute name="color">green</xsl:attribute>
11020
11243
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -11197,6 +11420,16 @@
11197
11420
  <xsl:apply-templates mode="update_xml_step1"/>
11198
11421
  </xsl:copy>
11199
11422
  </xsl:template>
11423
+
11424
+ <!-- remove semantic xml -->
11425
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
11426
+
11427
+ <!-- remove image/emf -->
11428
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
11429
+
11430
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
11431
+ <xsl:copy-of select="."/>
11432
+ </xsl:template>
11200
11433
  <!-- =========================================================================== -->
11201
11434
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
11202
11435
  <!-- =========================================================================== -->
@@ -11297,6 +11530,10 @@
11297
11530
  </xsl:call-template>
11298
11531
  </xsl:template>
11299
11532
 
11533
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step2">
11534
+ <xsl:copy-of select="."/>
11535
+ </xsl:template>
11536
+
11300
11537
  <!-- =========================================================================== -->
11301
11538
  <!-- END STEP2: add 'fn' after 'eref' and 'origin', if referenced to bibitem with 'note' = Withdrawn.' or 'Cancelled and replaced...' -->
11302
11539
  <!-- =========================================================================== -->
@@ -11318,7 +11555,7 @@
11318
11555
 
11319
11556
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
11320
11557
 
11321
- <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">
11558
+ <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">
11322
11559
 
11323
11560
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
11324
11561
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -11356,7 +11593,7 @@
11356
11593
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
11357
11594
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
11358
11595
  <!-- add &lt; and &gt; to \S -->
11359
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
11596
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
11360
11597
  <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>
11361
11598
  <xsl:variable name="text3">
11362
11599
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -11378,7 +11615,8 @@
11378
11615
  <xsl:choose>
11379
11616
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
11380
11617
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
11381
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
11618
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
11619
+ <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>
11382
11620
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
11383
11621
  <xsl:choose>
11384
11622
  <xsl:when test="self::text()">
@@ -11399,6 +11637,10 @@
11399
11637
 
11400
11638
  </xsl:template>
11401
11639
 
11640
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
11641
+ <xsl:copy-of select="."/>
11642
+ </xsl:template>
11643
+
11402
11644
  <xsl:template name="replace_text_tags">
11403
11645
  <xsl:param name="tag_open"/>
11404
11646
  <xsl:param name="tag_close"/>
@@ -11425,6 +11667,194 @@
11425
11667
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
11426
11668
  <!-- ===================================== -->
11427
11669
 
11670
+ <!-- ===================================== -->
11671
+ <!-- ===================================== -->
11672
+ <!-- Make linear XML (need for landscape orientation) -->
11673
+ <!-- ===================================== -->
11674
+ <!-- ===================================== -->
11675
+ <xsl:template match="@*|node()" mode="linear_xml">
11676
+ <xsl:copy>
11677
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
11678
+ </xsl:copy>
11679
+ </xsl:template>
11680
+
11681
+ <xsl:template match="processing-instruction()" mode="linear_xml">
11682
+ <xsl:copy-of select="."/>
11683
+ </xsl:template>
11684
+
11685
+ <!-- From:
11686
+ <clause>
11687
+ <title>...</title>
11688
+ <p>...</p>
11689
+ </clause>
11690
+ To:
11691
+ <clause/>
11692
+ <title>...</title>
11693
+ <p>...</p>
11694
+ -->
11695
+ <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">
11696
+
11697
+ <xsl:copy>
11698
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11699
+
11700
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11701
+
11702
+ <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'">
11703
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11704
+ </xsl:if>
11705
+ </xsl:copy>
11706
+
11707
+ <xsl:apply-templates mode="linear_xml"/>
11708
+ </xsl:template>
11709
+
11710
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
11711
+ <xsl:copy>
11712
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11713
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11714
+ <xsl:variable name="level">
11715
+ <xsl:call-template name="getLevel"/>
11716
+ </xsl:variable>
11717
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11718
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
11719
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
11720
+ </xsl:copy>
11721
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
11722
+ </xsl:template>
11723
+
11724
+ <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">
11725
+ <xsl:copy>
11726
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11727
+
11728
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11729
+
11730
+ <xsl:variable name="level">
11731
+ <xsl:call-template name="getLevel"/>
11732
+ </xsl:variable>
11733
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
11734
+
11735
+ <xsl:if test="parent::*[local-name() = 'annex']">
11736
+ <xsl:attribute name="depth">1</xsl:attribute>
11737
+ </xsl:if>
11738
+
11739
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
11740
+ <xsl:copy-of select="../@inline-header"/>
11741
+ </xsl:if>
11742
+
11743
+ <xsl:attribute name="ancestor">
11744
+ <xsl:choose>
11745
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
11746
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
11747
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
11748
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
11749
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
11750
+ </xsl:choose>
11751
+ </xsl:attribute>
11752
+
11753
+ <xsl:apply-templates mode="linear_xml"/>
11754
+ </xsl:copy>
11755
+ </xsl:template>
11756
+
11757
+ <!-- add @to = figure, table, clause -->
11758
+ <!-- add @depth = from -->
11759
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
11760
+ <xsl:copy>
11761
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11762
+ <xsl:variable name="target" select="@target"/>
11763
+ <xsl:attribute name="to">
11764
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
11765
+ </xsl:attribute>
11766
+ <xsl:attribute name="depth">
11767
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
11768
+ </xsl:attribute>
11769
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11770
+ </xsl:copy>
11771
+ </xsl:template>
11772
+
11773
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
11774
+ <xsl:choose>
11775
+ <xsl:when test="contains(., $non_breaking_hyphen)">
11776
+ <xsl:call-template name="replaceChar">
11777
+ <xsl:with-param name="text" select="."/>
11778
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
11779
+ <xsl:with-param name="by" select="'-'"/>
11780
+ </xsl:call-template>
11781
+ </xsl:when>
11782
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
11783
+ </xsl:choose>
11784
+ </xsl:template>
11785
+
11786
+ <xsl:template name="replaceChar">
11787
+ <xsl:param name="text"/>
11788
+ <xsl:param name="replace"/>
11789
+ <xsl:param name="by"/>
11790
+ <xsl:choose>
11791
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
11792
+ <xsl:value-of select="$text"/>
11793
+ </xsl:when>
11794
+ <xsl:when test="contains($text, $replace)">
11795
+ <xsl:value-of select="substring-before($text,$replace)"/>
11796
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
11797
+ <xsl:call-template name="replaceChar">
11798
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
11799
+ <xsl:with-param name="replace" select="$replace"/>
11800
+ <xsl:with-param name="by" select="$by"/>
11801
+ </xsl:call-template>
11802
+ </xsl:when>
11803
+ <xsl:otherwise>
11804
+ <xsl:value-of select="$text"/>
11805
+ </xsl:otherwise>
11806
+ </xsl:choose>
11807
+ </xsl:template>
11808
+
11809
+ <xsl:template match="*[local-name() = 'inlineChar']">
11810
+ <fo:inline><xsl:value-of select="."/></fo:inline>
11811
+ </xsl:template>
11812
+
11813
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
11814
+ <!--
11815
+ <fn reference="1">
11816
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
11817
+ </fn>
11818
+ -->
11819
+ <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">
11820
+ <xsl:variable name="p_fn_">
11821
+ <xsl:call-template name="get_fn_list"/>
11822
+ </xsl:variable>
11823
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
11824
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
11825
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
11826
+ <xsl:variable name="reference" select="@reference"/>
11827
+ <!-- fn sequence number in document -->
11828
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
11829
+
11830
+ <xsl:copy>
11831
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11832
+ <!-- put actual reference number -->
11833
+ <xsl:attribute name="current_fn_number">
11834
+ <xsl:value-of select="$current_fn_number"/>
11835
+ </xsl:attribute>
11836
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
11837
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
11838
+ </xsl:attribute>
11839
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11840
+ </xsl:copy>
11841
+ </xsl:template>
11842
+
11843
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
11844
+ <xsl:copy>
11845
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11846
+ <xsl:if test="@depth = '1'">
11847
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11848
+ </xsl:if>
11849
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11850
+ </xsl:copy>
11851
+ </xsl:template>
11852
+ <!-- ===================================== -->
11853
+ <!-- ===================================== -->
11854
+ <!-- END: Make linear XML (need for landscape orientation) -->
11855
+ <!-- ===================================== -->
11856
+ <!-- ===================================== -->
11857
+
11428
11858
  <!-- for correct rendering combining chars -->
11429
11859
  <xsl:template match="*[local-name() = 'lang_none']">
11430
11860
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -11981,6 +12411,23 @@
11981
12411
  </xsl:if>
11982
12412
  </xsl:template>
11983
12413
 
12414
+ <xsl:template name="setBlockAttributes">
12415
+ <xsl:param name="text_align_default">left</xsl:param>
12416
+ <xsl:call-template name="setTextAlignment">
12417
+ <xsl:with-param name="default" select="$text_align_default"/>
12418
+ </xsl:call-template>
12419
+
12420
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
12421
+ <!-- Example: keep-lines-together="true" -->
12422
+ <xsl:if test="@keep-lines-together = 'true'">
12423
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
12424
+ </xsl:if>
12425
+ <!-- Example: keep-with-next="true" -->
12426
+ <xsl:if test="@keep-with-next = 'true'">
12427
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
12428
+ </xsl:if>
12429
+ </xsl:template>
12430
+
11984
12431
  <xsl:template name="number-to-words">
11985
12432
  <xsl:param name="number"/>
11986
12433
  <xsl:param name="first"/>