metanorma-bipm 1.1.9 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,6 @@ require_relative "base_convert"
6
6
  module IsoDoc
7
7
  module BIPM
8
8
  class HtmlConvert < IsoDoc::Generic::HtmlConvert
9
-
10
9
  def middle(isoxml, out)
11
10
  super
12
11
  doccontrol isoxml, out
@@ -25,15 +24,16 @@ module IsoDoc
25
24
  def counter_reset(node)
26
25
  s = node["start"]
27
26
  return nil unless s && !s.empty? && !s.to_i.zero?
27
+
28
28
  "counter-reset: #{node['type']} #{s.to_i - 1};"
29
29
  end
30
30
 
31
31
  def ol_attrs(node)
32
32
  klass, style = if node["type"] == "roman" &&
33
- !node.at("./ancestor::xmlns:ol[@type = 'roman']") ||
33
+ !node.at("./ancestor::xmlns:ol[@type = 'roman']") ||
34
34
  node["type"] == "alphabet" &&
35
- !node.at("./ancestor::xmlns:ol[@type = 'alphabet']")
36
- [node["type"], counter_reset(node)]
35
+ !node.at("./ancestor::xmlns:ol[@type = 'alphabet']")
36
+ [node["type"], counter_reset(node)]
37
37
  end
38
38
  super.merge(attr_code(type: ol_style((node["type"] || "arabic").to_sym),
39
39
  start: node["start"]), style: style, class: klass)
@@ -44,4 +44,3 @@ module IsoDoc
44
44
  end
45
45
  end
46
46
  end
47
-
@@ -10,6 +10,8 @@
10
10
  <!-- param for second pass -->
11
11
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
12
12
 
13
+ <xsl:param name="align-cross-elements"/>
14
+
13
15
 
14
16
 
15
17
  <xsl:key name="kfn" match="*[local-name()='p']/*[local-name()='fn']" use="@reference"/>
@@ -17,7 +19,14 @@
17
19
 
18
20
 
19
21
  <xsl:variable name="align_cross_elements_default">clause</xsl:variable>
20
- <xsl:variable name="align_cross_elements_doc" select="normalize-space((//jcgm:bipm-standard)[1]/jcgm:bibdata/jcgm:ext/jcgm:parallel-align-element)"/>
22
+ <xsl:variable name="align_cross_elements_doc">
23
+ <xsl:choose>
24
+ <xsl:when test="normalize-space($align-cross-elements) != ''"><xsl:value-of select="$align-cross-elements"/></xsl:when>
25
+ <xsl:otherwise>
26
+ <xsl:value-of select="normalize-space((//jcgm:bipm-standard)[1]/jcgm:bibdata/jcgm:ext/jcgm:parallel-align-element)"/>
27
+ </xsl:otherwise>
28
+ </xsl:choose>
29
+ </xsl:variable>
21
30
  <xsl:variable name="align_cross_elements_">
22
31
  <xsl:choose>
23
32
  <xsl:when test="$align_cross_elements_doc != ''">
@@ -918,7 +927,7 @@
918
927
  </xsl:variable>
919
928
  <fo:block line-height="1.1" role="H{$level}">
920
929
  <fo:block font-weight="bold" keep-with-next="always">
921
- <xsl:apply-templates select="ancestor::*[local-name()='term']/*[local-name()='name']" mode="presentation"/>
930
+ <xsl:apply-templates select="ancestor::*[local-name()='term'][1]/*[local-name()='name']" mode="presentation"/>
922
931
  </fo:block>
923
932
  <fo:block font-weight="bold" keep-with-next="always">
924
933
  <xsl:apply-templates/>
@@ -2107,6 +2116,8 @@
2107
2116
 
2108
2117
  <title-list-figures lang="en">List of Figures</title-list-figures>
2109
2118
 
2119
+ <title-table-figures lang="en">Table of Figures</title-table-figures>
2120
+
2110
2121
  <title-list-recommendations lang="en">List of Recommendations</title-list-recommendations>
2111
2122
 
2112
2123
  <title-acknowledgements lang="en">Acknowledgements</title-acknowledgements>
@@ -2406,6 +2417,11 @@
2406
2417
 
2407
2418
 
2408
2419
 
2420
+ </xsl:attribute-set><xsl:attribute-set name="table-note-name-style">
2421
+
2422
+
2423
+
2424
+
2409
2425
  </xsl:attribute-set><xsl:attribute-set name="note-p-style">
