metanorma-bipm 2.2.5 → 2.2.6

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 -->
@@ -3047,7 +3047,7 @@
3047
3047
  <xsl:apply-templates select="." mode="contents"/>
3048
3048
  </xsl:for-each>
3049
3049
 
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')]]">
3050
+ <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
3051
  <xsl:sort select="@displayorder" data-type="number"/>
3052
3052
  <xsl:apply-templates select="." mode="contents"/>
3053
3053
  </xsl:for-each>
@@ -3990,6 +3990,10 @@
3990
3990
  </xsl:choose>
3991
3991
  </xsl:variable>
3992
3992
 
3993
+ <xsl:variable name="table_fn_block">
3994
+ <xsl:call-template name="table_fn_display"/>
3995
+ </xsl:variable>
3996
+
3993
3997
  <xsl:variable name="tableWithNotesAndFootnotes">
3994
3998
 
3995
3999
  <fo:table keep-with-previous="always">
@@ -4037,11 +4041,25 @@
4037
4041
 
4038
4042
  <xsl:apply-templates select="../*[local-name()='note']"/>
4039
4043
 
4044
+ <xsl:variable name="isDisplayRowSeparator">
4045
+
4046
+ </xsl:variable>
4047
+
4040
4048
  <!-- horizontal row separator -->
4049
+ <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4050
+ <xsl:if test="../*[local-name()='note'] and normalize-space($table_fn_block) != ''">
4051
+ <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4052
+
4053
+ <xsl:call-template name="setBordersTableArray"/>
4054
+ <fo:block font-size="1pt"> </fo:block>
4055
+ </fo:block-container>
4056
+ </xsl:if>
4057
+ </xsl:if>
4041
4058
 
4042
4059
  <!-- fn processing -->
4043
4060
 
4044
- <xsl:call-template name="table_fn_display"/>
4061
+ <!-- <xsl:call-template name="table_fn_display" /> -->
4062
+ <xsl:copy-of select="$table_fn_block"/>
4045
4063
 
4046
4064
  <!-- for PAS display Notes after footnotes -->
4047
4065
 
@@ -4210,6 +4228,28 @@
4210
4228
  </fo:table-row>
4211
4229
  </xsl:template>
4212
4230
 
4231
+ <xsl:template name="setBorderUnderRow">
4232
+ <xsl:variable name="border_under_row_" select="normalize-space(ancestor::*[local-name() = 'table'][1]/@border-under-row)"/>
4233
+ <xsl:choose>
4234
+ <xsl:when test="$border_under_row_ != ''">
4235
+ <xsl:variable name="table_id" select="ancestor::*[local-name() = 'table'][1]/@id"/>
4236
+ <xsl:variable name="row_num_"><xsl:number level="any" count="*[local-name() = 'table'][@id = $table_id]//*[local-name() = 'tr']"/></xsl:variable>
4237
+ <xsl:variable name="row_num" select="number($row_num_) - 1"/> <!-- because values in border-under-row start with 0 -->
4238
+ <xsl:variable name="border_under_row">
4239
+ <xsl:call-template name="split">
4240
+ <xsl:with-param name="pText" select="$border_under_row_"/>
4241
+ </xsl:call-template>
4242
+ </xsl:variable>
4243
+ <xsl:if test="xalan:nodeset($border_under_row)/item[. = normalize-space($row_num)]">
4244
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4245
+ </xsl:if>
4246
+ </xsl:when>
4247
+ <xsl:otherwise>
4248
+ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute>
4249
+ </xsl:otherwise>
4250
+ </xsl:choose>
4251
+ </xsl:template>
4252
+
4213
4253
  <!-- row in table footer (tfoot) -->
4214
4254
  <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
4215
4255
  <fo:table-row xsl:use-attribute-sets="table-footer-row-style">
@@ -4545,8 +4585,16 @@
4545
4585
  <!-- figure's footnotes rendering -->
4546
4586
  <xsl:template name="fn_display_figure">
4547
4587
 
