metanorma-bipm 1.1.8 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -239,10 +239,17 @@ ul li p {
239
239
  display: inline;
240
240
  }
241
241
 
242
- ul li:first-child {
242
+ ul > li:first-child {
243
243
  margin-top: 1em;
244
244
  }
245
245
 
246
+ ul ul > li:first-child {
247
+ margin-top: 0;
248
+ }
249
+ ol ul > li:first-child {
250
+ margin-top: 0;
251
+ }
252
+
246
253
  #toc-list ul {
247
254
  margin-bottom: 0.25em;
248
255
  }
@@ -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 != ''">
@@ -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
 
@@ -4200,6 +4258,8 @@
4200
4258
  <xsl:if test="$font-size != ''">
4201
4259
  <xsl:attribute name="font-size">
4202
4260
  <xsl:choose>
4261
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
4262
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
4203
4263
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
4204
4264
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
4205
4265
  </xsl:choose>
@@ -5001,6 +5061,7 @@
5001
5061
  <xsl:otherwise>
5002
5062
  <fo:block xsl:use-attribute-sets="image-style">
5003
5063
 
5064
+
5004
5065
  <xsl:variable name="src">
5005
5066
  <xsl:call-template name="image_src"/>
5006
5067
  </xsl:variable>
@@ -5248,6 +5309,13 @@
5248
5309
  </xsl:attribute>
5249
5310
  <xsl:apply-templates mode="svg_update"/>
5250
5311
  </xsl:copy>
5312
+ </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
5313
+ <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
5314
+ <xsl:for-each select="*[local-name() = 'svg']">
5315
+ <xsl:call-template name="image_svg">
5316
+ <xsl:with-param name="name" select="$name"/>
5317
+ </xsl:call-template>
5318
+ </xsl:for-each>
5251
5319
  </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
5320
  <xsl:variable name="svg_content" select="document(@src)"/>
5253
5321
  <xsl:variable name="name" select="ancestor::*[local-name() = 'figure']/*[local-name() = 'name']"/>
@@ -5352,7 +5420,7 @@
5352
5420
  </fo:basic-link>
5353
5421
  </fo:block>
5354
5422
  </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">
5423
+ </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
5424
  <xsl:apply-templates mode="contents"/>
5357
5425
  <xsl:text> </xsl:text>
5358
5426
  </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 +5428,7 @@
5360
5428
  <xsl:text> </xsl:text>
5361
5429
  </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
5430
  <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">
5431
+ </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
5432
  <xsl:value-of select="."/>
5365
5433
  </xsl:template><xsl:template match="node()" mode="contents">
5366
5434
  <xsl:apply-templates mode="contents"/>
@@ -5458,6 +5526,8 @@
5458
5526
 
5459
5527
 
5460
5528
 
5529
+
5530
+
5461
5531
  </fo:bookmark-tree>
5462
5532
  </xsl:if>
5463
5533
  </xsl:template><xsl:template name="insertFigureBookmarks">
@@ -5651,12 +5721,16 @@
5651
5721
  <xsl:if test="$font-size != ''">
5652
5722
  <xsl:attribute name="font-size">
5653
5723
  <xsl:choose>
5724
+ <xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
5725
+ <xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
5654
5726
  <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
5655
5727
  <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
5656
5728
  </xsl:choose>
5657
5729
  </xsl:attribute>
5658
5730
  </xsl:if>
5659
5731
 
5732
+
5733
+
5660
5734
  <xsl:apply-templates/>
5661
5735
  </fo:block>
5662
5736
 
@@ -6009,6 +6083,7 @@
6009
6083
  </xsl:choose>
6010
6084
  </xsl:template><xsl:template match="*[local-name() = 'termsource']" name="termsource">
6011
6085
  <fo:block xsl:use-attribute-sets="termsource-style">
6086
+
6012
6087
  <!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] -->
6013
6088
  <xsl:variable name="termsource_text">
6014
6089
  <xsl:apply-templates/>
@@ -6037,20 +6112,22 @@
6037
6112
  </xsl:if>
6038
6113
  </xsl:template><xsl:variable name="localized.source">
6039
6114
  <xsl:call-template name="getLocalizedString">
6040
- <xsl:with-param name="key">source</xsl:with-param>
6041
- </xsl:call-template>
6115
+ <xsl:with-param name="key">source</xsl:with-param>
6116
+ </xsl:call-template>
6042
6117
  </xsl:variable><xsl:template match="*[local-name() = 'origin']">
6043
6118
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
6044
6119
  <xsl:if test="normalize-space(@citeas) = ''">
6045
6120
  <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
6046
6121
  </xsl:if>
6047
6122
 