2410
2426
 
2411
2427
 
@@ -2581,13 +2597,20 @@
2581
2597
 
2582
2598
  </xsl:attribute-set><xsl:attribute-set name="list-style">
2583
2599
 
2584
- </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents">
2600
+ </xsl:attribute-set><xsl:attribute-set name="toc-style">
2601
+ <xsl:attribute name="line-height">135%</xsl:attribute>
2602
+ </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="OLD_processPrefaceSectionsDefault_Contents">
2585
2603
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/>
2586
2604
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/>
2587
2605
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/>
2588
2606
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/>
2589
2607
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']" mode="contents"/>
2590
- </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2608
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault_Contents">
2609
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2610
+ <xsl:sort select="@displayorder" data-type="number"/>
2611
+ <xsl:apply-templates select="." mode="contents"/>
2612
+ </xsl:for-each>
2613
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault_Contents">
2591
2614
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/>
2592
2615
 
2593
2616
  <!-- Normative references -->
@@ -2600,13 +2623,33 @@
2600
2623
  <!-- Bibliography -->
2601
2624
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]" mode="contents"/>
2602
2625
 
2603
- </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2626
+ </xsl:template><xsl:template name="processMainSectionsDefault_Contents">
2627
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2628
+ <xsl:sort select="@displayorder" data-type="number"/>
2629
+ <xsl:apply-templates select="." mode="contents"/>
2630
+ </xsl:for-each>
2631
+
2632
+ <xsl:for-each select="/*/*[local-name()='annex']">
2633
+ <xsl:sort select="@displayorder" data-type="number"/>
2634
+ <xsl:apply-templates select="." mode="contents"/>
2635
+ </xsl:for-each>
2636
+
2637
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2638
+ <xsl:sort select="@displayorder" data-type="number"/>
2639
+ <xsl:apply-templates select="." mode="contents"/>
2640
+ </xsl:for-each>
2641
+ </xsl:template><xsl:template name="OLD_processPrefaceSectionsDefault">
2604
2642
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/>
2605
2643
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/>
2606
2644
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']"/>
2607
2645
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/>
2608
2646
  <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']"/>
2609
- </xsl:template><xsl:template name="processMainSectionsDefault">
2647
+ </xsl:template><xsl:template name="processPrefaceSectionsDefault">
2648
+ <xsl:for-each select="/*/*[local-name()='preface']/*">
2649
+ <xsl:sort select="@displayorder" data-type="number"/>
2650
+ <xsl:apply-templates select="."/>
2651
+ </xsl:for-each>
2652
+ </xsl:template><xsl:template name="OLD_processMainSectionsDefault">
2610
2653
  <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/>
2611
2654
 
2612
2655
  <!-- Normative references -->
@@ -2618,6 +2661,22 @@
2618
2661
  <xsl:apply-templates select="/*/*[local-name()='annex']"/>
2619
2662
  <!-- Bibliography -->
2620
2663
  <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]"/>
2664
+ </xsl:template><xsl:template name="processMainSectionsDefault">
2665
+ <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']">
2666
+ <xsl:sort select="@displayorder" data-type="number"/>
2667
+ <xsl:apply-templates select="."/>
2668
+
2669
+ </xsl:for-each>
2670
+
2671
+ <xsl:for-each select="/*/*[local-name()='annex']">
2672
+ <xsl:sort select="@displayorder" data-type="number"/>
2673
+ <xsl:apply-templates select="."/>
2674
+ </xsl:for-each>
2675
+
2676
+ <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]">
2677
+ <xsl:sort select="@displayorder" data-type="number"/>
2678
+ <xsl:apply-templates select="."/>
2679
+ </xsl:for-each>
2621
2680
  </xsl:template><xsl:template match="text()">
2622
2681
  <xsl:value-of select="."/>
2623
2682
  </xsl:template><xsl:template match="*[local-name()='br']">
@@ -3563,9 +3622,8 @@
3563
3622
 
3564
3623
  <!-- Table's note name (NOTE, for example) -->
3565
3624
 
3566
- <fo:inline padding-right="2mm">
3625
+ <fo:inline padding-right="2mm" xsl:use-attribute-sets="table-note-name-style">
3567
3626
 
3568
-
3569
3627
 
3570
3628
 
3571
3629
 