4588
+ <!-- current figure id -->
4589
+ <xsl:variable name="figure_id_">
4590
+ <xsl:value-of select="@id"/>
4591
+ <xsl:if test="not(@id)"><xsl:value-of select="generate-id()"/></xsl:if>
4592
+ </xsl:variable>
4593
+ <xsl:variable name="figure_id" select="normalize-space($figure_id_)"/>
4594
+
4595
+ <!-- all footnotes relates to the current figure -->
4548
4596
  <xsl:variable name="references">
4549
- <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
4597
+ <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])][ancestor::*[local-name() = 'figure'][1][@id = $figure_id]]">
4550
4598
  <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
4551
4599
  <xsl:apply-templates/>
4552
4600
  </fn>
@@ -4559,91 +4607,93 @@
4559
4607
  true
4560
4608
  </xsl:variable>
4561
4609
 
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>
4610
+ <fo:block>
4611
+
4612
+ <!-- current hierarchy is 'figure' element -->
4613
+ <xsl:variable name="following_dl_colwidths">
4614
+ <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
4615
+ <xsl:variable name="simple-table">
4616
+ <!-- <xsl:variable name="doc_ns">
4617
+ <xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
4618
+ </xsl:variable>
4619
+ <xsl:variable name="ns">
4620
+ <xsl:choose>
4621
+ <xsl:when test="normalize-space($doc_ns) != ''">
4622
+ <xsl:value-of select="normalize-space($doc_ns)"/>
4623
+ </xsl:when>
4624
+ <xsl:otherwise>
4625
+ <xsl:value-of select="substring-before(name(/*), '-')"/>
4626
+ </xsl:otherwise>
4627
+ </xsl:choose>
4628
+ </xsl:variable> -->
4629
+
4630
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
4631
+ <tbody>
4632
+ <xsl:apply-templates mode="dl"/>
4633
+ </tbody>
4634
+ </xsl:for-each>
4635
+ </xsl:variable>
4636
+
4637
+ <xsl:call-template name="calculate-column-widths">
4638
+ <xsl:with-param name="cols-count" select="2"/>
4639
+ <xsl:with-param name="table" select="$simple-table"/>
4640
+ </xsl:call-template>
4641
+
4642
+ </xsl:if>
4568
4643
  </xsl:variable>
4569
- <xsl:variable name="ns">
4644
+
4645
+ <xsl:variable name="maxlength_dt">
4646
+ <xsl:for-each select="*[local-name() = 'dl'][1]">
4647
+ <xsl:call-template name="getMaxLength_dt"/>
4648
+ </xsl:for-each>
4649
+ </xsl:variable>
4650
+
4651
+ <fo:table width="95%" table-layout="fixed">
4652
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4653
+ <xsl:attribute name="font-size">10pt</xsl:attribute>
4654
+
4655
+ </xsl:if>
4570
4656
  <xsl:choose>
4571
- <xsl:when test="normalize-space($doc_ns) != ''">
4572
- <xsl:value-of select="normalize-space($doc_ns)"/>
4657
+ <!-- if there 'dl', then set same columns width -->
4658
+ <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
4659
+ <xsl:call-template name="setColumnWidth_dl">
4660
+ <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>
4661
+ <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
4662
+ </xsl:call-template>
4573
4663
  </xsl:when>
4574
4664
  <xsl:otherwise>
4575
- <xsl:value-of select="substring-before(name(/*), '-')"/>
4665
+ <fo:table-column column-width="5%"/>
4666
+ <fo:table-column column-width="95%"/>
4576
4667
  </xsl:otherwise>
4577
4668
  </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>
4669
+ <fo:table-body>
4670
+ <xsl:for-each select="xalan:nodeset($references)//fn">
4671
+ <xsl:variable name="reference" select="@reference"/>
4672
+ <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
4673
+ <fo:table-row>
4674
+ <fo:table-cell>
4675
+ <fo:block>
4676
+ <fo:inline id="{@id}" xsl:use-attribute-sets="figure-fn-number-style">
4677
+ <xsl:value-of select="@reference"/>
4678
+ </fo:inline>
4679
+ </fo:block>
4680
+ </fo:table-cell>
4681
+ <fo:table-cell>
4682
+ <fo:block xsl:use-attribute-sets="figure-fn-body-style">
4683
+ <xsl:if test="normalize-space($key_iso) = 'true'">
4600
4684
 
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>
4685
+ <xsl:attribute name="margin-bottom">0</xsl:attribute>
4605
4686
 
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>
4687
+ </xsl:if>
4688
+ <xsl:copy-of select="./node()"/>
4689
+ </fo:block>
4690
+ </fo:table-cell>
4691
+ </fo:table-row>
4692
+ </xsl:if>
4693
+ </xsl:for-each>
4694
+ </fo:table-body>
4695
+ </fo:table>
4637
4696
 
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
4697
  </fo:block>
