metanorma-bipm 2.2.5 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@
32
32
  <xsl:variable name="doc_first">
33
33
  <xsl:if test="*[local-name()='metanorma-collection']">
34
34
  <xsl:variable name="doc_first_step1">
35
- <xsl:apply-templates select="(/*[local-name()='metanorma-collection']//*[contains(local-name(), '-standard')])[1]" mode="flatxml_step1">
35
+ <xsl:apply-templates select="(/*[local-name()='metanorma-collection']//*[local-name() = 'bipm-standard'])[1]" mode="flatxml_step1">
36
36
  <xsl:with-param name="num" select="'first'"/>
37
37
  </xsl:apply-templates>
38
38
  </xsl:variable>
@@ -44,7 +44,7 @@
44
44
  </xsl:variable>
45
45
  <xsl:variable name="docs_slave">
46
46
  <xsl:if test="*[local-name()='metanorma-collection']">
47
- <xsl:for-each select="(/*[local-name()='metanorma-collection']//*[contains(local-name(), '-standard')])[position() &gt; 1]">
47
+ <xsl:for-each select="(/*[local-name()='metanorma-collection']//*[local-name() = 'bipm-standard'])[position() &gt; 1]">
48
48
  <xsl:variable name="doc_first_step1">
49
49
  <xsl:apply-templates select="." mode="flatxml_step1">
50
50
  <xsl:with-param name="num" select="'slave'"/>
@@ -63,7 +63,7 @@
63
63
  <xsl:variable name="docs_count">
64
64
  <xsl:choose>
65
65
  <xsl:when test="/*[local-name()='metanorma-collection']">
66
- <xsl:value-of select="count(/*[local-name()='metanorma-collection']//*[contains(local-name(), '-standard')])"/>
66
+ <xsl:value-of select="count(/*[local-name()='metanorma-collection']//*[local-name() = 'bipm-standard'])"/>
67
67
  </xsl:when>
68
68
  <xsl:otherwise>1</xsl:otherwise>
69
69
  </xsl:choose>
@@ -88,7 +88,7 @@
88
88
  -->
89
89
  <xsl:variable name="contents_">
90
90
 
91
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
91
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
92
92
  <xsl:variable name="lang" select="*[local-name()='bibdata']/*[local-name()='language'][@current = 'true']"/>
93
93
  <xsl:variable name="current_document">
94
94
  <xsl:copy-of select="."/>
@@ -332,12 +332,12 @@
332
332
  <fo:flow flow-name="xsl-region-body" line-height="115%">
333
333
 
334
334
  <!-- Copyright -->
335
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
335
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
336
336
  <xsl:apply-templates select="./*[local-name()='boilerplate']/*"/>
337
337
  <fo:block break-after="page"/>
338
338
  </xsl:for-each>
339
339
 
340
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
340
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
341
341
  <xsl:variable name="current_document">
342
342
  <xsl:copy-of select="."/>
343
343
  </xsl:variable>
@@ -417,23 +417,23 @@
417
417
 
418
418
  <!-- Foreword, Introduction -->
419
419
  <!-- <xsl:call-template name="processPrefaceSectionsDefault"/> -->
420
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
420
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
421
421
  <fo:block break-after="page"/>
422
422
  <xsl:apply-templates select="./*[local-name()='preface']/*[local-name()='abstract']"/>
423
423
  </xsl:for-each>
424
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
424
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
425
425
  <fo:block break-after="page"/>
426
426
  <xsl:apply-templates select="./*[local-name()='preface']/*[local-name()='foreword']"/>
427
427
  </xsl:for-each>
428
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
428
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
429
429
  <fo:block break-after="page"/>
430
430
  <xsl:apply-templates select="./*[local-name()='preface']/*[local-name()='introduction']"/>
431
431
  </xsl:for-each>
432
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
432
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
433
433
  <fo:block break-after="page"/>
434
434
  <xsl:apply-templates select="./*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements' and local-name() != 'note' and local-name() != 'admonition']"/>
435
435
  </xsl:for-each>
436
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
436
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
437
437
  <fo:block break-after="page"/>
438
438
  <xsl:apply-templates select="./*[local-name()='preface']/*[local-name()='acknowledgements']"/>
439
439
  </xsl:for-each>
@@ -456,7 +456,7 @@
456
456
  <!-- Show title -->