6123
+
6048
6124
  <fo:inline>
6049
6125
 
6050
6126
 
6051
6127
 
6052
6128
 
6053
6129
 
6130
+
6054
6131
  <xsl:value-of select="$localized.source"/>
6055
6132
  <xsl:text> </xsl:text>
6056
6133
 
@@ -6061,6 +6138,7 @@
6061
6138
  <fo:inline xsl:use-attribute-sets="origin-style">
6062
6139
  <xsl:apply-templates/>
6063
6140
  </fo:inline>
6141
+
6064
6142
  </fo:basic-link>
6065
6143
  </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
6066
6144
  <fo:inline><xsl:apply-templates/></fo:inline>
@@ -6137,6 +6215,9 @@
6137
6215
 
6138
6216
  </xsl:if>
6139
6217
 
6218
+ <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
6219
+ <xsl:variable name="text" select="normalize-space()"/>
6220
+
6140
6221
 
6141
6222
 
6142
6223
  <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
@@ -6149,7 +6230,9 @@
6149
6230
 
6150
6231
 
6151
6232
  </xsl:if>
6152
-
6233
+
6234
+
6235
+
6153
6236
  <xsl:apply-templates/>
6154
6237
  </fo:basic-link>
6155
6238
 
@@ -6491,6 +6574,7 @@
6491
6574
  </xsl:template><xsl:template match="*[local-name() = 'indexsect']//*[local-name() = 'li']" priority="4">
6492
6575
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
6493
6576
  <fo:block start-indent="{5 * $level}mm" text-indent="-5mm">
6577
+
6494
6578
  <xsl:apply-templates/>
6495
6579
  </fo:block>
6496
6580
  </xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
@@ -6659,9 +6743,97 @@
6659
6743
  <fo:block-container border="1pt solid black" width="50%">
6660
6744
  <fo:block> </fo:block>
6661
6745
  </fo:block-container>