4648
4698
  </xsl:if>
4649
4699
 
@@ -4728,12 +4778,14 @@
4728
4778
 
4729
4779
  <xsl:attribute name="margin-bottom">0</xsl:attribute>
4730
4780
 
4731
- <xsl:variable name="title-where">
4781
+ <!-- <xsl:variable name="title-where">
4732
4782
  <xsl:call-template name="getLocalizedString">
4733
4783
  <xsl:with-param name="key">where</xsl:with-param>
4734
4784
  </xsl:call-template>
4735
4785
  </xsl:variable>
4736
- <xsl:value-of select="$title-where"/><xsl:text> </xsl:text>
4786
+ <xsl:value-of select="$title-where"/> -->
4787
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
4788
+ <xsl:text> </xsl:text>
4737
4789
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
4738
4790
  <xsl:text/>
4739
4791
  <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
@@ -4745,12 +4797,14 @@
4745
4797
 
4746
4798
  <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
4747
4799
 
4748
- <xsl:variable name="title-where">
4800
+ <!-- <xsl:variable name="title-where">
4749
4801
  <xsl:call-template name="getLocalizedString">
4750
4802
  <xsl:with-param name="key">where</xsl:with-param>
4751
4803
  </xsl:call-template>
4752
4804
  </xsl:variable>
4753
- <xsl:value-of select="$title-where"/>
4805
+ <xsl:value-of select="$title-where"/><xsl:if test="$namespace = 'bsi' or $namespace = 'itu'">:</xsl:if> -->
4806
+ <!-- preceding 'p' with word 'where' -->
4807
+ <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
4754
4808
  </fo:block>
4755
4809
  </xsl:when> <!-- END: a few components -->
4756
4810
  <xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
@@ -4941,6 +4995,9 @@
4941
4995
 
4942
4996
  </xsl:template> <!-- END: dl -->
4943
4997
 
4998
+ <!-- ignore 'p' with 'where' in formula, before 'dl' -->
4999
+ <xsl:template match="*[local-name() = 'formula']/*[local-name() = 'p' and @keep-with-next = 'true' and following-sibling::*[1][local-name() = 'dl']]"/>
5000
+
4944
5001
  <xsl:template match="*[local-name() = 'dl']/*[local-name() = 'name']">
4945
5002
  <xsl:param name="process">false</xsl:param>
4946
5003
  <xsl:if test="$process = 'true'">
@@ -5768,20 +5825,34 @@
5768
5825
 
5769
5826
  <xsl:template name="add-zero-spaces-java">
5770
5827
  <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​')"/>
