metanorma-bipm 2.2.9 → 2.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ require "metanorma-iso"
4
4
  require_relative "init"
5
5
  require_relative "index"
6
6
  require_relative "doccontrol"
7
+ require_relative "../../relaton/render/general"
7
8
 
8
9
  module IsoDoc
9
10
  module BIPM
@@ -24,8 +25,7 @@ module IsoDoc
24
25
  end
25
26
 
26
27
  def table1(elem)
27
- return if labelled_ancestor(elem) || elem["unnumbered"]
28
-
28
+ labelled_ancestor(elem) || elem["unnumbered"] and return
29
29
  n = @xrefs.anchor(elem["id"], :label, false)
30
30
  prefix_name(elem, ".<tab/>",
31
31
  l10n("#{@i18n.table.capitalize} #{n}"), "name")
@@ -40,9 +40,8 @@ module IsoDoc
40
40
  end
41
41
 
42
42
  def annex1(elem)
43
- return super if @jcgm
44
- return if elem["unnumbered"] == "true"
45
-
43
+ @jcgm and return super
44
+ elem["unnumbered"] == "true" and return
46
45
  lbl = @xrefs.anchor(elem["id"], :label)
47
46
  t = elem.at(ns("./title")) and
48
47
  t.children = "<strong>#{to_xml(t.children)}</strong>"
@@ -59,18 +58,15 @@ module IsoDoc
59
58
  end
60
59
 
61
60
  def clause1(elem)
62
- elem.at(("./ancestor::*[@unnumbered = 'true']")) and
61
+ elem.at("./ancestor::*[@unnumbered = 'true']") and
63
62
  elem["unnumbered"] = "true"
64
-
65
63
  super
66
64
  end
67
65
 
68
66
  def prefix_name(node, delim, number, elem)
69
- return if number.nil? || number.empty?
70
-
67
+ number.nil? || number.empty? and return
71
68
  unless name = node.at(ns("./#{elem}[not(@type = 'quoted')]"))
72
- return if node.at(ns("./#{elem}[@type = 'quoted']"))
73
-
69
+ node.at(ns("./#{elem}[@type = 'quoted']")) and return
74
70
  (node.children.empty? and node.add_child("<#{elem}></#{elem}>")) or
75
71
  node.children.first.previous = "<#{elem}></#{elem}>"
76
72
  name = node.children.first
@@ -117,14 +113,12 @@ module IsoDoc
117
113
  end
118
114
 
119
115
  def bibdata_titles(bibdata)
120
- return unless app = bibdata.at(ns("//bibdata/ext/" \
121
- "structuredidentifier/part"))
122
-
116
+ app = bibdata.at(ns("//bibdata/ext/" \
117
+ "structuredidentifier/part")) or return
123
118
  bibdata.xpath(ns("//bibdata/title[@type = 'part']")).each do |t|
124
119
  t.previous = t.dup
125
120
  t["type"] = "part-with-numbering"
126
- part = t["language"] == "en" ? "Part" : "Partie"
127
- # not looking up in YAML
121
+ part = t["language"] == "en" ? "Part" : "Partie" # not looking up in YAML
128
122
  t.children = l10n("#{part} #{app.text}: #{to_xml(t.children)}",
129
123
  t["language"])
130
124
  end
@@ -146,8 +140,7 @@ module IsoDoc
146
140
  end
147
141
 
148
142
  def jcgm_eref(docxml, xpath)
149
- return unless @jcgm
150
-
143
+ @jcgm or return
151
144
  docxml.xpath(ns(xpath)).each { |x| extract_brackets(x) }
152
145
  # merge adjacent text nodes
153
146
  docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
@@ -163,7 +156,6 @@ module IsoDoc
163
156
  start = node.at("./text()[1]")
164
157
  finish = node.at("./text()[last()]")
165
158
  (/^\[/.match?(start.text) && /\]$/.match?(finish.text)) or return
166
-
167
159
  start.replace(start.text[1..-1])
168
160
  node.previous = "["
169
161
  finish = node.at("./text()[last()]")
@@ -180,12 +172,8 @@ module IsoDoc
180
172
 
181
173
  # notes and remarques (list notes) are not numbered
182
174
  def note1(elem)
183
- return if elem.parent.name == "bibitem" || elem["notag"] == "true"
184
-
185
- # n = @xrefs.get[elem["id"]]
175
+ elem.parent.name == "bibitem" || elem["notag"] == "true" and return
186
176
  lbl = l10n(note_label(elem))