457
457
  <!-- Example: Evaluation of measurement data — An introduction to the `Guide to the expression of uncertainty in measurement' and related documents -->
458
458
 
459
- <xsl:for-each select="//*[contains(local-name(), '-standard')]">
459
+ <xsl:for-each select="//*[local-name() = 'bipm-standard']">
460
460
  <fo:block font-size="20pt" font-weight="bold" margin-bottom="20pt" space-before="36pt" line-height="1.1">
461
461
  <xsl:variable name="curr_lang" select="*[local-name()='bibdata']/*[local-name()='language'][@current = 'true']"/>
462
462
 
@@ -492,7 +492,7 @@
492
492
  <!-- Clause(s) -->
493
493
  <fo:block>
494
494
  <xsl:choose>
495
- <xsl:when test="count(//*[contains(local-name(), '-standard')]) = 1 ">
495
+ <xsl:when test="count(//*[local-name() = 'bipm-standard']) = 1 ">
496
496
  <xsl:call-template name="processMainSectionsDefault"/>
497
497
  </xsl:when>
498
498
  <xsl:otherwise>
@@ -1376,7 +1376,7 @@
1376
1376
  </xsl:copy>
1377
1377
  </xsl:template>
1378
1378
 
1379
- <xsl:template match="*[contains(local-name(), '-standard')]" mode="flatxml_step1">
1379
+ <xsl:template match="*[local-name() = 'bipm-standard']" mode="flatxml_step1">
1380
1380
  <xsl:param name="num"/>
1381
1381
  <xsl:copy>
1382
1382
  <xsl:apply-templates select="@*" mode="flatxml_step1"/>
@@ -2280,21 +2280,21 @@
2280
2280
 
2281
2281
  <xsl:attribute-set name="table-header-cell-style">
2282
2282
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2283
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2284
2283
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2285
2284
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2286
2285
  <xsl:attribute name="display-align">center</xsl:attribute>
2287
2286
 
2287
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2288
2288
  <xsl:attribute name="padding-top">1mm</xsl:attribute>
2289
2289
 
2290
2290
  </xsl:attribute-set> <!-- table-header-cell-style -->
2291
2291
 
2292
2292
  <xsl:attribute-set name="table-cell-style">
2293
2293
  <xsl:attribute name="display-align">center</xsl:attribute>
2294
- <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2295
2294
  <xsl:attribute name="padding-left">1mm</xsl:attribute>
2296
2295
  <xsl:attribute name="padding-right">1mm</xsl:attribute>
2297
2296
 
2297
+ <xsl:attribute name="border">solid black 1pt</xsl:attribute>
2298
2298
  <xsl:attribute name="padding-top">0.5mm</xsl:attribute>
2299
2299
 
2300
2300
  </xsl:attribute-set> <!-- table-cell-style -->
@@ -2504,6 +2504,7 @@
2504
2504
  <xsl:attribute-set name="term-name-style">
2505
2505
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
2506
2506
  <xsl:attribute name="font-weight">bold</xsl:attribute>
2507
+
2507
2508
  </xsl:attribute-set>
2508
2509
 
2509
2510
  <xsl:attribute-set name="figure-block-style">
@@ -3047,7 +3048,7 @@
3047
3048
  <xsl:apply-templates select="." mode="contents"/>
3048
3049
  </xsl:for-each>
3049
3050
 
3050
- <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')]]">
3051
+ <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]">
3051
3052
  <xsl:sort select="@displayorder" data-type="number"/>
3052
3053
  <xsl:apply-templates select="." mode="contents"/>
3053
3054
  </xsl:for-each>
@@ -3453,7 +3454,7 @@
3453
3454
  <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
3454
3455
  </xsl:when>
3455
3456
  <xsl:otherwise>
3456
- <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 -->
3457
+ <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 -->
3457
3458
  </xsl:otherwise>
3458
3459
  </xsl:choose>
3459
3460
 
@@ -3971,7 +3972,7 @@
3971
3972
  <xsl:param name="colwidths"/>
3972
3973
  <xsl:param name="colgroup"/>
3973
3974
 
3974
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3975
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
3975
3976
 
3976
3977
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
3977
3978
 
@@ -3990,6 +3991,10 @@
3990
3991
  </xsl:choose>
3991
3992
  </xsl:variable>
3992
3993
 
3994
+ <xsl:variable name="table_fn_block">
3995
+ <xsl:call-template name="table_fn_display"/>
3996
+ </xsl:variable>
3997
+
3993
3998
  <xsl:variable name="tableWithNotesAndFootnotes">
3994
3999
 
3995
4000
  <fo:table keep-with-previous="always">
@@ -4035,13 +4040,28 @@
4035
4040
 
4036
4041
  <!-- except gb and bsi -->
4037
4042
 
4043
+ <xsl:apply-templates select="../*[local-name()='dl']"/>
4038
4044
  <xsl:apply-templates select="../*[local-name()='note']"/>
4039
4045
 
4046
+ <xsl:variable name="isDisplayRowSeparator">
4047
+
4048
+ </xsl:variable>
4049
+
4040
4050
  <!-- horizontal row separator -->
4051
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4052
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
4053
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4054
+
4055
+ <xsl:call-template name="setBordersTableArray"/>
4056
+ <fo:block font-size="1pt"> </fo:block>
4057
+ </fo:block-container>
4058
+ </xsl:if>
4059
+ </xsl:if>
4041
4060
 
4042
4061
  <!-- fn processing -->
4043
4062
 
4044
- <xsl:call-template name="table_fn_display"/>
4063
+ <!-- <xsl:call-template name="table_fn_display" /> -->
4064
+ <xsl:copy-of select="$table_fn_block"/>
4045
4065
 
4046
4066
  <!-- for PAS display Notes after footnotes -->
4047
4067
 
@@ -4187,7 +4207,7 @@
4187
4207
  <!-- ===================== -->
4188
4208
  <!-- Table's row processing -->
4189
4209
  <!-- ===================== -->
4190
- <!-- row in table header (thead) -->
4210
+ <!-- row in table header (thead) thead/tr -->
4191
4211
  <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
4192
4212
  <fo:table-row xsl:use-attribute-sets="table-header-row-style">
4193
4213
 
@@ -4210,7 +4230,29 @@
4210
4230
  </fo:table-row>
4211
4231
  </xsl:template>
4212
4232
 
4213
- <!-- row in table footer (tfoot) -->
4233
+ <xsl:template name="setBorderUnderRow">
4234
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
4235
+ <xsl:choose>
4236
+ <xsl:when test="$border_under_row_ != ''">
4237
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
4238
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
4239
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
4240
+ <xsl:variable name="border_under_row">
4241
+ <xsl:call-template name="split">
4242
+ <xsl:with-param name="pText" select="$border_under_row_"/>
4243
+ </xsl:call-template>
4244
+ </xsl:variable>
4245
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
4246
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4247
+ </xsl:if>
4248
+ </xsl:when>
4249
+ <xsl:otherwise>
4250
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4251
+ </xsl:otherwise>
4252
+ </xsl:choose>
4253
+ </xsl:template>
4254
+
4255
+ <!-- row in table footer (tfoot), tfoot/tr -->
4214
4256
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4215
4257
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
4216
4258
 
@@ -4545,8 +4587,16 @@
4545
4587
  <!-- figure's footnotes rendering -->
4546
4588
  <xsl:template name="fn_display_figure">
4547
4589
 
4590
+ <!-- current figure id -->
4591
+ <xsl:variable name="figure_id_">
4592
+ <xsl:value-of select="@id"/>
4593
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
4594
+ </xsl:variable>
4595
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
4596
+
4597
+ <!-- all footnotes relates to the current figure -->
4548
4598
  <xsl:variable name="references">
4549
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
4599
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
4550
4600
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
4551
4601
  <xsl:apply-templates/>
4552
4602
  </fn>
@@ -4559,91 +4609,93 @@
4559
4609
  true
4560
4610
  </xsl:variable>
4561
4611
 
4562
- <!-- current hierarchy is 'figure' element -->
4563
- <xsl:variable name="following_dl_colwidths">
4564
- <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4565
- <xsl:variable name="simple-table">
4566
- <!-- <xsl:variable name="doc_ns">
4567
- <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4612
+ <fo:block>
4613
+
4614
+ <!-- current hierarchy is 'figure' element -->
4615
+ <xsl:variable name="following_dl_colwidths">
4616
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4617
+ <xsl:variable name="simple-table">
4618
+ <!-- <xsl:variable name="doc_ns">
4619
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4620
+ </xsl:variable>
4621
+ <xsl:variable name="ns">
4622
+ <xsl:choose>
4623
+ <xsl:when test="normalize-space($doc_ns) != ''">
4624
+ <xsl:value-of select="normalize-space($doc_ns)"/>
4625
+ </xsl:when>
4626
+ <xsl:otherwise>
4627
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
4628
+ </xsl:otherwise>
4629
+ </xsl:choose>
4630
+ </xsl:variable> -->
4631
+
4632
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
4633
+ <tbody>
4634
+ <xsl:apply-templates mode="dl"/>
4635
+ </tbody>
4636
+ </xsl:for-each>
4637
+ </xsl:variable>
4638
+
4639
+ <xsl:call-template name="calculate-column-widths">
4640
+ <xsl:with-param name="cols-count" select="2"/>
4641
+ <xsl:with-param name="table" select="$simple-table"/>
4642
+ </xsl:call-template>
4643
+
4644
+ </xsl:if>
4645
+ </xsl:variable>
4646
+
4647
+ <xsl:variable name="maxlength_dt">
4648
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
4649
+ <xsl:call-template name="getMaxLength_dt"/>
4650
+ </xsl:for-each>
4568
4651
  </xsl:variable>
4569
- <xsl:variable name="ns">
4652
+
4653
+ <fo:table width="95%" table-layout="fixed">
4654
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4655
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
4656
+
4657
+ </xsl:if>
4570
4658
  <xsl:choose>
4571
- <xsl:when test="normalize-space($doc_ns) != ''">
4572
- <xsl:value-of select="normalize-space($doc_ns)"/>
4659
+ <!-- if there 'dl', then set same columns width -->
4660
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
4661
+ <xsl:call-template name="setColumnWidth_dl">
4662
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
4663
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4664
+ </xsl:call-template>
4573
4665
  </xsl:when>
4574
4666
  <xsl:otherwise>
4575
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4667
+ <fo:table-column column-width="5%"/>
4668
+ <fo:table-column column-width="95%"/>
4576
4669
  </xsl:otherwise>
4577
4670
  </xsl:choose>
4578
- </xsl:variable> -->
4579
-
4580
- <xsl:for-each select="*[local-name() = 'dl'][1]">
4581
- <tbody>
4582
- <xsl:apply-templates mode="dl"/>
4583
- </tbody>
4584
- </xsl:for-each>
4585
- </xsl:variable>
4586
-
4587
- <xsl:call-template name="calculate-column-widths">
4588
- <xsl:with-param name="cols-count" select="2"/>
4589
- <xsl:with-param name="table" select="$simple-table"/>
4590
- </xsl:call-template>
4591
-
4592
- </xsl:if>
4593
- </xsl:variable>
4594
-
4595
- <xsl:variable name="maxlength_dt">
4596
- <xsl:for-each select="*[local-name() = 'dl'][1]">
4597
- <xsl:call-template name="getMaxLength_dt"/>
4598
- </xsl:for-each>
4599
- </xsl:variable>
4671
+ <fo:table-body>
4672
+ <xsl:for-each select="xalan:nodeset($references)//fn">
4673
+ <xsl:variable name="reference" select="@reference"/>
4674
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4675
+ <fo:table-row>
4676
+ <fo:table-cell>
4677
+ <fo:block>
4678
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
4679
+ <xsl:value-of select="@reference"/>
4680
+ </fo:inline>
4681
+ </fo:block>
4682
+ </fo:table-cell>
4683
+ <fo:table-cell>
4684
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
4685
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4600
4686
 
4601
- <fo:block>
4602
- <fo:table width="95%" table-layout="fixed">
4603
- <xsl:if test="normalize-space($key_iso) = 'true'">
4604
- <xsl:attribute name="font-size">10pt</xsl:attribute>
4687
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
4605
4688
 
4606
- </xsl:if>
4607
- <xsl:choose>
4608
- <!-- if there 'dl', then set same columns width -->
4609
- <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
4610
- <xsl:call-template name="setColumnWidth_dl">
4611
- <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
4612
- <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4613
- </xsl:call-template>
4614
- </xsl:when>
4615
- <xsl:otherwise>
4616
- <fo:table-column column-width="15%"/>
4617
- <fo:table-column column-width="85%"/>
4618
- </xsl:otherwise>
4619
- </xsl:choose>
4620
- <fo:table-body>
4621
- <xsl:for-each select="xalan:nodeset($references)//fn">
4622
- <xsl:variable name="reference" select="@reference"/>
4623
- <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4624
- <fo:table-row>
4625
- <fo:table-cell>
4626
- <fo:block>
4627
- <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
4628
- <xsl:value-of select="@reference"/>
4629
- </fo:inline>
4630
- </fo:block>
4631
- </fo:table-cell>
4632
- <fo:table-cell>
4633
- <fo:block xsl:use-attribute-sets="figure-fn-body-style">
4634
- <xsl:if test="normalize-space($key_iso) = 'true'">
4635
-
4636
- <xsl:attribute name="margin-bottom">0</xsl:attribute>
4689
+ </xsl:if>
4690
+ <xsl:copy-of select="./node()"/>
4691
+ </fo:block>
4692
+ </fo:table-cell>
4693
+ </fo:table-row>
4694
+ </xsl:if>
4695
+ </xsl:for-each>
4696
+ </fo:table-body>
4697
+ </fo:table>
4637
4698
 
4638
- </xsl:if>
4639
- <xsl:copy-of select="./node()"/>
4640
- </fo:block>
4641
- </fo:table-cell>
4642
- </fo:table-row>
4643
- </xsl:if>
4644
- </xsl:for-each>
4645
- </fo:table-body>
4646
- </fo:table>
4647
4699
  </fo:block>
4648
4700
  </xsl:if>
4649
4701
 
@@ -4688,6 +4740,8 @@
4688
4740
  <!-- <dl><xsl:copy-of select="."/></dl> -->
4689
4741
  <fo:block-container>
4690
4742
 
4743
+ <xsl:call-template name="setBlockSpanAll"/>
4744
+
4691
4745
  <xsl:if test="not(ancestor::*[local-name() = 'quote'])">
4692
4746
  <xsl:attribute name="margin-left">0mm</xsl:attribute>
4693
4747
  </xsl:if>
@@ -4728,12 +4782,14 @@
4728
4782
 
4729
4783
  <xsl:attribute name="margin-bottom">0</xsl:attribute>
4730
4784
 
4731
- <xsl:variable name="title-where">
4785
+ <!-- <xsl:variable name="title-where">
4732
4786
  <xsl:call-template name="getLocalizedString">
4733
4787
  <xsl:with-param name="key">where</xsl:with-param>
4734
4788
  </xsl:call-template>
4735
4789
  </xsl:variable>
4736
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
4790
+ <xsl:value-of select="$title-where"/> -->
4791
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
4792
+ <xsl:text> </xsl:text>
4737
4793
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
4738
4794
  <xsl:text/>
4739
4795
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -4745,12 +4801,14 @@
4745
4801
 
4746
4802
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4747
4803
 
4748
- <xsl:variable name="title-where">
4804
+ <!-- <xsl:variable name="title-where">
4749
4805
  <xsl:call-template name="getLocalizedString">
4750
4806
  <xsl:with-param name="key">where</xsl:with-param>
4751
4807
  </xsl:call-template>
4752
4808
  </xsl:variable>
4753
- <xsl:value-of select="$title-where"/>
4809
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
4810
+ <!-- preceding 'p' with word 'where' -->
4811
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
4754
4812
  </fo:block>
4755
4813
  </xsl:when> <!-- END: a few components -->
4756
4814
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -4941,6 +4999,9 @@
4941
4999
 
4942
5000
  </xsl:template> <!-- END: dl -->
4943
5001
 
5002
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
5003
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
5004
+
4944
5005
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4945
5006
  <xsl:param name="process">false</xsl:param>
4946
5007
  <xsl:if test="$process = 'true'">
@@ -5768,20 +5829,34 @@
5768
5829
 
5769
5830
  <xsl:template name="add-zero-spaces-java">
5770
5831
  <xsl:param name="text" select="."/>
5771
- <!-- add zero-width space (#x200B) after characters: dash, dot, equal, underscore, em dash, thin space, arrow right -->
5772
- <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|=|_|—| |→)','$1​')"/>
5832
+
5833
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
5834
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
5835
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
5836
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
5773
5837
  <!-- add zero-width space (#x200B) after characters: colon, if there aren't digits after -->
5774
- <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(:)(\D)','$1​$2')"/>
5838
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
5775
5839
  <!-- add zero-width space (#x200B) after characters: 'great than' -->
5776
- <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' -->
5840
+ <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' -->
5777
5841
  <!-- add zero-width space (#x200B) before characters: 'less than' -->
5778
- <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' -->
5842
+ <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' -->
5779
5843
  <!-- add zero-width space (#x200B) before character: { -->
5780
- <xsl:variable name="text5" select="java:replaceAll(java:java.lang.String.new($text4), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
5844
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
5781
5845
  <!-- add zero-width space (#x200B) after character: , -->
5782
- <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
5846
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
5847
+ <!-- add zero-width space (#x200B) after character: '/' -->
5848
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
5783
5849
 
5784
- <xsl:value-of select="$text6"/>
5850
+ <xsl:variable name="text9">
5851
+ <xsl:choose>
5852
+ <xsl:when test="$isGenerateTableIF = 'true'">
5853
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
5854
+ </xsl:when>
5855
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
5856
+ </xsl:choose>
5857
+ </xsl:variable>
5858
+
5859
+ <xsl:value-of select="$text9"/>
5785
5860
  </xsl:template>
5786
5861
 
5787
5862
  <xsl:template name="add-zero-spaces-link-java">
@@ -5789,8 +5864,8 @@
5789
5864
 
5790
5865
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
5791
5866
  <xsl:variable name="url_continue" select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$2')"/>
5792
- <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space -->
5793
- <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/)','$1​')"/>
5867
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
5868
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
5794
5869
  <!-- remove zero-width space at the end -->
5795
5870
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
5796
5871
  </xsl:template>
@@ -6145,9 +6220,28 @@
6145
6220
  </xsl:variable>
6146
6221
  <xsl:copy-of select="$newRow"/>
6147
6222
 
6148
- <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6149
- <xsl:with-param name="previousRow" select="$newRow"/>
6150
- </xsl:apply-templates>
6223
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
6224
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
6225
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
6226
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
6227
+ <xsl:choose>
6228
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
6229
+ <xsl:copy-of select="following-sibling::tr"/>
6230
+ </xsl:when>
6231
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
6232
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
6233
+
6234
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6235
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
6236
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6237
+ </xsl:apply-templates>
6238
+ </xsl:when> -->
6239
+ <xsl:otherwise>
6240
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6241
+ <xsl:with-param name="previousRow" select="$newRow"/>
6242
+ </xsl:apply-templates>
6243
+ </xsl:otherwise>
6244
+ </xsl:choose>
6151
6245
  </xsl:template>
6152
6246
  <!-- End mode simple-table-rowspan -->
6153
6247
 
@@ -6310,6 +6404,27 @@
6310
6404
  </xsl:call-template>
6311
6405
  </xsl:template>
6312
6406
 
6407
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
6408
+ <xsl:variable name="link">
6409
+ <link_updated>
6410
+ <xsl:variable name="target_text">
6411
+ <xsl:choose>
6412
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
6413
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
6414
+ </xsl:when>
6415
+ <xsl:otherwise>
6416
+ <xsl:value-of select="normalize-space(@target)"/>
6417
+ </xsl:otherwise>
6418
+ </xsl:choose>
6419
+ </xsl:variable>
6420
+ <xsl:value-of select="$target_text"/>
6421
+ </link_updated>
6422
+ </xsl:variable>
6423
+ <xsl:for-each select="xalan:nodeset($link)/*">
6424
+ <xsl:apply-templates mode="td_text_with_formatting"/>
6425
+ </xsl:for-each>
6426
+ </xsl:template>
6427
+
6313
6428
  <xsl:template name="getFormattingTags">
6314
6429
  <tags>
6315
6430
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -6658,7 +6773,7 @@
6658
6773
  </xsl:variable>
6659
6774
  <fo:inline xsl:use-attribute-sets="link-style">
6660
6775
 
6661
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
6776
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
6662
6777
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
6663
6778
  </xsl:if>
6664
6779
 
@@ -6713,13 +6828,17 @@
6713
6828
  </xsl:template>
6714
6829
 
6715
6830
  <xsl:template match="*[local-name() = 'callout']">
6716
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link>
6831
+ <xsl:choose>
6832
+ <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when>
6833
+ <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise>
6834
+ </xsl:choose>
6717
6835
  </xsl:template>
6718
6836
 
6719
6837
  <xsl:template match="*[local-name() = 'annotation']">
6720
6838
  <xsl:variable name="annotation-id" select="@id"/>
6721
6839
  <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/>
6722
6840
  <fo:block id="{$annotation-id}" white-space="nowrap">
6841
+
6723
6842
  <fo:inline>
6724
6843
  <xsl:apply-templates>
6725
6844
  <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/>
@@ -6824,6 +6943,10 @@
6824
6943
  <!-- ====== -->
6825
6944
  <!-- ====== -->
6826
6945
 
6946
+ <xsl:template name="setBlockSpanAll">
6947
+ <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if>
6948
+ </xsl:template>
6949
+
6827
6950
  <!-- ====== -->
6828
6951
  <!-- note -->
6829
6952
  <!-- termnote -->
@@ -6833,6 +6956,8 @@
6833
6956
 
6834
6957
  <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">
6835
6958
 
6959
+ <xsl:call-template name="setBlockSpanAll"/>
6960
+
6836
6961
  <fo:block-container margin-left="0mm" margin-right="0mm">
6837
6962
 
6838
6963
  <fo:block>
@@ -6883,6 +7008,8 @@
6883
7008
  <xsl:template match="*[local-name() = 'termnote']">
6884
7009
  <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style">
6885
7010
 
7011
+ <xsl:call-template name="setBlockSpanAll"/>
7012
+
6886
7013
  <fo:inline xsl:use-attribute-sets="termnote-name-style">
6887
7014
 
6888
7015
  <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
@@ -7015,10 +7142,10 @@
7015
7142
  <fo:block xsl:use-attribute-sets="figure-style">
7016
7143
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
7017
7144
  </fo:block>
7018
- <xsl:call-template name="fn_display_figure"/>
7019
7145
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
7020
7146
  <xsl:call-template name="note"/>
7021
7147
  </xsl:for-each>
7148
+ <xsl:call-template name="fn_display_figure"/>
7022
7149
 
7023
7150
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
7024
7151
 
@@ -7081,7 +7208,13 @@
7081
7208
  </xsl:choose>
7082
7209
  </xsl:variable>
7083
7210
 
7084
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7211
+ <xsl:variable name="image_width_effective">
7212
+
7213
+ <xsl:value-of select="$width_effective"/>
7214
+
7215
+ </xsl:variable>
7216
+
7217
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7085
7218
  <xsl:if test="number($scale) &lt; 100">
7086
7219
 
7087
7220
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -7668,6 +7801,13 @@
7668
7801
  <xsl:when test="$contents_nodes/doc">
7669
7802
  <xsl:choose>
7670
7803
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
7804
+
7805
+ <xsl:if test="$contents_nodes/collection">
7806
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
7807
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
7808
+ </fo:bookmark>
7809
+ </xsl:if>
7810
+
7671
7811
  <xsl:for-each select="$contents_nodes/doc">
7672
7812
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
7673
7813
  <xsl:if test="@bundle = 'true'">
@@ -8780,6 +8920,9 @@
8780
8920
  <!-- ====== -->
8781
8921
  <xsl:template match="*[local-name() = 'termexample']">
8782
8922
  <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style">
8923
+
8924
+ <xsl:call-template name="setBlockSpanAll"/>
8925
+
8783
8926
  <xsl:apply-templates select="*[local-name()='name']"/>
8784
8927
  <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
8785
8928
  </fo:block>
@@ -8831,6 +8974,8 @@
8831
8974
 
8832
8975
  <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
8833
8976
 
8977
+ <xsl:call-template name="setBlockSpanAll"/>
8978
+
8834
8979
  <xsl:variable name="fo_element">
8835
8980
  <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
8836
8981
  inline
@@ -8858,6 +9003,35 @@
8858
9003
  </fo:block-container>
8859
9004
  </xsl:when> <!-- end block -->
8860
9005
 
9006
+ <xsl:when test="contains(normalize-space($fo_element), 'list')">
9007
+
9008
+ <xsl:variable name="provisional_distance_between_starts">
9009
+ 7
9010
+ </xsl:variable>
9011
+ <xsl:variable name="indent">
9012
+ 0
9013
+ </xsl:variable>
9014
+
9015
+ <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm">
9016
+ <fo:list-item>
9017
+ <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()">
9018
+ <fo:block>
9019
+ <xsl:apply-templates select="*[local-name()='name']">
9020
+ <xsl:with-param name="fo_element">block</xsl:with-param>
9021
+ </xsl:apply-templates>
9022
+ </fo:block>
9023
+ </fo:list-item-label>
9024
+ <fo:list-item-body start-indent="body-start()">
9025
+ <fo:block>
9026
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
9027
+ <xsl:with-param name="fo_element" select="$fo_element"/>
9028
+ </xsl:apply-templates>
9029
+ </fo:block>
9030
+ </fo:list-item-body>
9031
+ </fo:list-item>
9032
+ </fo:list-block>
9033
+ </xsl:when> <!-- end list -->
9034
+
8861
9035
  <xsl:otherwise> <!-- inline -->
8862
9036
 
8863
9037
  <!-- display 'EXAMPLE' and first element in the same line -->
@@ -8938,6 +9112,11 @@
8938
9112
  </fo:block>
8939
9113
  </fo:block-container>
8940
9114
  </xsl:when>
9115
+ <xsl:when test="starts-with(normalize-space($element), 'list')">
9116
+ <fo:block xsl:use-attribute-sets="example-p-style">
9117
+ <xsl:apply-templates/>
9118
+ </fo:block>
9119
+ </xsl:when>
8941
9120
  <xsl:otherwise>
8942
9121
  <fo:inline xsl:use-attribute-sets="example-p-style">
8943
9122
  <xsl:apply-templates/>
@@ -9055,6 +9234,9 @@
9055
9234
  <!-- ====== -->
9056
9235
  <xsl:template match="*[local-name() = 'quote']">
9057
9236
  <fo:block-container margin-left="0mm">
9237
+
9238
+ <xsl:call-template name="setBlockSpanAll"/>
9239
+
9058
9240
  <xsl:if test="parent::*[local-name() = 'note']">
9059
9241
  <xsl:if test="not(ancestor::*[local-name() = 'table'])">
9060
9242
  <xsl:attribute name="margin-left">5mm</xsl:attribute>
@@ -9352,6 +9534,8 @@
9352
9534
  <fo:block>
9353
9535
  <xsl:call-template name="setId"/>
9354
9536
 
9537
+ <xsl:call-template name="setBlockSpanAll"/>
9538
+
9355
9539
  <xsl:if test="@inline-header='true'">
9356
9540
  <xsl:attribute name="text-align">justify</xsl:attribute>
9357
9541
  </xsl:if>
@@ -9370,6 +9554,8 @@
9370
9554
  <fo:block break-after="page"/>
9371
9555
  <fo:block id="{@id}">
9372
9556
 
9557
+ <xsl:call-template name="setBlockSpanAll"/>
9558
+
9373
9559
  </fo:block>
9374
9560
  <xsl:apply-templates/>
9375
9561
  </xsl:template>
@@ -9408,6 +9594,8 @@
9408
9594
  <label level="2">−</label><!-- minus sign -->
9409
9595
  <label level="3" font-size="75%">o</label> <!-- white circle -->
9410
9596
 
9597
+ <label>-</label> <!-- full-width hyphen minus -->
9598
+
9411
9599
  </xsl:variable>
9412
9600
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
9413
9601
 
@@ -9560,6 +9748,44 @@
9560
9748
 
9561
9749
  <fo:list-block xsl:use-attribute-sets="list-style">
9562
9750
 
9751
+ <xsl:variable name="provisional_distance_between_starts_">
9752
+ <attributes xsl:use-attribute-sets="list-style">
9753
+
9754
+ </attributes>
9755
+ </xsl:variable>
9756
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
9757
+ <xsl:if test="$provisional_distance_between_starts != ''">
9758
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
9759
+ </xsl:if>
9760
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
9761
+
9762
+ <!-- increase provisional-distance-between-starts for long lists -->
9763
+ <xsl:if test="local-name() = 'ol'">
9764
+ <!-- Examples: xiii), xviii), xxviii) -->
9765
+ <xsl:variable name="item_numbers">
9766
+ <xsl:for-each select="*[local-name() = 'li']">
9767
+ <item><xsl:call-template name="getListItemFormat"/></item>
9768
+ </xsl:for-each>
9769
+ </xsl:variable>
9770
+
9771
+ <xsl:variable name="max_length">
9772
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
9773
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
9774
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
9775
+ </xsl:for-each>
9776
+ </xsl:variable>
9777
+
9778
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
9779
+ <xsl:variable name="addon" select="$max_length - 4"/>
9780
+ <xsl:if test="$addon &gt; 0">
9781
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
9782
+ </xsl:if>
9783
+ <!-- DEBUG -->
9784
+ <!-- <xsl:copy-of select="$item_numbers"/>
9785
+ <max_length><xsl:value-of select="$max_length"/></max_length>
9786
+ <addon><xsl:value-of select="$addon"/></addon> -->
9787
+ </xsl:if>
9788
+
9563
9789
  <xsl:if test="*[local-name() = 'name']">
9564
9790
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
9565
9791
  </xsl:if>
@@ -10288,6 +10514,8 @@
10288
10514
 
10289
10515
  <fo:block xsl:use-attribute-sets="admonition-style">
10290
10516
 
10517
+ <xsl:call-template name="setBlockSpanAll"/>
10518
+
10291
10519
  <xsl:if test="@type = 'editorial'">
10292
10520
  <xsl:attribute name="color">green</xsl:attribute>
10293
10521
  <xsl:attribute name="font-weight">normal</xsl:attribute>
@@ -10471,6 +10699,16 @@
10471
10699
  <xsl:apply-templates mode="update_xml_step1"/>
10472
10700
  </xsl:copy>
10473
10701
  </xsl:template>
10702
+
10703
+ <!-- remove semantic xml -->
10704
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/>
10705
+
10706
+ <!-- remove image/emf -->
10707
+ <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/>
10708
+
10709
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1">
10710
+ <xsl:copy-of select="."/>
10711
+ </xsl:template>
10474
10712
  <!-- =========================================================================== -->
10475
10713
  <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder -->
10476
10714
  <!-- =========================================================================== -->
@@ -10492,7 +10730,7 @@
10492
10730
 
10493
10731
  <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable>
10494
10732
 
10495
- <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">
10733
+ <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">
10496
10734
 
10497
10735
  <!-- enclose standard's number into tag 'keep-together_within-line' -->
10498
10736
  <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
@@ -10522,7 +10760,7 @@
10522
10760
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
10523
10761
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
10524
10762
  <!-- add &lt; and &gt; to \S -->
10525
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
10763
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
10526
10764
  <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>
10527
10765
  <xsl:variable name="text3">
10528
10766
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -10544,7 +10782,8 @@
10544
10782
  <xsl:choose>
10545
10783
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
10546
10784
  <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
10547
- <xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
10785
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
10786
+ <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>
10548
10787
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
10549
10788
  <xsl:choose>
10550
10789
  <xsl:when test="self::text()">
@@ -10565,6 +10804,10 @@
10565
10804
 
10566
10805
  </xsl:template>
10567
10806
 
10807
+ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line">
10808
+ <xsl:copy-of select="."/>
10809
+ </xsl:template>
10810
+
10568
10811
  <xsl:template name="replace_text_tags">
10569
10812
  <xsl:param name="tag_open"/>
10570
10813
  <xsl:param name="tag_close"/>
@@ -10591,6 +10834,194 @@
10591
10834
  <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' -->
10592
10835
  <!-- ===================================== -->
10593
10836
 
10837
+ <!-- ===================================== -->
10838
+ <!-- ===================================== -->
10839
+ <!-- Make linear XML (need for landscape orientation) -->
10840
+ <!-- ===================================== -->
10841
+ <!-- ===================================== -->
10842
+ <xsl:template match="@*|node()" mode="linear_xml">
10843
+ <xsl:copy>
10844
+ <xsl:apply-templates select="@*|node()" mode="linear_xml"/>
10845
+ </xsl:copy>
10846
+ </xsl:template>
10847
+
10848
+ <xsl:template match="processing-instruction()" mode="linear_xml">
10849
+ <xsl:copy-of select="."/>
10850
+ </xsl:template>
10851
+
10852
+ <!-- From:
10853
+ <clause>
10854
+ <title>...</title>
10855
+ <p>...</p>
10856
+ </clause>
10857
+ To:
10858
+ <clause/>
10859
+ <title>...</title>
10860
+ <p>...</p>
10861
+ -->
10862
+ <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">
10863
+
10864
+ <xsl:copy>
10865
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10866
+
10867
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10868
+
10869
+ <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'">
10870
+ <xsl:attribute name="mainsection">true</xsl:attribute>
10871
+ </xsl:if>
10872
+ </xsl:copy>
10873
+
10874
+ <xsl:apply-templates mode="linear_xml"/>
10875
+ </xsl:template>
10876
+
10877
+ <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2">
10878
+ <xsl:copy>
10879
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10880
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10881
+ <xsl:variable name="level">
10882
+ <xsl:call-template name="getLevel"/>
10883
+ </xsl:variable>
10884
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
10885
+ <xsl:attribute name="ancestor">sections</xsl:attribute>
10886
+ <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/>
10887
+ </xsl:copy>
10888
+ <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/>
10889
+ </xsl:template>
10890
+
10891
+ <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">
10892
+ <xsl:copy>
10893
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10894
+
10895
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
10896
+
10897
+ <xsl:variable name="level">
10898
+ <xsl:call-template name="getLevel"/>
10899
+ </xsl:variable>
10900
+ <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute>
10901
+
10902
+ <xsl:if test="parent::*[local-name() = 'annex']">
10903
+ <xsl:attribute name="depth">1</xsl:attribute>
10904
+ </xsl:if>
10905
+
10906
+ <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']">
10907
+ <xsl:copy-of select="../@inline-header"/>
10908
+ </xsl:if>
10909
+
10910
+ <xsl:attribute name="ancestor">
10911
+ <xsl:choose>
10912
+ <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when>
10913
+ <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when>
10914
+ <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when>
10915
+ <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when>
10916
+ <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when>
10917
+ </xsl:choose>
10918
+ </xsl:attribute>
10919
+
10920
+ <xsl:apply-templates mode="linear_xml"/>
10921
+ </xsl:copy>
10922
+ </xsl:template>
10923
+
10924
+ <!-- add @to = figure, table, clause -->
10925
+ <!-- add @depth = from -->
10926
+ <xsl:template match="*[local-name() = 'xref']" mode="linear_xml">
10927
+ <xsl:copy>
10928
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10929
+ <xsl:variable name="target" select="@target"/>
10930
+ <xsl:attribute name="to">
10931
+ <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/>
10932
+ </xsl:attribute>
10933
+ <xsl:attribute name="depth">
10934
+ <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/>
10935
+ </xsl:attribute>
10936
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
10937
+ </xsl:copy>
10938
+ </xsl:template>
10939
+
10940
+ <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml">
10941
+ <xsl:choose>
10942
+ <xsl:when test="contains(., $non_breaking_hyphen)">
10943
+ <xsl:call-template name="replaceChar">
10944
+ <xsl:with-param name="text" select="."/>
10945
+ <xsl:with-param name="replace" select="$non_breaking_hyphen"/>
10946
+ <xsl:with-param name="by" select="'-'"/>
10947
+ </xsl:call-template>
10948
+ </xsl:when>
10949
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
10950
+ </xsl:choose>
10951
+ </xsl:template>
10952
+
10953
+ <xsl:template name="replaceChar">
10954
+ <xsl:param name="text"/>
10955
+ <xsl:param name="replace"/>
10956
+ <xsl:param name="by"/>
10957
+ <xsl:choose>
10958
+ <xsl:when test="$text = '' or $replace = '' or not($replace)">
10959
+ <xsl:value-of select="$text"/>
10960
+ </xsl:when>
10961
+ <xsl:when test="contains($text, $replace)">
10962
+ <xsl:value-of select="substring-before($text,$replace)"/>
10963
+ <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element>
10964
+ <xsl:call-template name="replaceChar">
10965
+ <xsl:with-param name="text" select="substring-after($text,$replace)"/>
10966
+ <xsl:with-param name="replace" select="$replace"/>
10967
+ <xsl:with-param name="by" select="$by"/>
10968
+ </xsl:call-template>
10969
+ </xsl:when>
10970
+ <xsl:otherwise>
10971
+ <xsl:value-of select="$text"/>
10972
+ </xsl:otherwise>
10973
+ </xsl:choose>
10974
+ </xsl:template>
10975
+
10976
+ <xsl:template match="*[local-name() = 'inlineChar']">
10977
+ <fo:inline><xsl:value-of select="."/></fo:inline>
10978
+ </xsl:template>
10979
+
10980
+ <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) -->
10981
+ <!--
10982
+ <fn reference="1">
10983
+ <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
10984
+ </fn>
10985
+ -->
10986
+ <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">
10987
+ <xsl:variable name="p_fn_">
10988
+ <xsl:call-template name="get_fn_list"/>
10989
+ </xsl:variable>
10990
+ <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/>
10991
+ <xsl:variable name="gen_id" select="generate-id(.)"/>
10992
+ <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/>
10993
+ <xsl:variable name="reference" select="@reference"/>
10994
+ <!-- fn sequence number in document -->
10995
+ <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
10996
+
10997
+ <xsl:copy>
10998
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
10999
+ <!-- put actual reference number -->
11000
+ <xsl:attribute name="current_fn_number">
11001
+ <xsl:value-of select="$current_fn_number"/>
11002
+ </xsl:attribute>
11003
+ <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote -->
11004
+ <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/>
11005
+ </xsl:attribute>
11006
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11007
+ </xsl:copy>
11008
+ </xsl:template>
11009
+
11010
+ <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml">
11011
+ <xsl:copy>
11012
+ <xsl:apply-templates select="@*" mode="linear_xml"/>
11013
+ <xsl:if test="@depth = '1'">
11014
+ <xsl:attribute name="mainsection">true</xsl:attribute>
11015
+ </xsl:if>
11016
+ <xsl:apply-templates select="node()" mode="linear_xml"/>
11017
+ </xsl:copy>
11018
+ </xsl:template>
11019
+ <!-- ===================================== -->
11020
+ <!-- ===================================== -->
11021
+ <!-- END: Make linear XML (need for landscape orientation) -->
11022
+ <!-- ===================================== -->
11023
+ <!-- ===================================== -->
11024
+
10594
11025
  <!-- for correct rendering combining chars -->
10595
11026
  <xsl:template match="*[local-name() = 'lang_none']">
10596
11027
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
@@ -11144,6 +11575,23 @@
11144
11575
  </xsl:if>
11145
11576
  </xsl:template>
11146
11577
 
11578
+ <xsl:template name="setBlockAttributes">
11579
+ <xsl:param name="text_align_default">left</xsl:param>
11580
+ <xsl:call-template name="setTextAlignment">
11581
+ <xsl:with-param name="default" select="$text_align_default"/>
11582
+ </xsl:call-template>
11583
+
11584
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
11585
+ <!-- Example: keep-lines-together="true" -->
11586
+ <xsl:if test="@keep-lines-together = 'true'">
11587
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
11588
+ </xsl:if>
11589
+ <!-- Example: keep-with-next="true" -->
11590
+ <xsl:if test="@keep-with-next = 'true'">
11591
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11592
+ </xsl:if>
11593
+ </xsl:template>
11594
+
11147
11595
  <xsl:template name="number-to-words">
11148
11596
  <xsl:param name="number"/>
11149
11597
  <xsl:param name="first"/>