@@ -4095,6 +4153,7 @@
4095
4153
  <fo:table-cell>
4096
4154
 
4097
4155
  <fo:block margin-top="6pt">
4156
+ <xsl:copy-of select="@id"/>
4098
4157
 
4099
4158
  <xsl:attribute name="margin-top">0pt</xsl:attribute>
4100
4159
 
@@ -4200,6 +4259,8 @@
4200
4259
  <xsl:if test="$font-size != ''">
4201
4260
  <xsl:attribute name="font-size">
4202
4261
  <xsl:choose>
4262
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4263
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4203
4264
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4204
4265
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4205
4266
  </xsl:choose>
@@ -4932,14 +4993,18 @@
4932
4993
  </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'p']">
4933
4994
  <fo:inline><xsl:apply-templates/></fo:inline>
4934
4995
  </xsl:template><xsl:template match="*[local-name() = 'terms']">
4996
+ <!-- <xsl:message>'terms' <xsl:number/> processing...</xsl:message> -->
4935
4997
  <fo:block id="{@id}">
4936
4998
  <xsl:apply-templates/>
4937
4999
  </fo:block>
4938
5000
  </xsl:template><xsl:template match="*[local-name() = 'term']">
5001
+ <!-- <xsl:message>'term' <xsl:number/> processing, name=<xsl:value-of select="iso:name"/>, preferred=<xsl:value-of select="iso:preferred"/>...</xsl:message> -->
4939
5002
  <fo:block id="{@id}" xsl:use-attribute-sets="term-style">
4940
5003
 
4941
5004
 
4942
-
5005
+ <xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'term'])">
5006
+
5007
+ </xsl:if>
4943
5008
  <xsl:apply-templates/>
4944
5009
  </fo:block>
4945
5010
  </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
@@ -5001,6 +5066,7 @@
5001
5066
  <xsl:otherwise>
5002
5067
  <fo:block xsl:use-attribute-sets="image-style">
5003
5068
 
5069
+
5004
5070
  <xsl:variable name="src">
5005
5071
  <xsl:call-template name="image_src"/>
5006
5072
  </xsl:variable>
@@ -5248,6 +5314,13 @@
5248
5314
  </xsl:attribute>
5249
5315
  <xsl:apply-templates mode="svg_update"/>
5250
5316
  </xsl:copy>
5317
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
5318
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5319
+ <xsl:for-each select="*[local-name() = 'svg']">
5320
+ <xsl:call-template name="image_svg">
5321
+ <xsl:with-param name="name" select="$name"/>
5322
+ </xsl:call-template>
5323
+ </xsl:for-each>
5251
5324
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][@mimetype = 'image/svg+xml' and @src[not(starts-with(., 'data:image/'))]]" priority="2">
5252
5325
  <xsl:variable name="svg_content" select="document(@src)"/>
5253
5326
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -5352,7 +5425,7 @@
5352
5425
  </fo:basic-link>
5353
5426
  </fo:block>
5354
5427
  </fo:block-container>
5355
- </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
5428
+ </xsl:template><xsl:template match="*[local-name() = 'emf']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents">
5356
5429
  <xsl:apply-templates mode="contents"/>
5357
5430
  <xsl:text> </xsl:text>
5358
5431
  </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="bookmarks">
@@ -5360,7 +5433,7 @@
5360
5433
  <xsl:text> </xsl:text>
5361
5434
  </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="contents" priority="2">
5362
5435
  <xsl:value-of select="."/>
5363
- </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="bookmarks" priority="2">
5436
+ </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']//text()" mode="bookmarks" priority="2">
5364
5437
  <xsl:value-of select="."/>
5365
5438
  </xsl:template><xsl:template match="node()" mode="contents">
5366
5439
  <xsl:apply-templates mode="contents"/>
@@ -5458,6 +5531,8 @@
5458
5531
 
5459
5532
 
5460
5533
 
5534
+
5535
+
5461
5536
  </fo:bookmark-tree>
5462
5537
  </xsl:if>
5463
5538
  </xsl:template><xsl:template name="insertFigureBookmarks">
@@ -5651,12 +5726,16 @@
5651
5726
  <xsl:if test="$font-size != ''">
5652
5727
  <xsl:attribute name="font-size">
5653
5728
  <xsl:choose>
5729
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
5730
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
5654
5731
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5655
5732
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
5656
5733
  </xsl:choose>