187
- # (n.nil? || n[:label].nil? || n[:label].empty?) or
188
- # lbl = l10n("#{lbl} #{n[:label]}")
189
177
  prefix_name(elem, "", lbl, "name")
190
178
  end
191
179
 
@@ -193,29 +181,57 @@ module IsoDoc
193
181
  if elem.ancestors("preface").empty?
194
182
  if elem.ancestors("ul, ol, dl").empty?
195
183
  @i18n.note
196
- else
197
- @i18n.listnote
198
- end
199
- else
200
- @i18n.prefacenote
184
+ else @i18n.listnote end
185
+ else @i18n.prefacenote
201
186
  end
202
187
  end
203
188
 
204
189
  def termsource1(elem)
190
+ # elem["status"] == "modified" and return super
205
191
  while elem&.next_element&.name == "termsource"
206
192
  elem << "; #{to_xml(elem.next_element.remove.children)}"
207
193
  end
208
- elem.children = l10n("[#{@i18n.source} #{to_xml(elem.children).strip}]")
194
+ elem.children = l10n("[#{termsource_adapt(elem['status'])}" \
195
+ "#{to_xml(elem.children).strip}]")
209
196
  end
210
197
 
211
- def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn, _bib)
198
+ def termsource_adapt(status)
199
+ case status
200
+ when "adapted" then @i18n.adapted_from
201
+ when "modified" then @i18n.modified_from
202
+ else ""
203
+ end
204
+ end
205
+
206
+ def termsource(docxml)
207
+ termsource_insert_empty_modification(docxml)
208
+ super
209
+ end
210
+
211
+ def termsource_insert_empty_modification(docxml)
212
+ docxml.xpath("//xmlns:termsource[@status = 'modified']" \
213
+ "[not(xmlns:modification)]").each do |f|
214
+ f << "<modification/>"
215
+ end
216
+ end
217
+
218
+ def termsource_modification(elem)
219
+ if elem["status"] == "modified"
220
+ origin = elem.at(ns("./origin"))
221
+ # s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
222
+ end
223
+ termsource_add_modification_text(elem.at(ns("./modification")))
224
+ end
225
+
226
+ def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn,
227
+ _bib)
212
228
  ret = (identifiers[0] || identifiers[1])
213
229
  ret += " #{identifiers[1]}" if identifiers[0] && identifiers[1]
214
230
  "#{ret}#{datefn} "
215
231
  end
216
232
 
217
- def biblio_ref_entry_code(ordinal, ids, _id, standard, datefn, _bib)
218
- #standard and id = nil
233
+ def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
234
+ # standard and id = nil
219
235
  ret = (ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]")
220
236
  if ids[:sdo]
221
237
  ret = prefix_bracketed_ref(ret)
@@ -226,6 +242,10 @@ module IsoDoc
226
242
  ret
227
243
  end
228
244
 
245
+ def bibrenderer
246
+ ::Relaton::Render::BIPM::General.new(language: @lang)
247
+ end
248
+
229
249
  include Init
230
250
  end
231
251
  end
@@ -51,9 +51,9 @@ module Metanorma
51
51
  end
52
52
 
53
53
  def date_range(date)
54
- from = date.at(("./from"))
55
- to = date.at(("./to"))
56
- on = date.at(("./on"))
54
+ from = date.at("./from")
55
+ to = date.at("./to")
56
+ on = date.at("./on")
57
57
  return date.text unless from || on || to
58
58
  return on.text.sub(/-.*$/, "") if on
59
59
 
@@ -125,6 +125,14 @@ module Metanorma
125
125
  lowergreek: false, lowerroman: true }
126
126
  end
127
127
 
128
+ def xref_to_eref(elem, name)
129
+ if elem.at("//bibitem[@id = '#{elem['target']}']/" \
130
+ "docidentifier[@type = 'BIPM-long']")
131
+ elem["style"] = "BIPM-long"
132
+ end
133
+ super
134
+ end
135
+
128
136
  def document(node)
129
137
  @jcgm = node.attr("committee-acronym") == "JCGM"
130
138
  super
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.1 -->
20
+ <!-- VERSION v1.2.2 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -211,6 +211,9 @@
211
211
  <data type="boolean"/>
212
212
  </attribute>
213
213
  </optional>
214
+ <optional>
215
+ <attribute name="style"/>
216
+ </optional>
214
217
  <ref name="CitationType"/>
215
218
  <oneOrMore>
216
219
  <ref name="PureTextElement"/>
@@ -1009,6 +1012,7 @@
1009
1012
  <ref name="del"/>
1010
1013
  <ref name="span"/>
