metanorma-bipm 2.4.2 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/bipm/bipm.brochure.xsl +135 -20
- data/lib/isodoc/bipm/bipm.guide.xsl +135 -20
- data/lib/isodoc/bipm/bipm.mise-en-pratique.xsl +135 -20
- data/lib/isodoc/bipm/bipm.rapport.xsl +135 -20
- data/lib/isodoc/bipm/html/html_bipm_titlepage.html +15 -1
- data/lib/isodoc/bipm/html/htmlstyle.css +6 -0
- data/lib/isodoc/bipm/html/htmlstyle.scss +1 -0
- data/lib/isodoc/bipm/i18n-en.yaml +2 -0
- data/lib/isodoc/bipm/i18n-fr.yaml +2 -0
- data/lib/isodoc/bipm/init.rb +5 -0
- data/lib/isodoc/bipm/jcgm.standard.xsl +131 -16
- data/lib/isodoc/bipm/metadata.rb +27 -15
- data/lib/isodoc/bipm/presentation_xml_convert.rb +14 -16
- data/lib/metanorma/bipm/biblio.rng +28 -25
- data/lib/metanorma/bipm/cleanup.rb +89 -0
- data/lib/metanorma/bipm/converter.rb +4 -42
- data/lib/metanorma/bipm/relaton-bipm.rng +1 -0
- data/lib/metanorma/bipm/version.rb +1 -1
- data/lib/relaton/render/general.rb +1 -0
- data/metanorma-bipm.gemspec +2 -2
- data/metanorma.yml +1 -0
- metadata +7 -6
@@ -1737,6 +1737,8 @@
|
|
1737
1737
|
<xsl:param name="svg_images"/> <!-- svg images array -->
|
1738
1738
|
<xsl:variable name="images" select="document($svg_images)"/>
|
1739
1739
|
<xsl:param name="basepath"/> <!-- base path for images -->
|
1740
|
+
<xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
|
1741
|
+
<xsl:param name="inputxml_filename"/> <!-- input xml file name -->
|
1740
1742
|
<xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
|
1741
1743
|
<xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
|
1742
1744
|
<xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
|
@@ -1789,6 +1791,20 @@
|
|
1789
1791
|
<xsl:call-template name="getLang"/>
|
1790
1792
|
</xsl:variable>
|
1791
1793
|
|
1794
|
+
<xsl:variable name="inputxml_filename_prefix">
|
1795
|
+
<xsl:choose>
|
1796
|
+
<xsl:when test="contains($inputxml_filename, '.presentation.xml')">
|
1797
|
+
<xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
|
1798
|
+
</xsl:when>
|
1799
|
+
<xsl:when test="contains($inputxml_filename, '.xml')">
|
1800
|
+
<xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
|
1801
|
+
</xsl:when>
|
1802
|
+
<xsl:otherwise>
|
1803
|
+
<xsl:value-of select="$inputxml_filename"/>
|
1804
|
+
</xsl:otherwise>
|
1805
|
+
</xsl:choose>
|
1806
|
+
</xsl:variable>
|
1807
|
+
|
1792
1808
|
<!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
|
1793
1809
|
You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
|
1794
1810
|
BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
|
@@ -2739,6 +2755,10 @@
|
|
2739
2755
|
|
2740
2756
|
</xsl:attribute-set>
|
2741
2757
|
|
2758
|
+
<xsl:template name="refine_figure-block-style">
|
2759
|
+
|
2760
|
+
</xsl:template>
|
2761
|
+
|
2742
2762
|
<xsl:attribute-set name="figure-style">
|
2743
2763
|
|
2744
2764
|
</xsl:attribute-set>
|
@@ -3654,7 +3674,7 @@
|
|
3654
3674
|
<xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
|
3655
3675
|
|
3656
3676
|
<xsl:variable name="colwidths">
|
3657
|
-
<xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
|
3677
|
+
<xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
|
3658
3678
|
<xsl:call-template name="calculate-column-widths">
|
3659
3679
|
<xsl:with-param name="cols-count" select="$cols-count"/>
|
3660
3680
|
<xsl:with-param name="table" select="$simple-table"/>
|
@@ -3766,6 +3786,11 @@
|
|
3766
3786
|
<fo:table-column column-width="{@width}"/>
|
3767
3787
|
</xsl:for-each>
|
3768
3788
|
</xsl:when>
|
3789
|
+
<xsl:when test="@class = 'dl'">
|
3790
|
+
<xsl:for-each select=".//*[local-name()='tr'][1]/*">
|
3791
|
+
<fo:table-column column-width="{@width}"/>
|
3792
|
+
</xsl:for-each>
|
3793
|
+
</xsl:when>
|
3769
3794
|
<xsl:otherwise>
|
3770
3795
|
<xsl:call-template name="insertTableColumnWidth">
|
3771
3796
|
<xsl:with-param name="colwidths" select="$colwidths"/>
|
@@ -5097,6 +5122,7 @@
|
|
5097
5122
|
<!-- ===================== -->
|
5098
5123
|
<!-- Definition List -->
|
5099
5124
|
<!-- ===================== -->
|
5125
|
+
|
5100
5126
|
<xsl:template match="*[local-name()='dl']">
|
5101
5127
|
<xsl:variable name="isAdded" select="@added"/>
|
5102
5128
|
<xsl:variable name="isDeleted" select="@deleted"/>
|
@@ -5313,10 +5339,21 @@
|
|
5313
5339
|
</xsl:variable>
|
5314
5340
|
|
5315
5341
|
<xsl:variable name="colwidths">
|
5316
|
-
<xsl:
|
5317
|
-
|
5318
|
-
<xsl:
|
5319
|
-
|
5342
|
+
<xsl:choose>
|
5343
|
+
<!-- dl from table[@class='dl'] -->
|
5344
|
+
<xsl:when test="*[local-name() = 'colgroup']">
|
5345
|
+
<autolayout/>
|
5346
|
+
<xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
|
5347
|
+
<column><xsl:value-of select="translate(@width,'%m','')"/></column>
|
5348
|
+
</xsl:for-each>
|
5349
|
+
</xsl:when>
|
5350
|
+
<xsl:otherwise>
|
5351
|
+
<xsl:call-template name="calculate-column-widths">
|
5352
|
+
<xsl:with-param name="cols-count" select="2"/>
|
5353
|
+
<xsl:with-param name="table" select="$simple-table"/>
|
5354
|
+
</xsl:call-template>
|
5355
|
+
</xsl:otherwise>
|
5356
|
+
</xsl:choose>
|
5320
5357
|
</xsl:variable>
|
5321
5358
|
|
5322
5359
|
<!-- <xsl:text disable-output-escaping="yes"><!- -</xsl:text>
|
@@ -6055,7 +6092,8 @@
|
|
6055
6092
|
</xsl:template>
|
6056
6093
|
|
6057
6094
|
<xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
|
6058
|
-
<xsl:variable name="text" select="normalize-space(.)"/>
|
6095
|
+
<!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
|
6096
|
+
<xsl:variable name="text" select="."/>
|
6059
6097
|
<fo:inline font-size="75%" role="SKIP">
|
6060
6098
|
<xsl:if test="string-length($text) > 0">
|
6061
6099
|
<xsl:variable name="smallCapsText">
|
@@ -7430,6 +7468,12 @@
|
|
7430
7468
|
<xsl:when test="@updatetype = 'true'">
|
7431
7469
|
<xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
|
7432
7470
|
</xsl:when>
|
7471
|
+
<xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
|
7472
|
+
<!-- link to the PDF attachment -->
|
7473
|
+
<xsl:variable name="target_" select="translate(@target, '\', '/')"/>
|
7474
|
+
<xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
|
7475
|
+
<xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
|
7476
|
+
</xsl:when>
|
7433
7477
|
<xsl:otherwise>
|
7434
7478
|
<xsl:value-of select="normalize-space(@target)"/>
|
7435
7479
|
</xsl:otherwise>
|
@@ -7837,6 +7881,7 @@
|
|
7837
7881
|
<xsl:variable name="isAdded" select="@added"/>
|
7838
7882
|
<xsl:variable name="isDeleted" select="@deleted"/>
|
7839
7883
|
<fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
|
7884
|
+
<xsl:call-template name="refine_figure-block-style"/>
|
7840
7885
|
|
7841
7886
|
<xsl:call-template name="setTrackChangesStyles">
|
7842
7887
|
<xsl:with-param name="isAdded" select="$isAdded"/>
|
@@ -8192,16 +8237,44 @@
|
|
8192
8237
|
</xsl:choose>
|
8193
8238
|
|
8194
8239
|
<xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
|
8195
|
-
<xsl:variable name="
|
8196
|
-
<xsl:variable name="
|
8240
|
+
<xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
|
8241
|
+
<xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
|
8242
|
+
<xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
|
8243
|
+
<xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
|
8244
|
+
|
8245
|
+
<!-- Example: -->
|
8197
8246
|
<!-- effective height 297 - 27.4 - 13 = 256.6 -->
|
8198
8247
|
<!-- effective width 210 - 12.5 - 25 = 172.5 -->
|
8199
8248
|
<!-- effective height / width = 1.48, 1.4 - with title -->
|
8200
|
-
|
8249
|
+
|
8250
|
+
<xsl:variable name="scale_x">
|
8251
|
+
<xsl:choose>
|
8252
|
+
<xsl:when test="$svg_width > $width_effective_px">
|
8253
|
+
<xsl:value-of select="$width_effective_px div $svg_width"/>
|
8254
|
+
</xsl:when>
|
8255
|
+
<xsl:otherwise>1</xsl:otherwise>
|
8256
|
+
</xsl:choose>
|
8257
|
+
</xsl:variable>
|
8258
|
+
<xsl:variable name="scale_y">
|
8259
|
+
<xsl:choose>
|
8260
|
+
<xsl:when test="$svg_height * $scale_x > $height_effective_px">
|
8261
|
+
<xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
|
8262
|
+
</xsl:when>
|
8263
|
+
<xsl:otherwise>1</xsl:otherwise>
|
8264
|
+
</xsl:choose>
|
8265
|
+
</xsl:variable>
|
8266
|
+
|
8267
|
+
<!-- for images with big height -->
|
8268
|
+
<!-- <xsl:if test="$svg_height > ($svg_width * 1.4)">
|
8201
8269
|
<xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
|
8202
8270
|
<xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
|
8203
|
-
</xsl:if>
|
8271
|
+
</xsl:if> -->
|
8204
8272
|
<xsl:attribute name="scaling">uniform</xsl:attribute>
|
8273
|
+
|
8274
|
+
<xsl:if test="$scale_y != 1">
|
8275
|
+
<xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
|
8276
|
+
</xsl:if>
|
8277
|
+
|
8205
8278
|
<xsl:copy-of select="$svg_content"/>
|
8206
8279
|
</fo:instream-foreign-object>
|
8207
8280
|
<!-- </fo:block> -->
|
@@ -8239,8 +8312,12 @@
|
|
8239
8312
|
<xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
|
8240
8313
|
<xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
|
8241
8314
|
|
8315
|
+
<xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
|
8316
|
+
<xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
|
8317
|
+
|
8242
8318
|
<xsl:attribute name="width">
|
8243
8319
|
<xsl:choose>
|
8320
|
+
<xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
|
8244
8321
|
<xsl:when test="$width != ''">
|
8245
8322
|
<xsl:value-of select="round($width)"/>
|
8246
8323
|
</xsl:when>
|
@@ -8249,6 +8326,7 @@
|
|
8249
8326
|
</xsl:attribute>
|
8250
8327
|
<xsl:attribute name="height">
|
8251
8328
|
<xsl:choose>
|
8329
|
+
<xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
|
8252
8330
|
<xsl:when test="$height != ''">
|
8253
8331
|
<xsl:value-of select="round($height)"/>
|
8254
8332
|
</xsl:when>
|
@@ -8260,6 +8338,28 @@
|
|
8260
8338
|
</xsl:copy>
|
8261
8339
|
</xsl:template>
|
8262
8340
|
|
8341
|
+
<xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
|
8342
|
+
<!-- image[@width]/svg -->
|
8343
|
+
<xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
|
8344
|
+
<xsl:attribute name="width">
|
8345
|
+
<xsl:choose>
|
8346
|
+
<xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
|
8347
|
+
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
|
8348
|
+
</xsl:choose>
|
8349
|
+
</xsl:attribute>
|
8350
|
+
</xsl:template>
|
8351
|
+
|
8352
|
+
<xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
|
8353
|
+
<!-- image[@height]/svg -->
|
8354
|
+
<xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
|
8355
|
+
<xsl:attribute name="height">
|
8356
|
+
<xsl:choose>
|
8357
|
+
<xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
|
8358
|
+
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
|
8359
|
+
</xsl:choose>
|
8360
|
+
</xsl:attribute>
|
8361
|
+
</xsl:template>
|
8362
|
+
|
8263
8363
|
<!-- regex for 'display: inline-block;' -->
|
8264
8364
|
<xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
|
8265
8365
|
<xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
|
@@ -10336,7 +10436,9 @@
|
|
10336
10436
|
</xsl:template> <!-- sections_element_style -->
|
10337
10437
|
|
10338
10438
|
<xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
|
10339
|
-
|
10439
|
+
|
10440
|
+
<fo:block break-after="page"/>
|
10441
|
+
|
10340
10442
|
<fo:block>
|
10341
10443
|
<xsl:call-template name="setId"/>
|
10342
10444
|
<xsl:apply-templates/>
|
@@ -10407,7 +10509,7 @@
|
|
10407
10509
|
<xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
|
10408
10510
|
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
|
10409
10511
|
</xsl:when>
|
10410
|
-
<xsl:when test="not(
|
10512
|
+
<xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
|
10411
10513
|
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
|
10412
10514
|
</xsl:when>
|
10413
10515
|
</xsl:choose>
|
@@ -12215,10 +12317,10 @@
|
|
12215
12317
|
|
12216
12318
|
<xsl:template name="addPDFUAmeta">
|
12217
12319
|
<pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
|
12218
|
-
|
12219
|
-
|
12220
|
-
|
12221
|
-
|
12320
|
+
<pdf:dictionary type="normal" key="ViewerPreferences">
|
12321
|
+
<pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
|
12322
|
+
</pdf:dictionary>
|
12323
|
+
</pdf:catalog>
|
12222
12324
|
<x:xmpmeta xmlns:x="adobe:ns:meta/">
|
12223
12325
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
12224
12326
|
<rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
|
@@ -12267,6 +12369,19 @@
|
|
12267
12369
|
</rdf:Description>
|
12268
12370
|
</rdf:RDF>
|
12269
12371
|
</x:xmpmeta>
|
12372
|
+
<!-- add attachments -->
|
12373
|
+
<xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
|
12374
|
+
<xsl:choose>
|
12375
|
+
<xsl:when test="normalize-space() != ''">
|
12376
|
+
<pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
|
12377
|
+
</xsl:when>
|
12378
|
+
<xsl:otherwise>
|
12379
|
+
<!-- _{filename}_attachments -->
|
12380
|
+
<xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
|
12381
|
+
<pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
|
12382
|
+
</xsl:otherwise>
|
12383
|
+
</xsl:choose>
|
12384
|
+
</xsl:for-each>
|
12270
12385
|
</xsl:template> <!-- addPDFUAmeta -->
|
12271
12386
|
|
12272
12387
|
<xsl:template name="getId">
|
data/lib/isodoc/bipm/metadata.rb
CHANGED
@@ -39,9 +39,8 @@ module IsoDoc
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def status_print(status)
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
status == "procès-verbal" and return "Procès-Verbal"
|
43
|
+
status == "cipm-mra" and return "CIPM-MRA"
|
45
44
|
status.split(/[- ]/).map.with_index do |s, i|
|
46
45
|
%w(en de).include?(s) && i.positive? ? s : s.capitalize
|
47
46
|
end.join(" ")
|
@@ -49,23 +48,22 @@ module IsoDoc
|
|
49
48
|
|
50
49
|
def docid(isoxml, _out)
|
51
50
|
super
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
dn and set(:appendixid_alt, @i18n.l10n("#{label2} #{dn.text}"))
|
56
|
-
label1, label2 = @lang == "fr" ? %w(Appendice Annex) : %w(Annex Appendice)
|
57
|
-
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/annexid"))
|
58
|
-
dn and set(:annexid, @i18n.l10n("#{label1} #{dn.text}"))
|
59
|
-
dn and set(:annexid_alt, @i18n.l10n("#{label2} #{dn.text}"))
|
60
|
-
label1, label2 = @lang == "fr" ? %w(Partie Part) : %w(Part Partie)
|
61
|
-
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
|
62
|
-
dn and set(:partid, @i18n.l10n("#{label1} #{dn.text}"))
|
63
|
-
dn and set(:partid_alt, @i18n.l10n("#{label2} #{dn.text}"))
|
51
|
+
docid_part(isoxml, %w(Appendix Annexe), "appendix", :appendixid)
|
52
|
+
docid_part(isoxml, %w(Annex Appendice), "annexid", :annexid)
|
53
|
+
docid_part(isoxml, %w(Part Partie), "part", :partid)
|
64
54
|
set(:org_abbrev,
|
65
55
|
isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
|
66
56
|
"[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
|
67
57
|
end
|
68
58
|
|
59
|
+
def docid_part(isoxml, labels, elem, key)
|
60
|
+
@lang == "fr" and labels.reverse!
|
61
|
+
label1, label2 = labels
|
62
|
+
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/#{elem}"))
|
63
|
+
dn and set(key, @i18n.l10n("#{label1} #{dn.text}"))
|
64
|
+
dn and set("#{key}_alt".to_sym, @i18n.l10n("#{label2} #{dn.text}"))
|
65
|
+
end
|
66
|
+
|
69
67
|
def extract_person_names_affiliations(authors)
|
70
68
|
extract_person_affiliations(authors)
|
71
69
|
end
|
@@ -75,6 +73,20 @@ module IsoDoc
|
|
75
73
|
.at(ns("//bibdata/date[not(@format)][@type = 'published']"))
|
76
74
|
pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
|
77
75
|
end
|
76
|
+
|
77
|
+
def author(xml, _out)
|
78
|
+
super
|
79
|
+
authorizer(xml)
|
80
|
+
end
|
81
|
+
|
82
|
+
def authorizer(xml)
|
83
|
+
ret = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = " \
|
84
|
+
"'authorizer']/organization"))
|
85
|
+
.each_with_object([]) do |org, m|
|
86
|
+
m << extract_variant(org.at(ns("./name")))
|
87
|
+
end
|
88
|
+
ret.empty? or set(:authorizer, ret)
|
89
|
+
end
|
78
90
|
end
|
79
91
|
end
|
80
92
|
end
|
@@ -75,13 +75,16 @@ module IsoDoc
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def twitter_cldr_localiser_symbols
|
78
|
-
{ group: " ", fraction_group: " ",
|
78
|
+
{ group: " ", fraction_group: " ",
|
79
|
+
fraction_group_digits: 3 }
|
79
80
|
end
|
80
81
|
|
81
82
|
def localized_number(num, locale, precision)
|
82
|
-
g = Regexp.quote(
|
83
|
-
f = Regexp.quote(
|
84
|
-
|
83
|
+
g = Regexp.quote(@twitter_cldr_reader[:group])
|
84
|
+
f = Regexp.quote(@twitter_cldr_reader[:fraction_group])
|
85
|
+
d = Regexp.quote(@twitter_cldr_reader[:decimal])
|
86
|
+
super.sub(/^(\d)#{g}(\d) (?= \d\d$ | \d\d#{d} )/x, "\\1\\2")
|
87
|
+
.sub(/(?<= ^\d\d | #{d}\d\d ) (\d)#{f}(\d) $/x, "\\1\\2")
|
85
88
|
end
|
86
89
|
|
87
90
|
def mathml1(elem, locale)
|
@@ -97,8 +100,7 @@ module IsoDoc
|
|
97
100
|
|
98
101
|
def bibdata_dates(bibdata)
|
99
102
|
pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
|
100
|
-
|
101
|
-
|
103
|
+
pubdate or return
|
102
104
|
meta = metadata_init(@lang, @script, @locale, @i18n)
|
103
105
|
pubdate.next = pubdate.dup
|
104
106
|
pubdate.next["format"] = "ddMMMyyyy"
|
@@ -193,23 +195,23 @@ module IsoDoc
|
|
193
195
|
end
|
194
196
|
|
195
197
|
def termsource_modification(elem)
|
196
|
-
if elem["status"] == "modified"
|
197
|
-
|
198
|
-
|
199
|
-
end
|
198
|
+
# if elem["status"] == "modified"
|
199
|
+
# origin = elem.at(ns("./origin"))
|
200
|
+
# s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
|
201
|
+
# end
|
200
202
|
termsource_add_modification_text(elem.at(ns("./modification")))
|
201
203
|
end
|
202
204
|
|
203
205
|
def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn,
|
204
206
|
_bib)
|
205
|
-
ret =
|
207
|
+
ret = identifiers[0] || identifiers[1]
|
206
208
|
ret += " #{identifiers[1]}" if identifiers[0] && identifiers[1]
|
207
209
|
"#{ret}#{datefn} "
|
208
210
|
end
|
209
211
|
|
210
212
|
def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
|
211
213
|
# standard and id = nil
|
212
|
-
ret =
|
214
|
+
ret = ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]"
|
213
215
|
if ids[:sdo]
|
214
216
|
ret = prefix_bracketed_ref(ret)
|
215
217
|
ret += "#{ids[:sdo]}#{datefn} "
|
@@ -219,10 +221,6 @@ _bib)
|
|
219
221
|
ret
|
220
222
|
end
|
221
223
|
|
222
|
-
def bibrenderer
|
223
|
-
::Relaton::Render::BIPM::General.new(language: @lang)
|
224
|
-
end
|
225
|
-
|
226
224
|
include Init
|
227
225
|
end
|
228
226
|
end
|
@@ -338,29 +338,32 @@
|
|
338
338
|
</define>
|
339
339
|
<define name="organization">
|
340
340
|
<element name="organization">
|
341
|
-
<
|
342
|
-
<ref name="orgname"/>
|
343
|
-
</oneOrMore>
|
344
|
-
<zeroOrMore>
|
345
|
-
<ref name="subdivision"/>
|
346
|
-
</zeroOrMore>
|
347
|
-
<optional>
|
348
|
-
<ref name="abbreviation"/>
|
349
|
-
</optional>
|
350
|
-
<zeroOrMore>
|
351
|
-
<ref name="uri"/>
|
352
|
-
</zeroOrMore>
|
353
|
-
<zeroOrMore>
|
354
|
-
<ref name="org-identifier"/>
|
355
|
-
</zeroOrMore>
|
356
|
-
<zeroOrMore>
|
357
|
-
<ref name="contact"/>
|
358
|
-
</zeroOrMore>
|
359
|
-
<optional>
|
360
|
-
<ref name="logo"/>
|
361
|
-
</optional>
|
341
|
+
<ref name="OrganizationType"/>
|
362
342
|
</element>
|
363
343
|
</define>
|
344
|
+
<define name="OrganizationType">
|
345
|
+
<oneOrMore>
|
346
|
+
<ref name="orgname"/>
|
347
|
+
</oneOrMore>
|
348
|
+
<zeroOrMore>
|
349
|
+
<ref name="subdivision"/>
|
350
|
+
</zeroOrMore>
|
351
|
+
<optional>
|
352
|
+
<ref name="abbreviation"/>
|
353
|
+
</optional>
|
354
|
+
<zeroOrMore>
|
355
|
+
<ref name="uri"/>
|
356
|
+
</zeroOrMore>
|
357
|
+
<zeroOrMore>
|
358
|
+
<ref name="org-identifier"/>
|
359
|
+
</zeroOrMore>
|
360
|
+
<zeroOrMore>
|
361
|
+
<ref name="contact"/>
|
362
|
+
</zeroOrMore>
|
363
|
+
<optional>
|
364
|
+
<ref name="logo"/>
|
365
|
+
</optional>
|
366
|
+
</define>
|
364
367
|
<define name="orgname">
|
365
368
|
<element name="name">
|
366
369
|
<choice>
|
@@ -371,10 +374,10 @@
|
|
371
374
|
</define>
|
372
375
|
<define name="subdivision">
|
373
376
|
<element name="subdivision">
|
374
|
-
<
|
375
|
-
<
|
376
|
-
|
377
|
-
|
377
|
+
<optional>
|
378
|
+
<attribute name="type"/>
|
379
|
+
</optional>
|
380
|
+
<ref name="OrganizationType"/>
|
378
381
|
</element>
|
379
382
|
</define>
|
380
383
|
<define name="logo">
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module BIPM
|
3
|
+
class Converter < Metanorma::Generic::Converter
|
4
|
+
def boilerplate_file(_xmldoc)
|
5
|
+
if @jcgm
|
6
|
+
File.join(File.dirname(__FILE__), "boilerplate-jcgm-en.adoc")
|
7
|
+
else
|
8
|
+
File.join(File.dirname(__FILE__), "boilerplate-#{@lang}.adoc")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def sections_cleanup(xml)
|
13
|
+
super
|
14
|
+
jcgm_untitled_sections_cleanup(xml) if @jcgm
|
15
|
+
end
|
16
|
+
|
17
|
+
def jcgm_untitled_sections_cleanup(xml)
|
18
|
+
xml.xpath("//clause//clause | //annex//clause | //introduction/clause")
|
19
|
+
.each do |c|
|
20
|
+
next if !c&.at("./title")&.text&.empty?
|
21
|
+
|
22
|
+
c["inline-header"] = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def section_names_terms_cleanup(xml); end
|
27
|
+
|
28
|
+
def section_names_refs_cleanup(xml); end
|
29
|
+
|
30
|
+
def mathml_mi_italics
|
31
|
+
{ uppergreek: false, upperroman: false,
|
32
|
+
lowergreek: false, lowerroman: true }
|
33
|
+
end
|
34
|
+
|
35
|
+
def xref_to_eref(elem, name)
|
36
|
+
if elem.at("//bibitem[@id = '#{elem['target']}']/" \
|
37
|
+
"docidentifier[@type = 'BIPM-long']")
|
38
|
+
elem["style"] = "BIPM-long"
|
39
|
+
end
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
ID_LABELS = {
|
44
|
+
"en" => {
|
45
|
+
"appendix" => "Appendix",
|
46
|
+
"annexid" => "Annex",
|
47
|
+
"part" => "Part",
|
48
|
+
},
|
49
|
+
"fr" => {
|
50
|
+
"appendix" => "Annexe",
|
51
|
+
"annexid" => "Appendice",
|
52
|
+
"part" => "Partie",
|
53
|
+
},
|
54
|
+
}.freeze
|
55
|
+
|
56
|
+
def bibdata_docidentifier_cleanup(isoxml)
|
57
|
+
bibdata_docidentifier_i18n(isoxml)
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def bibdata_docidentifier_i18n(isoxml)
|
62
|
+
id, parts = bibdata_docidentifier_i18n_prep(isoxml)
|
63
|
+
parts.empty? and return
|
64
|
+
id_alt = id.dup
|
65
|
+
id.next = id_alt
|
66
|
+
bibdata_docidentifier_enhance(id, @lang, parts)
|
67
|
+
bibdata_docidentifier_enhance(id_alt, @lang == "en" ? "fr" : "en",
|
68
|
+
parts)
|
69
|
+
end
|
70
|
+
|
71
|
+
def bibdata_docidentifier_i18n_prep(isoxml)
|
72
|
+
id = isoxml.at("//bibdata/docidentifier[@type = 'BIPM']")
|
73
|
+
parts = %w(appendix annexid part).each_with_object({}) do |w, m|
|
74
|
+
dn = isoxml.at("//bibdata/ext/structuredidentifier/#{w}") and
|
75
|
+
m[w] = dn.text
|
76
|
+
end
|
77
|
+
[id, parts]
|
78
|
+
end
|
79
|
+
|
80
|
+
def bibdata_docidentifier_enhance(id, lang, parts)
|
81
|
+
id["language"] = lang
|
82
|
+
ret = %w(appendix annexid part).each_with_object([]) do |w, m|
|
83
|
+
p = parts[w] and m << "#{ID_LABELS[lang][w]} #{p}"
|
84
|
+
end
|
85
|
+
id.children = "#{id.text} #{ret.join(' ')}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "metanorma/standoc/converter"
|
2
2
|
require "metanorma/generic/converter"
|
3
3
|
require_relative "front"
|
4
|
+
require_relative "cleanup"
|
4
5
|
|
5
6
|
module Metanorma
|
6
7
|
module BIPM
|
@@ -96,45 +97,6 @@ module Metanorma
|
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
99
|
-
def boilerplate_file(_xmldoc)
|
100
|
-
if @jcgm
|
101
|
-
File.join(File.dirname(__FILE__), "boilerplate-jcgm-en.adoc")
|
102
|
-
else
|
103
|
-
File.join(File.dirname(__FILE__), "boilerplate-#{@lang}.adoc")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def sections_cleanup(xml)
|
108
|
-
super
|
109
|
-
jcgm_untitled_sections_cleanup(xml) if @jcgm
|
110
|
-
end
|
111
|
-
|
112
|
-
def jcgm_untitled_sections_cleanup(xml)
|
113
|
-
xml.xpath("//clause//clause | //annex//clause | //introduction/clause")
|
114
|
-
.each do |c|
|
115
|
-
next if !c&.at("./title")&.text&.empty?
|
116
|
-
|
117
|
-
c["inline-header"] = true
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def section_names_terms_cleanup(xml); end
|
122
|
-
|
123
|
-
def section_names_refs_cleanup(xml); end
|
124
|
-
|
125
|
-
def mathml_mi_italics
|
126
|
-
{ uppergreek: false, upperroman: false,
|
127
|
-
lowergreek: false, lowerroman: true }
|
128
|
-
end
|
129
|
-
|
130
|
-
def xref_to_eref(elem, name)
|
131
|
-
if elem.at("//bibitem[@id = '#{elem['target']}']/" \
|
132
|
-
"docidentifier[@type = 'BIPM-long']")
|
133
|
-
elem["style"] = "BIPM-long"
|
134
|
-
end
|
135
|
-
super
|
136
|
-
end
|
137
|
-
|
138
100
|
def document(node)
|
139
101
|
@jcgm = node.attr("committee-acronym") == "JCGM"
|
140
102
|
super
|
@@ -156,12 +118,12 @@ module Metanorma
|
|
156
118
|
def presentation_xml_converter(node)
|
157
119
|
IsoDoc::BIPM::PresentationXMLConvert
|
158
120
|
.new(html_extract_attributes(node)
|
159
|
-
.merge(output_formats: ::Metanorma::BIPM::Processor.new
|
121
|
+
.merge(output_formats: ::Metanorma::BIPM::Processor.new
|
122
|
+
.output_formats))
|
160
123
|
end
|
161
124
|
|
162
125
|
def pdf_converter(node)
|
163
|
-
|
164
|
-
|
126
|
+
node.attr("no-pdf") and return nil
|
165
127
|
IsoDoc::BIPM::PdfConvert.new(pdf_extract_attributes(node))
|
166
128
|
end
|
167
129
|
end
|