5657
5734
  </xsl:attribute>
5658
5735
  </xsl:if>
5659
5736
 
5737
+
5738
+
5660
5739
  <xsl:apply-templates/>
5661
5740
  </fo:block>
5662
5741
 
@@ -5899,7 +5978,8 @@
5899
5978
  </fo:block>
5900
5979
  </fo:table-cell>
5901
5980
  </xsl:template><xsl:template match="*[local-name() = 'p'][@class='RecommendationTitle' or @class = 'RecommendationTestTitle']" priority="2">
5902
- <fo:block font-size="11pt" color="rgb(237, 193, 35)"> <!-- font-weight="bold" margin-bottom="4pt" text-align="center" -->
5981
+ <fo:block font-size="11pt">
5982
+
5903
5983
  <xsl:apply-templates/>
5904
5984
  </fo:block>
5905
5985
  </xsl:template><xsl:template match="*[local-name() = 'p2'][ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']]">
@@ -6009,6 +6089,7 @@
6009
6089
  </xsl:choose>
6010
6090
  </xsl:template><xsl:template match="*[local-name() = 'termsource']" name="termsource">
6011
6091
  <fo:block xsl:use-attribute-sets="termsource-style">
6092
+
6012
6093
  <!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] -->
6013
6094
  <xsl:variable name="termsource_text">
6014
6095
  <xsl:apply-templates/>
@@ -6019,13 +6100,15 @@
6019
6100
  <!-- <xsl:apply-templates /> -->
6020
6101
  <xsl:copy-of select="$termsource_text"/>
6021
6102
  </xsl:when>
6022
- <xsl:otherwise>
6103
+ <xsl:otherwise>
6104
+
6023
6105
 
6024
6106
  <xsl:text>[</xsl:text>
6025
6107
 
6026
6108
  <!-- <xsl:apply-templates /> -->
6027
6109
  <xsl:copy-of select="$termsource_text"/>
6028
6110
 
6111
+
6029
6112
  <xsl:text>]</xsl:text>
6030
6113
 
6031
6114
  </xsl:otherwise>
@@ -6037,20 +6120,22 @@
6037
6120
  </xsl:if>
6038
6121
  </xsl:template><xsl:variable name="localized.source">
6039
6122
  <xsl:call-template name="getLocalizedString">
6040
- <xsl:with-param name="key">source</xsl:with-param>
6041
- </xsl:call-template>
6123
+ <xsl:with-param name="key">source</xsl:with-param>
6124
+ </xsl:call-template>
6042
6125
  </xsl:variable><xsl:template match="*[local-name() = 'origin']">
6043
6126
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6044
6127
  <xsl:if test="normalize-space(@citeas) = ''">
6045
6128
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6046
6129
  </xsl:if>
6047
6130
 
6131
+
6048
6132
  <fo:inline>
6049
6133
 
6050
6134
 
6051
6135
 
6052
6136
 
6053
6137
 
6138
+
6054
6139
  <xsl:value-of select="$localized.source"/>
6055
6140
  <xsl:text> </xsl:text>
6056
6141
 
@@ -6061,6 +6146,7 @@
6061
6146
  <fo:inline xsl:use-attribute-sets="origin-style">
6062
6147
  <xsl:apply-templates/>
6063
6148
  </fo:inline>
6149
+
6064
6150
  </fo:basic-link>
6065
6151
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
6066
6152
  <fo:inline><xsl:apply-templates/></fo:inline>
@@ -6114,12 +6200,20 @@
6114
6200
  </xsl:template><xsl:template match="*[local-name() = 'author']">
6115
6201
  <xsl:text>— </xsl:text>
6116
6202
  <xsl:apply-templates/>
6117
- </xsl:template><xsl:template match="*[local-name() = 'eref']">
6203
+ </xsl:template><xsl:variable name="bibitem_hidden_">
6204
+ <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden='true']">
6205
+ <xsl:copy-of select="."/>
6206
+ </xsl:for-each>
6207
+ <xsl:for-each select="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem']">
6208
+ <xsl:copy-of select="."/>
6209
+ </xsl:for-each>
6210
+ </xsl:variable><xsl:variable name="bibitem_hidden" select="xalan:nodeset($bibitem_hidden_)"/><xsl:template match="*[local-name() = 'eref']">
6118
6211
 
6119
6212
  <xsl:variable name="bibitemid">