1011
1014
  <ref name="erefstack"/>
1015
+ <ref name="date_inline"/>
1012
1016
  </choice>
1013
1017
  </define>
1014
1018
  <define name="add">
@@ -1050,6 +1054,23 @@
1050
1054
  </oneOrMore>
1051
1055
  </element>
1052
1056
  </define>
1057
+ <define name="date_inline">
1058
+ <element name="date">
1059
+ <attribute name="value"/>
1060
+ <optional>
1061
+ <attribute name="format"/>
1062
+ </optional>
1063
+ <optional>
1064
+ <attribute name="language"/>
1065
+ </optional>
1066
+ <optional>
1067
+ <attribute name="script"/>
1068
+ </optional>
1069
+ <optional>
1070
+ <attribute name="locale"/>
1071
+ </optional>
1072
+ </element>
1073
+ </define>
1053
1074
  <define name="concept">
1054
1075
  <element name="concept">
1055
1076
  <optional>
@@ -2136,6 +2157,7 @@
2136
2157
  <choice>
2137
2158
  <value>identical</value>
2138
2159
  <value>modified</value>
2160
+ <value>adapted</value>
2139
2161
  <value>restyled</value>
2140
2162
  <value>context-added</value>
2141
2163
  <value>generalisation</value>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.2.9".freeze