5828
+
5829
+ <!-- add zero-width space (#x200B) after dot with next non-digit -->
5830
+ <xsl:variable name="text1" select="java:replaceAll(java:java.lang.String.new($text),'(\.)([^\d\s])','$1​$2')"/>
5831
+ <!-- add zero-width space (#x200B) after characters: dash, equal, underscore, em dash, thin space, arrow right, ; -->
5832
+ <xsl:variable name="text2" select="java:replaceAll(java:java.lang.String.new($text1),'(-|=|_|—| |→|;)','$1​')"/>
5773
5833
  <!-- 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')"/>
5834
+ <xsl:variable name="text3" select="java:replaceAll(java:java.lang.String.new($text2),'(:)(\D)','$1​$2')"/>
5775
5835
  <!-- 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' -->
5836
+ <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
5837
  <!-- 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' -->
5838
+ <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
5839
  <!-- 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' -->
5840
+ <xsl:variable name="text6" select="java:replaceAll(java:java.lang.String.new($text5), '(?&lt;!\W)(\{)', '​$1')"/> <!-- negative lookbehind: '{' not preceeded by 'punctuation char' -->
5781
5841
  <!-- 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 -->
5842
+ <xsl:variable name="text7" select="java:replaceAll(java:java.lang.String.new($text6), '(\,)(?!\d)', '$1​')"/> <!-- negative lookahead: ',' not followed by digit -->
5843
+ <!-- add zero-width space (#x200B) after character: '/' -->
5844
+ <xsl:variable name="text8" select="java:replaceAll(java:java.lang.String.new($text7), '(\u002f)(?!\u002f)', '$1​')"/><!-- negative lookahead: '/' not followed by '/' -->
5783
5845
 
5784
- <xsl:value-of select="$text6"/>
5846
+ <xsl:variable name="text9">
5847
+ <xsl:choose>
5848
+ <xsl:when test="$isGenerateTableIF = 'true'">
5849
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text8), '([\u3000-\u9FFF])', '$1​')"/> <!-- 3000 - CJK Symbols and Punctuation ... 9FFF CJK Unified Ideographs-->
5850
+ </xsl:when>
5851
+ <xsl:otherwise><xsl:value-of select="$text8"/></xsl:otherwise>
5852
+ </xsl:choose>
5853
+ </xsl:variable>
5854
+
5855
+ <xsl:value-of select="$text9"/>
5785
5856
  </xsl:template>
5786
5857
 
5787
5858
  <xsl:template name="add-zero-spaces-link-java">
@@ -5789,8 +5860,8 @@
5789
5860
 
5790
5861
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text), $regex_url_start, '$1')"/> <!-- http://. https:// or www. -->
5791
5862
  <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​')"/>
5863
+ <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space, comma, slash, @ -->
5864
+ <xsl:variable name="url" select="java:replaceAll(java:java.lang.String.new($url_continue),'(-|\.|:|=|_|—| |,|/|@)','$1​')"/>
5794
5865
  <!-- remove zero-width space at the end -->
5795
5866
  <xsl:value-of select="java:replaceAll(java:java.lang.String.new($url), '​$', '')"/>
5796
5867
  </xsl:template>
@@ -6145,9 +6216,28 @@
6145
6216
  </xsl:variable>
6146
6217
  <xsl:copy-of select="$newRow"/>
6147
6218
 
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>
6219
+ <!-- optimize to prevent StackOverflowError, just copy next 'tr' -->
6220
+ <xsl:variable name="currrow_num" select="count(preceding-sibling::tr) + 1"/>
6221
+ <xsl:variable name="nextrow_without_rowspan_" select="count(following-sibling::tr[*[@rowspan and @rowspan != 1]][1]/preceding-sibling::tr) + 1"/>
6222
+ <xsl:variable name="nextrow_without_rowspan" select="$nextrow_without_rowspan_ - $currrow_num"/>
6223
+ <xsl:choose>
6224
+ <xsl:when test="not(xalan:nodeset($newRow)/*/*[@rowspan and @rowspan != 1]) and $nextrow_without_rowspan &lt;= 0">
6225
+ <xsl:copy-of select="following-sibling::tr"/>
6226
+ </xsl:when>
6227
+ <!-- <xsl:when test="xalan:nodeset($newRow)/*[not(@rowspan) or (@rowspan = 1)] and $nextrow_without_rowspan &gt; 0">
6228
+ <xsl:copy-of select="following-sibling::tr[position() &lt;= $nextrow_without_rowspan]"/>
6229
+
6230
+ <xsl:copy-of select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6231
+ <xsl:apply-templates select="following-sibling::tr[$nextrow_without_rowspan + 2]" mode="simple-table-rowspan">
6232
+ <xsl:with-param name="previousRow" select="following-sibling::tr[$nextrow_without_rowspan + 1]"/>
6233
+ </xsl:apply-templates>
6234
+ </xsl:when> -->
6235
+ <xsl:otherwise>
6236
+ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
6237
+ <xsl:with-param name="previousRow" select="$newRow"/>
6238
+ </xsl:apply-templates>
6239
+ </xsl:otherwise>
6240
+ </xsl:choose>
6151
6241
  </xsl:template>