6120
6213
  <xsl:choose>
6121
- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"/>
6122
- <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6214
+ <!-- <xsl:when test="//*[local-name() = 'bibitem'][@hidden='true' and @id = current()/@bibitemid]"></xsl:when>
6215
+ <xsl:when test="//*[local-name() = 'references'][@hidden='true']/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"></xsl:when> -->
6216
+ <xsl:when test="$bibitem_hidden/*[local-name() = 'bibitem'][@id = current()/@bibitemid]"/>
6123
6217
  <xsl:otherwise><xsl:value-of select="@bibitemid"/></xsl:otherwise>
6124
6218
  </xsl:choose>
6125
6219
  </xsl:variable>
@@ -6137,6 +6231,9 @@
6137
6231
 
6138
6232
  </xsl:if>
6139
6233
 
6234
+ <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
6235
+ <xsl:variable name="text" select="normalize-space()"/>
6236
+
6140
6237
 
6141
6238
 
6142
6239
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
@@ -6149,7 +6246,9 @@
6149
6246
 
6150
6247
 
6151
6248
  </xsl:if>
6152
-
6249
+
6250
+
6251
+
6153
6252
  <xsl:apply-templates/>
6154
6253
  </fo:basic-link>
6155
6254
 
@@ -6203,10 +6302,10 @@
6203
6302
  </xsl:choose>
6204
6303
  </xsl:variable>
6205
6304
 
6206
- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
6305
+ <!-- <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/> -->
6207
6306
 
6208
6307
  <xsl:choose>
6209
- <xsl:when test="$language = 'zh'">
6308
+ <xsl:when test="$lang = 'zh'">
6210
6309
  <fo:inline><xsl:value-of select="$tab_zh"/></fo:inline>
6211
6310
  </xsl:when>
6212
6311
  <xsl:when test="../../@inline-header = 'true'">
@@ -6660,9 +6759,97 @@
6660
6759
  <fo:block-container border="1pt solid black" width="50%">
6661
6760
  <fo:block> </fo:block>
6662
6761
  </fo:block-container>