6746
+ </xsl:template><xsl:template match="*[local-name() = 'toc']">
6747
+ <xsl:param name="colwidths"/>
6748
+ <xsl:variable name="colwidths_">
6749
+ <xsl:choose>
6750
+ <xsl:when test="not($colwidths)">
6751
+ <xsl:variable name="toc_table_simple">
6752
+ <tbody>
6753
+ <xsl:apply-templates mode="toc_table_width"/>
6754
+ </tbody>
6755
+ </xsl:variable>
6756
+ <xsl:variable name="cols-count" select="count(xalan:nodeset($toc_table_simple)/*/tr[1]/td)"/>
6757
+ <xsl:call-template name="calculate-column-widths">
6758
+ <xsl:with-param name="cols-count" select="$cols-count"/>
6759
+ <xsl:with-param name="table" select="$toc_table_simple"/>
6760
+ </xsl:call-template>
6761
+ </xsl:when>
6762
+ <xsl:otherwise>
6763
+ <xsl:copy-of select="$colwidths"/>
6764
+ </xsl:otherwise>
6765
+ </xsl:choose>
6766
+ </xsl:variable>
6767
+ <fo:block role="TOCI" space-after="16pt">
6768
+ <fo:table width="100%" table-layout="fixed">
6769
+ <xsl:for-each select="xalan:nodeset($colwidths_)/column">
6770
+ <fo:table-column column-width="proportional-column-width({.})"/>
6771
+ </xsl:for-each>
6772
+ <fo:table-body>
6773
+ <xsl:apply-templates/>
6774
+ </fo:table-body>
6775
+ </fo:table>
6776
+ </fo:block>
6777
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']">
6778
+ <fo:table-row min-height="5mm">
6779
+ <xsl:apply-templates/>
6780
+ </fo:table-row>
6781
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'li']/*[local-name() = 'p']">
6782
+ <xsl:apply-templates/>
6783
+ </xsl:template><xsl:template match="*[local-name() = 'toc']//*[local-name() = 'xref']" priority="3">
6784
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6785
+ <xsl:variable name="target" select="@target"/>
6786
+ <xsl:for-each select="*[local-name() = 'tab']">
6787
+ <xsl:variable name="current_id" select="generate-id()"/>
6788
+ <fo:table-cell>
6789
+ <fo:block>
6790
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6791
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
6792
+ <xsl:choose>
6793
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
6794
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
6795
+ </xsl:choose>
6796
+ </xsl:for-each>
6797
+ </fo:basic-link>
6798
+ </fo:block>
6799
+ </fo:table-cell>
6800
+ </xsl:for-each>
6801
+ <!-- last column - for page numbers -->
6802
+ <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
6803
+ <fo:block>
6804
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
6805
+ <fo:page-number-citation ref-id="{$target}"/>
6806
+ </fo:basic-link>
6807
+ </fo:block>
6808
+ </fo:table-cell>
6809
+ </xsl:template><xsl:template match="*" mode="toc_table_width">
6810
+ <xsl:apply-templates mode="toc_table_width"/>
6811
+ </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">
6812
+ <tr>
6813
+ <xsl:apply-templates mode="toc_table_width"/>
6814
+ </tr>
6815
+ </xsl:template><xsl:template match="*[local-name() = 'xref']" mode="toc_table_width">
6816
+ <!-- <xref target="cgpm9th1948r6">1.6.3<tab/>&#8220;9th CGPM, 1948:<tab/>decision to establish the SI&#8221;</xref> -->
6817
+ <xsl:for-each select="*[local-name() = 'tab']">
6818
+ <xsl:variable name="current_id" select="generate-id()"/>
6819
+ <td>
6820
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
6821
+ <xsl:copy-of select="."/>
6822
+ </xsl:for-each>
6823
+ </td>
6824
+ </xsl:for-each>
6825
+ <td>333</td> <!-- page number, just for fill -->
6662
6826
  </xsl:template><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']"/><xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
6663
6827
  <fo:inline padding-right="5mm"> </fo:inline>
6664
6828
  <fo:inline><xsl:apply-templates/></fo:inline>
6829
+ </xsl:template><xsl:template match="*[local-name() = 'blacksquare']" name="blacksquare">
6830
+ <fo:inline padding-right="2.5mm" baseline-shift="5%">
6831
+ <fo:instream-foreign-object content-height="2mm" content-width="2mm" fox:alt-text="Quad">
6832
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 2 2">
6833
+ <rect x="0" y="0" width="2" height="2" fill="black"/>
6834
+ </svg>
6835
+ </fo:instream-foreign-object>
6836
+ </fo:inline>
6665
6837
  </xsl:template><xsl:template name="convertDate">
6666
6838
  <xsl:param name="date"/>
6667
6839
  <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,27 +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"
64
+
68
65
  super
69
66
  end
70
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
+
71
83
  def conversions(docxml)
72
84
  super
73
85
  doccontrol docxml
@@ -111,7 +123,7 @@ module IsoDoc
111
123
  i = 3
112
124
  while list_draft(xml, i) != ["", ""]
113
125
  ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join} "\
114
- "<td/></tr>"
126
+ "<td/></tr>"
115
127
  i += 1
116
128
  end
117
129
  ret
@@ -135,7 +147,7 @@ module IsoDoc
135
147
 
136
148
  COCHAIR = "xmlns:role[contains(text(),'co-chair')]".freeze
137
149
  CHAIR = "[xmlns:role[contains(text(),'chair')]"\
138
- "[not(contains(text(),'co-chair'))]]".freeze
150
+ "[not(contains(text(),'co-chair'))]]".freeze
139
151
 
140
152
  def list_cochairs(xml)
141
153
  ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
@@ -167,11 +179,11 @@ module IsoDoc
167
179
  end
168
180
 
169
181
  def twitter_cldr_localiser_symbols
170
- { group: "&#xA0;", fraction_group: "&#xA0;",
171
- fraction_group_digits: 3 }
182
+ { group: "&#xA0;", fraction_group: "&#xA0;", fraction_group_digits: 3 }
172
183
  end
173
184
 
174
185
  def mathml1(elem, locale)
186
+ asciimath_dup(elem)
175
187
  localize_maths(elem, locale)
176
188
  end
177
189
 
@@ -208,9 +220,7 @@ module IsoDoc
208
220
  def jcgm_eref(docxml, xpath)
209
221
  return unless @jcgm
210
222
 
211
- docxml.xpath(ns(xpath)).each do |x|
212
- extract_brackets(x)
213
- end
223
+ docxml.xpath(ns(xpath)).each { |x| extract_brackets(x) }
214
224
  # merge adjacent text nodes
215
225
  docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
216
226
  docxml.xpath(ns(xpath)).each do |x| # rubocop: disable Style/CombinableLoops
@@ -233,6 +243,13 @@ module IsoDoc
233
243
  end
234
244
  end
235
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
+
236
253
  include Init
237
254
  end
238
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.8".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  end
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
- spec.add_dependency "metanorma-generic", "~> 1.10.2"
30
- spec.add_dependency "metanorma-iso", "~> 1.9.0"
29
+ spec.add_dependency "metanorma-generic", "~> 1.11.0"
30
+ spec.add_dependency "metanorma-iso", "~> 1.10.0"
31
31
 
32
32
  spec.add_development_dependency "byebug", "~> 9.1"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"