6152
6242
  <!-- End mode simple-table-rowspan -->
6153
6243
 
@@ -6310,6 +6400,27 @@
6310
6400
  </xsl:call-template>
6311
6401
  </xsl:template>
6312
6402
 
6403
+ <xsl:template match="*[local-name() = 'link'][normalize-space() = '']" mode="td_text_with_formatting">
6404
+ <xsl:variable name="link">
6405
+ <link_updated>
6406
+ <xsl:variable name="target_text">
6407
+ <xsl:choose>
6408
+ <xsl:when test="starts-with(normalize-space(@target), 'mailto:')">
6409
+ <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/>
6410
+ </xsl:when>
6411
+ <xsl:otherwise>
6412
+ <xsl:value-of select="normalize-space(@target)"/>
6413
+ </xsl:otherwise>
6414
+ </xsl:choose>
6415
+ </xsl:variable>
6416
+ <xsl:value-of select="$target_text"/>
6417
+ </link_updated>
6418
+ </xsl:variable>
6419
+ <xsl:for-each select="xalan:nodeset($link)/*">
6420
+ <xsl:apply-templates mode="td_text_with_formatting"/>
6421
+ </xsl:for-each>
6422
+ </xsl:template>
6423
+
6313
6424
  <xsl:template name="getFormattingTags">
6314
6425
  <tags>
6315
6426
  <xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
@@ -6658,7 +6769,7 @@
6658
6769
  </xsl:variable>
6659
6770
  <fo:inline xsl:use-attribute-sets="link-style">
6660
6771
 
6661
- <xsl:if test="starts-with(normalize-space(@target), 'mailto:')">
6772
+ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])">
6662
6773
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
6663
6774
  </xsl:if>
6664
6775
 
@@ -7015,10 +7126,10 @@
7015
7126
  <fo:block xsl:use-attribute-sets="figure-style">
7016
7127
  <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note' and @type = 'units')]"/>
7017
7128
  </fo:block>
7018
- <xsl:call-template name="fn_display_figure"/>
7019
7129
  <xsl:for-each select="*[local-name() = 'note'][not(@type = 'units')]">
7020
7130
  <xsl:call-template name="note"/>
7021
7131
  </xsl:for-each>
7132
+ <xsl:call-template name="fn_display_figure"/>
7022
7133
 
7023
7134
  <xsl:apply-templates select="*[local-name() = 'name']"/> <!-- show figure's name AFTER image -->
7024
7135
 
@@ -7081,7 +7192,13 @@
7081
7192
  </xsl:choose>
7082
7193
  </xsl:variable>
7083
7194
 
7084
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $width_effective, $height_effective)"/>
7195
+ <xsl:variable name="image_width_effective">
7196
+
7197
+ <xsl:value-of select="$width_effective"/>
7198
+
7199
+ </xsl:variable>
7200
+
7201
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7085
7202
  <xsl:if test="number($scale) &lt; 100">
7086
7203
 
7087
7204
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
@@ -7668,6 +7785,13 @@
7668
7785
  <xsl:when test="$contents_nodes/doc">
7669
7786
  <xsl:choose>
7670
7787
  <xsl:when test="count($contents_nodes/doc) &gt; 1">
7788
+
7789
+ <xsl:if test="$contents_nodes/collection">
7790
+ <fo:bookmark internal-destination="{$contents/collection/@firstpage_id}">
7791
+ <fo:bookmark-title>collection.pdf</fo:bookmark-title>
7792
+ </fo:bookmark>
7793
+ </xsl:if>
7794
+
7671
7795
  <xsl:for-each select="$contents_nodes/doc">
7672
7796
  <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
7673
7797
  <xsl:if test="@bundle = 'true'">
@@ -9560,6 +9684,44 @@
9560
9684
 
9561
9685
  <fo:list-block xsl:use-attribute-sets="list-style">
9562
9686
 