6762
+ </xsl:template><xsl:template match="*[local-name() = 'toc']">
6763
+ <xsl:param name="colwidths"/>
6764
+ <xsl:variable name="colwidths_">
6765
+ <xsl:choose>
6766
+ <xsl:when test="not($colwidths)">
6767
+ <xsl:variable name="toc_table_simple">
6768
+ <tbody>
6769
+ <xsl:apply-templates mode="toc_table_width"/>
6770
+ </tbody>
6771
+ </xsl:variable>
6772
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($toc_table_simple)/*/tr[1]/td)"/>
6773
+ <xsl:call-template name="calculate-column-widths">
6774
+ <xsl:with-param name="cols-count" select="$cols-count"/>
6775
+ <xsl:with-param name="table" select="$toc_table_simple"/>
6776
+ </xsl:call-template>
6777
+ </xsl:when>
6778
+ <xsl:otherwise>
6779
+ <xsl:copy-of select="$colwidths"/>
6780
+ </xsl:otherwise>
6781
+ </xsl:choose>
6782
+ </xsl:variable>
6783
+ <fo:block role="TOCI" space-after="16pt">
6784
+ <fo:table width="100%" table-layout="fixed">
6785
+ <xsl:for-each select="xalan:nodeset($colwidths_)/column">
6786
+ <fo:table-column column-width="proportional-column-width({.})"/>
6787
+ </xsl:for-each>
6788
+ <fo:table-body>
6789
+ <xsl:apply-templates/>
6790
+ </fo:table-body>
6791
+ </fo:table>
6792
+ </fo:block>
6793
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']">
6794
+ <fo:table-row min-height="5mm">
6795
+ <xsl:apply-templates/>
6796
+ </fo:table-row>
6797
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']/*[local-name() = 'p']">
6798
+ <xsl:apply-templates/>
6799
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'xref']" priority="3">
6800
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6801
+ <xsl:variable name="target" select="@target"/>
6802
+ <xsl:for-each select="*[local-name() = 'tab']">
6803
+ <xsl:variable name="current_id" select="generate-id()"/>
6804
+ <fo:table-cell>
6805
+ <fo:block>
6806
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6807
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
6808
+ <xsl:choose>
6809
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
6810
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
6811
+ </xsl:choose>
6812
+ </xsl:for-each>
6813
+ </fo:basic-link>
6814
+ </fo:block>
6815
+ </fo:table-cell>
6816
+ </xsl:for-each>
6817
+ <!-- last column - for page numbers -->
6818
+ <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
6819
+ <fo:block>
6820
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6821
+ <fo:page-number-citation ref-id="{$target}"/>
6822
+ </fo:basic-link>
6823
+ </fo:block>
6824
+ </fo:table-cell>
6825
+ </xsl:template><xsl:template match="*" mode="toc_table_width">
6826
+ <xsl:apply-templates mode="toc_table_width"/>
6827
+ </xsl:template><xsl:template match="*[local-name() = 'clause'][@type = 'toc']/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'clause'][not(@type = 'toc')]/*[local-name() = 'title']" mode="toc_table_width"/><xsl:template match="*[local-name() = 'li']" mode="toc_table_width">
6828
+ <tr>
6829
+ <xsl:apply-templates mode="toc_table_width"/>
6830
+ </tr>
6831
+ </xsl:template><xsl:template match="*[local-name() = 'xref']" mode="toc_table_width">
6832
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6833
+ <xsl:for-each select="*[local-name() = 'tab']">
6834
+ <xsl:variable name="current_id" select="generate-id()"/>
6835
+ <td>
6836
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
6837
+ <xsl:copy-of select="."/>
6838
+ </xsl:for-each>
6839
+ </td>
6840
+ </xsl:for-each>
6841
+ <td>333</td> <!-- page number, just for fill -->
6663
6842
  </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
6664
6843
  <fo:inline padding-right="5mm"> </fo:inline>
6665
6844
  <fo:inline><xsl:apply-templates/></fo:inline>
6845
+ </xsl:template><xsl:template match="*[local-name() = 'blacksquare']" name="blacksquare">
6846
+ <fo:inline padding-right="2.5mm" baseline-shift="5%">
6847
+ <fo:instream-foreign-object content-height="2mm" content-width="2mm" fox:alt-text="Quad">
6848
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 2 2">
6849
+ <rect x="0" y="0" width="2" height="2" fill="black"/>
6850
+ </svg>
6851
+ </fo:instream-foreign-object>
6852
+ </fo:inline>
6666
6853
  </xsl:template><xsl:template name="convertDate">
6667
6854
  <xsl:param name="date"/>
6668
6855
  <xsl:param name="format" select="'short'"/>
@@ -18,16 +18,13 @@ module IsoDoc
18
18
  end
19
19
 
20
20
  def eref_localities1(target, type, from, to, delim, n, lang = "en")
21
- if @jcgm
22
- @iso.eref_localities1(target, type, from, to, delim, n, lang)
23
- else
24
- super
25
- end
21
+ @jcgm and
22
+ return @iso.eref_localities1(target, type, from, to, delim, n, lang)
23
+ super
26
24
  end
27
25
 
28
26
  def table1(elem)
29
- return if labelled_ancestor(elem)
30
- return if elem["unnumbered"]
27
+ return if labelled_ancestor(elem) || elem["unnumbered"]
31
28
 
32
29
  n = @xrefs.anchor(elem["id"], :label, false)
33
30
  prefix_name(elem, ".<tab/>",
@@ -47,28 +44,42 @@ module IsoDoc
47
44
  return if elem["unnumbered"] == "true"
48
45
 
49
46
  lbl = @xrefs.anchor(elem["id"], :label)
50
- if t = elem.at(ns("./title"))
47
+ t = elem.at(ns("./title")) and
51
48
  t.children = "<strong>#{t.children.to_xml}</strong>"
52
- end
53
49
  prefix_name(elem, ".<tab/>", lbl, "title")
54
50
  end
55
51
 
56
52
  def clause(docxml)
53
+ quotedtitles(docxml)
57
54
  super
58
- if @jcgm
55
+ @jcgm and
59
56
  docxml.xpath(ns("//preface/introduction[clause]")).each do |f|
60
57
  clause1(f)
61
58
  end
62
- end
63
59
  end
64
60
 
65
61
  def clause1(elem)
66
- return if elem["unnumbered"] == "true"
67
- return if elem.at(("./ancestor::*[@unnumbered = 'true']"))
62
+ elem.at(("./ancestor::*[@unnumbered = 'true']")) and
63
+ elem["unnumbered"] = "true"
68
64
 
69
65
  super
70
66
  end
71
67
 
68
+ def prefix_name(node, delim, number, elem)
69
+ return if number.nil? || number.empty?
70
+
71
+ unless name = node.at(ns("./#{elem}[not(@type = 'quoted')]"))
72
+ return if node.at(ns("./#{elem}[@type = 'quoted']"))
73
+
74
+ node.children.empty? and node.add_child("<#{elem}></#{elem}>") or
75
+ node.children.first.previous = "<#{elem}></#{elem}>"
76
+ name = node.children.first
77
+ end
78
+ if name.children.empty? then name.add_child(number)
79
+ else (name.children.first.previous = "#{number}#{delim}")
80
+ end
81
+ end
82
+
72
83
  def conversions(docxml)
73
84
  super
74
85
  doccontrol docxml
@@ -168,8 +179,7 @@ module IsoDoc
168
179
  end
169
180
 
170
181
  def twitter_cldr_localiser_symbols
171
- { group: "&#xA0;", fraction_group: "&#xA0;",
172
- fraction_group_digits: 3 }
182
+ { group: "&#xA0;", fraction_group: "&#xA0;", fraction_group_digits: 3 }
173
183
  end
174
184
 
175
185
  def mathml1(elem, locale)
@@ -210,9 +220,7 @@ module IsoDoc
210
220
  def jcgm_eref(docxml, xpath)
211
221
  return unless @jcgm
212
222
 
213
- docxml.xpath(ns(xpath)).each do |x|
214
- extract_brackets(x)
215
- end
223
+ docxml.xpath(ns(xpath)).each { |x| extract_brackets(x) }
216
224
  # merge adjacent text nodes
217
225
  docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
218
226
  docxml.xpath(ns(xpath)).each do |x| # rubocop: disable Style/CombinableLoops
@@ -235,6 +243,13 @@ module IsoDoc
235
243
  end
236
244
  end
237
245
 
246
+ def quotedtitles(docxml)
247
+ docxml.xpath(ns("//variant-title[@type = 'quoted']")).each do |t|
248
+ t.name = "title"
249
+ t.children.first.previous = "<blacksquare/>"
250
+ end
251
+ end
252
+
238
253
  include Init
239
254
  end
240
255
  end
@@ -61,16 +61,16 @@ module IsoDoc
61
61
  end
62
62
 
63
63
  NUMBERED_SUBCLAUSES = "./clause[not(@unnumbered = 'true')] | "\
64
- "./references[not(@unnumbered = 'true')] | "\
65
- "./term[not(@unnumbered = 'true')] | "\
66
- "./terms[not(@unnumbered = 'true')] | "\
67
- "./definitions[not(@unnumbered = 'true')]".freeze
64
+ "./references[not(@unnumbered = 'true')] | "\
65
+ "./term[not(@unnumbered = 'true')] | "\
66
+ "./terms[not(@unnumbered = 'true')] | "\
67
+ "./definitions[not(@unnumbered = 'true')]".freeze
68
68
 
69
69
  UNNUMBERED_SUBCLAUSES = "./clause[@unnumbered = 'true'] | "\
70
- "./references[@unnumbered = 'true'] | "\
71
- "./term[@unnumbered = 'true'] | "\
72
- "./terms[@unnumbered = 'true'] | "\
73
- "./definitions[@unnumbered = 'true']".freeze
70
+ "./references[@unnumbered = 'true'] | "\
71
+ "./term[@unnumbered = 'true'] | "\
72
+ "./terms[@unnumbered = 'true'] | "\
73
+ "./definitions[@unnumbered = 'true']".freeze
74
74
 
75
75
  def section_name_anchors(clause, num, lvl)
76
76
  lbl = @jcgm ? "clause_jcgm" : "clause"
@@ -157,9 +157,10 @@ module IsoDoc
157
157
  annex_names1(a, num.to_s, 1)
158
158
  else
159
159
  i = Counter.new
160
+ prefix = @jcgm ? "" : "A"
160
161
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
161
162
  i.increment(c)
162
- annex_names1(c, "#{num}.#{i.print}", 2)
163
+ annex_names1(c, "#{prefix}#{num}.#{i.print}", 2)
163
164
  end
164
165
  clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
165
166
  .each { |c| unnumbered_annex_names1(c, 2) }
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "1.1.9".freeze
3
+ VERSION = "1.2.1".freeze
4
4
  end
5
5
  end