3
+ VERSION = "2.2.11".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,47 @@
1
+ nametemplate:
2
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: ' ' | remove: '.' | remove: '_' }}{% endif %}"
3
+ two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: ' ' | remove: '.' | remove: '_' }}{% endif %} {{ labels['and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1] | join: ' ' | remove: '.' | remove: '_' }}{% endif %}"
4
+ more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0] | join: ' ' | remove: '.' | remove: '_' }} {% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1] | join: ' ' | remove: '.' | remove: '_' }} {% endif %} {{ labels['and'] }} {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2] | join: ' ' | remove: '.' | remove: '_' }}{% endif %}"
5
+ seriestemplate: "{% if series_formatted %}{{ series_formatted }}{% else %}{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ({{series_run}}) {{series_num}}|.{{series_partnumber}}{% endif %}"
6
+ extenttemplate:
7
+ book: "<strong>{{ volume }}</strong> ({{issue}}) {{ page }}"
8
+ booklet: book
9
+ proceedings: book
10
+ journal: "<strong>{{ volume_raw }}</strong> ({{issue_raw}}) {{ page_raw }}"
11
+ article: journal
12
+ standard: book
13
+ techreport: "<strong>{{ volume }}</strong> ({{issue}}) {{ page }}"
14
+ inbook: "{{ volume }}: {{ page }}"
15
+ misc: "<strong>{{ volume }}</strong> ({{issue}}) {{ page }}, {{ duration }}"
16
+ template:
17
+ book: "{{ creatornames }} ({{role | capitalize}}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> ,_{{ edition | capitalize_first }}. [{{medium}}] ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}) {{draft}} ({{ series }}) {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. {{size}}. {{extent}}."
18
+ # TODO: omitted: author ids, subsidiary titles, subsidiary creators, rights metadata, distributor, item attributes, relationships
19
+ booklet: book
20
+ manual: book
21
+ proceedings: book
22
+ inbook: "{{ creatornames }} ({{role | capitalize}}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} {{ title }} . {{ authoritative_identifier | join: '. ' }}. {{ labels['in'] | capitalize }}: {{ host_creatornames}} ({{ host_role | capitalize}}) <em>{{host_title}}</em> [{{medium}}] ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}) {{draft}} ({{ series }}) . {{size}}. {{extent}}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
23
+ inproceedings: inbook
24
+ incollection: inbook
25
+ # TODO: omitted: author ids, additional info for component part, subsidiary titles of host resource, rights metadata, distributor, relationships
26
+ journal: "<em>{{ title}}</em> [{{medium}}] . ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}). ({{date}}). {{size}}. {{extent}}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
27
+ # TODO subsidiary titles, rights metadata, item attributes, relationships
28
+ article: "{{ creatornames }} ({{role | capitalize}}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} {{ series }}. [{{medium}}] {{draft}} . {{size}}. {{ extent }}. {{ authoritative_identifier | join: '. ' }}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
29
+ # TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, item attributes, relationships; newspapers
30
+ software: "{{ creatornames }} ({{ role | capitalize}}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }} {{draft}} . [{{medium | capitalize}}]. ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}). {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{size}}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
31
+ # TODO: omitted: author ids, subsidiary titles, subsidiary creators, copyright, license, distributor, system requirements, relationships
32
+ electronic resource: software
33
+ standard: "{% if home_standard %}<em>{{title}}</em>, _{{extent}}{%else%}{% if creatornames %}{{ creatornames }} ({{ role | capitalize}}){%else%}{{ publisher}}{%endif%} . ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> ({{nistpublisher}}), {{draft }} {{ series }} . [{{ medium | capitalize }}]. {{size}}. {{ extent }}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}].{%endif%}"
34
+ # TODO: omitted: author ids, subsidiary titles, rights metadata, distributor, persistent identifier, item attributes, relationships
35
+ techreport: "{% if creatornames %}{{ creatornames }} ({{ role | capitalize}}){%else%}{{ publisher}}{%endif%} . ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> ({{nistpublisher}}), {{draft }} {{ series }} . [{{ medium | capitalize }}]. {{size}}. {{ extent }}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{ labels['at'] | capitalize}}:_{{ access_location }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
36
+ dataset: "{{ creatornames }} ({{ role | capitalize }}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }} [{{medium }}]. {{ labels['in'] | capitalize }}:_{{series}}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. {{ size }}. {{ extent}}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
37
+ # TODO: omitted: author ids, system requirements, host archive, copyright, license, data source, distributor, usage instructions, relationships, provenance
38
+ website: "{{ creatornames }} ({{ role | capitalize }}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> . {{ labels['version'] | capitalize }}_{{ edition_raw }} [{{medium }}] ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}) {{ draft }} . {{ authoritative_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]. "
39
+ # TODO: omitted: author ids, page title, system requirements, subsidiary creator, rights metadata, distributor, persistent identifier, archive location, archive date and time, relationships
40
+ webresource: website
41
+ # TODO: component part
42
+ unpublished: "{{ creatornames }} ({{ role | capitalize }}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> [{{ medium }}] {{ draft }} . {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
43
+ misc: unpublished
44
+ # TODO: omitted: author ids, subsidiary titles, subsidiary creators, host archive, item attributes, relationships
45
+ presentation: unpublished
46
+ thesis: "{{ creatornames }} ({{ role | capitalize }}) ({{date}} ({{ labels['updated'] }}_{{date_updated}}) {% if date %}){% endif %} <em>{{ title }}</em> [{{ medium }}] ({% if place %}{{place}}{%else%}{{ labels['no_place']}}{%endif%}:_{{publisher}}). {{ labels['at'] | capitalize}}:_{{ access_location }}. {{ authoritative_identifier | join: '. ' }}. {{ uri }}. [{{ labels['viewed'] }}:_{{date_accessed}}]."
47
+
@@ -0,0 +1,23 @@
1
+ require "relaton-render"
2
+
3
+ module Relaton
4
+ module Render
5
+ module BIPM
6
+ class General < ::Relaton::Render::IsoDoc::General
7
+ def config_loc
8
+ YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
9
+ end
10
+
11
+ def klass_initialize(_options)
12
+ @nametemplateklass = Relaton::Render::Template::Name
13
+ @seriestemplateklass = Relaton::Render::Template::Series
14
+ @extenttemplateklass = Relaton::Render::Template::Extent
15
+ @sizetemplateklass = Relaton::Render::Template::Size
16
+ @generaltemplateklass = Relaton::Render::Template::General
17
+ @fieldsklass = Relaton::Render::Fields
18
+ @parseklass = Relaton::Render::Parse
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Relaton
2
+ module Render
3
+ module BIPM
4
+ class Parse < ::Relaton::Render::Parse
5
+ def simple_or_host_xml2hash(doc, host)
6
+ ret = super
7
+ ret.merge(home_standard: home_standard(doc, ret[:publisher_raw]))
8
+ end
9
+
10
+ def home_standard(_doc, pubs)
11
+ pubs&.any? do |r|
12
+ ["International Organization for Standardization", "ISO",
13
+ "International Electrotechnical Commission", "IEC"]
14
+ .include?(r[:nonpersonal])
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.9
4
+ version: 2.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -276,6 +276,9 @@ files:
276
276
  - lib/metanorma/bipm/relaton-bipm.rng
277
277
  - lib/metanorma/bipm/reqt.rng
278
278
  - lib/metanorma/bipm/version.rb
279
+ - lib/relaton/render/config.yml
280
+ - lib/relaton/render/general.rb
281
+ - lib/relaton/render/parse.rb
279
282
  - metanorma-bipm.gemspec
280
283
  - metanorma.yml
281
284
  homepage: https://github.com/metanorma/metanorma-bipm