9687
+ <xsl:variable name="provisional_distance_between_starts_">
9688
+ <attributes xsl:use-attribute-sets="list-style">
9689
+
9690
+ </attributes>
9691
+ </xsl:variable>
9692
+ <xsl:variable name="provisional_distance_between_starts" select="normalize-space(xalan:nodeset($provisional_distance_between_starts_)/attributes/@provisional-distance-between-starts)"/>
9693
+ <xsl:if test="$provisional_distance_between_starts != ''">
9694
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts"/></xsl:attribute>
9695
+ </xsl:if>
9696
+ <xsl:variable name="provisional_distance_between_starts_value" select="substring-before($provisional_distance_between_starts, 'mm')"/>
9697
+
9698
+ <!-- increase provisional-distance-between-starts for long lists -->
9699
+ <xsl:if test="local-name() = 'ol'">
9700
+ <!-- Examples: xiii), xviii), xxviii) -->
9701
+ <xsl:variable name="item_numbers">
9702
+ <xsl:for-each select="*[local-name() = 'li']">
9703
+ <item><xsl:call-template name="getListItemFormat"/></item>
9704
+ </xsl:for-each>
9705
+ </xsl:variable>
9706
+
9707
+ <xsl:variable name="max_length">
9708
+ <xsl:for-each select="xalan:nodeset($item_numbers)/item">
9709
+ <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
9710
+ <xsl:if test="position() = 1"><xsl:value-of select="string-length(.)"/></xsl:if>
9711
+ </xsl:for-each>
9712
+ </xsl:variable>
9713
+
9714
+ <!-- base width (provisional-distance-between-starts) for 4 chars -->
9715
+ <xsl:variable name="addon" select="$max_length - 4"/>
9716
+ <xsl:if test="$addon &gt; 0">
9717
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$provisional_distance_between_starts_value + $addon * 2"/>mm</xsl:attribute>
9718
+ </xsl:if>
9719
+ <!-- DEBUG -->
9720
+ <!-- <xsl:copy-of select="$item_numbers"/>
9721
+ <max_length><xsl:value-of select="$max_length"/></max_length>
9722
+ <addon><xsl:value-of select="$addon"/></addon> -->
9723
+ </xsl:if>
9724
+
9563
9725
  <xsl:if test="*[local-name() = 'name']">
9564
9726
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
9565
9727
  </xsl:if>
@@ -10522,7 +10684,7 @@
10522
10684
  <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) -->
10523
10685
  <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> -->
10524
10686
  <!-- add &lt; and &gt; to \S -->
10525
- <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;]</xsl:variable>
10687
+ <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable>
10526
10688
  <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
10689
  <xsl:variable name="text3">
10528
10690
  <text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
@@ -10544,7 +10706,8 @@
10544
10706
  <xsl:choose>
10545
10707
  <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
10546
10708
  <!-- 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>
10709
+ <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable>
10710
+ <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
10711
  <xsl:for-each select="xalan:nodeset($text3)/text/node()">
10549
10712
  <xsl:choose>
10550
10713
  <xsl:when test="self::text()">
@@ -11144,6 +11307,23 @@
11144
11307
  </xsl:if>
11145
11308
  </xsl:template>
11146
11309
 
11310
+ <xsl:template name="setBlockAttributes">
11311
+ <xsl:param name="text_align_default">left</xsl:param>
11312
+ <xsl:call-template name="setTextAlignment">
11313
+ <xsl:with-param name="default" select="$text_align_default"/>
11314
+ </xsl:call-template>
11315
+
11316
+ <!-- https://www.metanorma.org/author/topics/document-format/text/#avoiding-page-breaks -->
11317
+ <!-- Example: keep-lines-together="true" -->
11318
+ <xsl:if test="@keep-lines-together = 'true'">
11319
+ <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
11320
+ </xsl:if>
11321
+ <!-- Example: keep-with-next="true" -->
11322
+ <xsl:if test="@keep-with-next = 'true'">
11323
+ <xsl:attribute name="keep-with-next">always</xsl:attribute>
11324
+ </xsl:if>
11325
+ </xsl:template>
11326
+
11147
11327
  <xsl:template name="number-to-words">
11148
11328
  <xsl:param name="number"/>
11149
11329
  <xsl:param name="first"/>