metanorma-bipm 2.0.8 → 2.1.2
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/base_convert.rb +11 -2
- data/lib/isodoc/bipm/bipm.brochure.xsl +1657 -484
- data/lib/isodoc/bipm/bipm.guide.xsl +1657 -484
- data/lib/isodoc/bipm/bipm.mise-en-pratique.xsl +1657 -484
- data/lib/isodoc/bipm/bipm.rapport.xsl +1657 -484
- data/lib/isodoc/bipm/doccontrol.rb +101 -0
- data/lib/isodoc/bipm/html/html_bipm_titlepage.html +1 -0
- data/lib/isodoc/bipm/html/htmlstyle.css +6 -0
- data/lib/isodoc/bipm/html/htmlstyle.scss +1 -0
- data/lib/isodoc/bipm/init.rb +1 -1
- data/lib/isodoc/bipm/jcgm.standard.xsl +1696 -440
- data/lib/isodoc/bipm/presentation_xml_convert.rb +18 -93
- data/lib/isodoc/bipm/xref.rb +8 -4
- data/lib/metanorma/bipm/biblio.rng +69 -42
- data/lib/metanorma/bipm/bipm.rng +3 -0
- data/lib/metanorma/bipm/converter.rb +41 -108
- data/lib/metanorma/bipm/front.rb +113 -0
- data/lib/metanorma/bipm/isodoc.rng +65 -0
- data/lib/metanorma/bipm/version.rb +1 -1
- data/metanorma-bipm.gemspec +2 -2
- metadata +9 -7
@@ -3,6 +3,7 @@ require "metanorma-generic"
|
|
3
3
|
require "metanorma-iso"
|
4
4
|
require_relative "init"
|
5
5
|
require_relative "index"
|
6
|
+
require_relative "doccontrol"
|
6
7
|
|
7
8
|
module IsoDoc
|
8
9
|
module BIPM
|
@@ -85,99 +86,6 @@ module IsoDoc
|
|
85
86
|
doccontrol docxml
|
86
87
|
end
|
87
88
|
|
88
|
-
def doccontrol(doc)
|
89
|
-
return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
|
90
|
-
|
91
|
-
clause = <<~DOCCONTROL
|
92
|
-
<doccontrol>
|
93
|
-
<title>Document Control</title>
|
94
|
-
<table unnumbered="true"><tbody>
|
95
|
-
<tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
|
96
|
-
#{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
|
97
|
-
</tbody></table></doccontrol>
|
98
|
-
DOCCONTROL
|
99
|
-
doc.root << clause
|
100
|
-
end
|
101
|
-
|
102
|
-
def doccontrol_row1(doc)
|
103
|
-
return "" if list_draft(doc, 1) == ["", ""] && list_cochairs(doc).empty?
|
104
|
-
|
105
|
-
<<~ROW
|
106
|
-
<tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
|
107
|
-
<td>#{list_cochairs(doc)}</td></tr>
|
108
|
-
ROW
|
109
|
-
end
|
110
|
-
|
111
|
-
def doccontrol_row2(docxml)
|
112
|
-
list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
|
113
|
-
return ""
|
114
|
-
|
115
|
-
<<~ROW
|
116
|
-
<tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
|
117
|
-
<td>#{list_chairs(docxml)}</td></tr>
|
118
|
-
ROW
|
119
|
-
end
|
120
|
-
|
121
|
-
def list_drafts(xml)
|
122
|
-
ret = ""
|
123
|
-
i = 3
|
124
|
-
while list_draft(xml, i) != ["", ""]
|
125
|
-
ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join} "\
|
126
|
-
"<td/></tr>"
|
127
|
-
i += 1
|
128
|
-
end
|
129
|
-
ret
|
130
|
-
end
|
131
|
-
|
132
|
-
def list_draft(xml, idx)
|
133
|
-
d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]"\
|
134
|
-
"/bibitem")) or return ["", ""]
|
135
|
-
|
136
|
-
draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
|
137
|
-
edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
|
138
|
-
[[draft, edn].join(" "), d&.at(ns("./date"))&.text]
|
139
|
-
end
|
140
|
-
|
141
|
-
def list_authors(xml)
|
142
|
-
ret = list_people(
|
143
|
-
xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
|
144
|
-
)
|
145
|
-
@i18n.boolean_conj(ret, "and")
|
146
|
-
end
|
147
|
-
|
148
|
-
COCHAIR = "xmlns:role[contains(text(),'co-chair')]".freeze
|
149
|
-
CHAIR = "[xmlns:role[contains(text(),'chair')]"\
|
150
|
-
"[not(contains(text(),'co-chair'))]]".freeze
|
151
|
-
|
152
|
-
def list_cochairs(xml)
|
153
|
-
ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
|
154
|
-
ret.empty? and return ""
|
155
|
-
role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
|
156
|
-
label = ret.size > 1 && role ? "#{role}s" : role
|
157
|
-
"#{label}: #{@i18n.boolean_conj(ret, 'and')}"
|
158
|
-
end
|
159
|
-
|
160
|
-
def list_chairs(xml)
|
161
|
-
ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
|
162
|
-
ret.empty? and return ""
|
163
|
-
role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
|
164
|
-
label = ret.size > 1 && role ? "#{role}s" : role
|
165
|
-
"#{label}: #{@i18n.boolean_conj(ret, 'and')}"
|
166
|
-
end
|
167
|
-
|
168
|
-
def list_people(xml, xpath)
|
169
|
-
ret = []
|
170
|
-
xml.xpath(ns(xpath)).each do |p|
|
171
|
-
name = p&.at(ns("./name/completename"))&.text
|
172
|
-
aff = p&.at(ns("./affiliation/organization/abbreviation"))&.text ||
|
173
|
-
p&.at(ns("./affiliation/organization/name"))&.text
|
174
|
-
c = name || ""
|
175
|
-
aff and c += " (#{aff})"
|
176
|
-
ret << c
|
177
|
-
end
|
178
|
-
ret
|
179
|
-
end
|
180
|
-
|
181
89
|
def twitter_cldr_localiser_symbols
|
182
90
|
{ group: " ", fraction_group: " ", fraction_group_digits: 3 }
|
183
91
|
end
|
@@ -261,6 +169,23 @@ module IsoDoc
|
|
261
169
|
super || @xrefs.klass.standard?(bibitem)
|
262
170
|
end
|
263
171
|
|
172
|
+
def expand_citeas(text)
|
173
|
+
ret = super
|
174
|
+
if @lang == "fr" && /^(CGPM|CIPM) /.match?(ret)
|
175
|
+
ret.sub!(/^(CGPM|CIPM) (\S+)/) do |_m|
|
176
|
+
"#{$1} – #{FR_OUTCOME_TYPE[$2.to_sym] || $2}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
ret
|
180
|
+
end
|
181
|
+
|
182
|
+
FR_OUTCOME_TYPE = {
|
183
|
+
Resolution: "Résolution",
|
184
|
+
Decision: "Décision",
|
185
|
+
Recommendation: "Recommandation",
|
186
|
+
Declaration: "Déclaration",
|
187
|
+
}.freeze
|
188
|
+
|
264
189
|
include Init
|
265
190
|
end
|
266
191
|
end
|
data/lib/isodoc/bipm/xref.rb
CHANGED
@@ -153,8 +153,9 @@ module IsoDoc
|
|
153
153
|
|
154
154
|
def annex_names(clause, num)
|
155
155
|
@anchors[clause["id"]] = annex_name_anchors(clause, num)
|
156
|
-
if
|
157
|
-
annex_names1(
|
156
|
+
if @klass.single_term_clause?(clause)
|
157
|
+
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
|
158
|
+
num.to_s, 1)
|
158
159
|
else
|
159
160
|
i = Counter.new
|
160
161
|
prefix = @jcgm ? "" : "A"
|
@@ -176,8 +177,9 @@ module IsoDoc
|
|
176
177
|
def unnumbered_annex_names(clause)
|
177
178
|
lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
|
178
179
|
@anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
|
179
|
-
if
|
180
|
-
annex_names1(
|
180
|
+
if @klass.single_term_clause?(clause)
|
181
|
+
annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
|
182
|
+
num.to_s, 1)
|
181
183
|
else
|
182
184
|
clause.xpath(ns(SUBCLAUSES))
|
183
185
|
.each { |c| unnumbered_annex_names1(c, 2) }
|
@@ -229,10 +231,12 @@ module IsoDoc
|
|
229
231
|
|
230
232
|
def initial_anchor_names(doc)
|
231
233
|
super
|
234
|
+
if @parse_settings.empty? || @parse_settings[:clauses]
|
232
235
|
if @jcgm
|
233
236
|
@iso.introduction_names(doc.at(ns("//introduction")))
|
234
237
|
@anchors.merge!(@iso.get)
|
235
238
|
end
|
239
|
+
end
|
236
240
|
end
|
237
241
|
|
238
242
|
def sequential_figure_names(clause)
|
@@ -614,12 +614,12 @@
|
|
614
614
|
<optional>
|
615
615
|
<ref name="fetched"/>
|
616
616
|
</optional>
|
617
|
-
<
|
618
|
-
<oneOrMore>
|
619
|
-
<ref name="btitle"/>
|
620
|
-
</oneOrMore>
|
617
|
+
<optional>
|
621
618
|
<ref name="formattedref"/>
|
622
|
-
</
|
619
|
+
</optional>
|
620
|
+
<oneOrMore>
|
621
|
+
<ref name="btitle"/>
|
622
|
+
</oneOrMore>
|
623
623
|
<zeroOrMore>
|
624
624
|
<ref name="bsource"/>
|
625
625
|
</zeroOrMore>
|
@@ -851,17 +851,46 @@
|
|
851
851
|
</define>
|
852
852
|
<define name="bplace">
|
853
853
|
<element name="place">
|
854
|
-
<
|
855
|
-
<
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
854
|
+
<choice>
|
855
|
+
<text/>
|
856
|
+
<group>
|
857
|
+
<ref name="bibliocity"/>
|
858
|
+
<zeroOrMore>
|
859
|
+
<ref name="biblioregion"/>
|
860
|
+
</zeroOrMore>
|
861
|
+
<zeroOrMore>
|
862
|
+
<ref name="bibliocountry"/>
|
863
|
+
</zeroOrMore>
|
864
|
+
</group>
|
865
|
+
</choice>
|
866
|
+
</element>
|
867
|
+
</define>
|
868
|
+
<define name="bibliocity">
|
869
|
+
<element name="city">
|
862
870
|
<text/>
|
863
871
|
</element>
|
864
872
|
</define>
|
873
|
+
<define name="biblioregion">
|
874
|
+
<element name="region">
|
875
|
+
<ref name="RegionType"/>
|
876
|
+
</element>
|
877
|
+
</define>
|
878
|
+
<define name="bibliocountry">
|
879
|
+
<element name="country">
|
880
|
+
<ref name="RegionType"/>
|
881
|
+
</element>
|
882
|
+
</define>
|
883
|
+
<define name="RegionType">
|
884
|
+
<optional>
|
885
|
+
<attribute name="iso"/>
|
886
|
+
</optional>
|
887
|
+
<optional>
|
888
|
+
<attribute name="recommended">
|
889
|
+
<data type="boolean"/>
|
890
|
+
</attribute>
|
891
|
+
</optional>
|
892
|
+
<text/>
|
893
|
+
</define>
|
865
894
|
<define name="bprice">
|
866
895
|
<element name="price">
|
867
896
|
<attribute name="currency"/>
|
@@ -957,36 +986,34 @@
|
|
957
986
|
<ref name="SeriesType"/>
|
958
987
|
</attribute>
|
959
988
|
</optional>
|
960
|
-
<
|
989
|
+
<optional>
|
961
990
|
<ref name="formattedref"/>
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
</group>
|
989
|
-
</choice>
|
991
|
+
</optional>
|
992
|
+
<ref name="btitle"/>
|
993
|
+
<optional>
|
994
|
+
<ref name="bplace"/>
|
995
|
+
</optional>
|
996
|
+
<optional>
|
997
|
+
<ref name="seriesorganization"/>
|
998
|
+
</optional>
|
999
|
+
<optional>
|
1000
|
+
<ref name="abbreviation"/>
|
1001
|
+
</optional>
|
1002
|
+
<optional>
|
1003
|
+
<ref name="seriesfrom"/>
|
1004
|
+
</optional>
|
1005
|
+
<optional>
|
1006
|
+
<ref name="seriesto"/>
|
1007
|
+
</optional>
|
1008
|
+
<optional>
|
1009
|
+
<ref name="seriesnumber"/>
|
1010
|
+
</optional>
|
1011
|
+
<optional>
|
1012
|
+
<ref name="seriespartnumber"/>
|
1013
|
+
</optional>
|
1014
|
+
<optional>
|
1015
|
+
<ref name="seriesrun"/>
|
1016
|
+
</optional>
|
990
1017
|
</element>
|
991
1018
|
</define>
|
992
1019
|
<define name="SeriesType">
|
data/lib/metanorma/bipm/bipm.rng
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "metanorma/standoc/converter"
|
2
2
|
require "metanorma/generic/converter"
|
3
|
+
require_relative "front"
|
3
4
|
|
4
5
|
module Metanorma
|
5
6
|
module BIPM
|
@@ -22,114 +23,6 @@ module Metanorma
|
|
22
23
|
{ org_name_long => configuration.organization_name_short }
|
23
24
|
end
|
24
25
|
|
25
|
-
def metadata_committee(node, xml)
|
26
|
-
return unless node.attr("committee-en") || node.attr("committee-fr")
|
27
|
-
|
28
|
-
xml.editorialgroup do |a|
|
29
|
-
metadata_committee1(node, a)
|
30
|
-
i = 2
|
31
|
-
while node.attr("committee-en_#{i}") || node.attr("committee-fr_#{i}")
|
32
|
-
metadata_committee2(node, a, i)
|
33
|
-
i += 1
|
34
|
-
end
|
35
|
-
metadata_workgroup(node, a)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def metadata_committee1(node, xml)
|
40
|
-
xml.committee **attr_code(acronym:
|
41
|
-
node.attr("committee-acronym")) do |c|
|
42
|
-
e = node.attr("committee-en") and
|
43
|
-
c.variant e, language: "en", script: "Latn"
|
44
|
-
e = node.attr("committee-fr") and
|
45
|
-
c.variant e, language: "fr", script: "Latn"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def metadata_committee2(node, xml, num)
|
50
|
-
xml.committee **attr_code(acronym:
|
51
|
-
node.attr("committee-acronym_#{num}")) do |c|
|
52
|
-
%w(en fr).each do |lg|
|
53
|
-
e = node.attr("committee-#{lg}_#{num}") and
|
54
|
-
c.variant e, language: lg, script: "Latn"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def metadata_workgroup(node, xml)
|
60
|
-
xml.workgroup(node.attr("workgroup"),
|
61
|
-
**attr_code(acronym: node.attr("workgroup-acronym")))
|
62
|
-
i = 2
|
63
|
-
while node.attr("workgroup_#{i}")
|
64
|
-
xml.workgroup(
|
65
|
-
node.attr("workgroup_#{i}"),
|
66
|
-
**attr_code(acronym: node.attr("workgroup-acronym_#{i}"))
|
67
|
-
)
|
68
|
-
i += 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def metadata_relations(node, xml)
|
73
|
-
super
|
74
|
-
relation_supersedes_self(node, xml, "")
|
75
|
-
i = 2
|
76
|
-
while relation_supersedes_self(node, xml, "_#{i}")
|
77
|
-
i += 1
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def relation_supersedes_self(node, xml, suffix)
|
82
|
-
d = node.attr("supersedes-date#{suffix}")
|
83
|
-
draft = node.attr("supersedes-draft#{suffix}")
|
84
|
-
edition = node.attr("supersedes-edition#{suffix}")
|
85
|
-
return false unless d || draft || edition
|
86
|
-
|
87
|
-
relation_supersedes_self1(xml, d, edition, draft)
|
88
|
-
end
|
89
|
-
|
90
|
-
def relation_supersedes_self1(xml, date, edition, draft)
|
91
|
-
xml.relation **{ type: "supersedes" } do |r|
|
92
|
-
r.bibitem do |b|
|
93
|
-
date and b.date(date,
|
94
|
-
**{ type: edition ? "published" : "circulated" })
|
95
|
-
edition and b.edition edition
|
96
|
-
draft and b.version do |v|
|
97
|
-
v.draft draft
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def personal_role(node, xml, suffix)
|
104
|
-
role = node.attr("role#{suffix}") || "author"
|
105
|
-
unless %w(author editor).include?(role.downcase)
|
106
|
-
desc = role
|
107
|
-
role = "editor"
|
108
|
-
end
|
109
|
-
xml.role desc, **{ type: role.downcase }
|
110
|
-
end
|
111
|
-
|
112
|
-
def title(node, xml)
|
113
|
-
["en", "fr"].each do |lang|
|
114
|
-
at = { language: lang, format: "text/plain" }
|
115
|
-
xml.title **attr_code(at.merge(type: "main")) do |t1|
|
116
|
-
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
|
117
|
-
end
|
118
|
-
%w(cover appendix annex part subpart provenance).each do |w|
|
119
|
-
typed_title(node, xml, lang, w)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def typed_title(node, xml, lang, type)
|
125
|
-
at = { language: lang, format: "text/plain" }
|
126
|
-
return unless title = node.attr("title-#{type}-#{lang}")
|
127
|
-
|
128
|
-
xml.title **attr_code(at.merge(type: type)) do |t1|
|
129
|
-
t1 << Metanorma::Utils::asciidoc_sub(title)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
26
|
def sectiontype_streamline(ret)
|
134
27
|
case ret
|
135
28
|
when "introduction" then @jcgm ? "introduction" : "clause"
|
@@ -157,6 +50,46 @@ module Metanorma
|
|
157
50
|
ret
|
158
51
|
end
|
159
52
|
|
53
|
+
=begin
|
54
|
+
def reference_names(xmldoc)
|
55
|
+
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
56
|
+
docid = ref.at("./docidentifier[@type = 'metanorma']") ||
|
57
|
+
ref.at("./docidentifier[not(@type = 'DOI')]") or next
|
58
|
+
#date = ref.at("./date[@type = 'published']")
|
59
|
+
#reference = format_ref(reference_names1(docid, date, docid["type"]),
|
60
|
+
#docid["type"])
|
61
|
+
reference = format_ref(docid.children.to_xml, docid["type"])
|
62
|
+
@anchors[ref["id"]] = { xref: reference }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def reference_names1(docid, date, type)
|
67
|
+
ret = docid.children.to_xml
|
68
|
+
if type == "BIPM" && date &&
|
69
|
+
/(CIPM|CGPM) (Decision|Resolution)/.match?(docid)
|
70
|
+
ret += " (#{date_range(date)})"
|
71
|
+
end
|
72
|
+
ret
|
73
|
+
end
|
74
|
+
=end
|
75
|
+
|
76
|
+
def date_range(date)
|
77
|
+
from = date.at(("./from"))
|
78
|
+
to = date.at(("./to"))
|
79
|
+
on = date.at(("./on"))
|
80
|
+
return date.text unless from || on || to
|
81
|
+
return on.text.sub(/-.*$/, "") if on
|
82
|
+
|
83
|
+
ret = "#{from.text.sub(/-.*$/, '')}–"
|
84
|
+
ret += to.text.sub(/-.*$/, "") if to
|
85
|
+
ret
|
86
|
+
end
|
87
|
+
|
88
|
+
def format_ref(ref, type)
|
89
|
+
ref = ref.sub(/^BIPM /, "") if type == "BIPM"
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
160
93
|
def clause_parse(attrs, xml, node)
|
161
94
|
node.option?("unnumbered") and attrs[:unnumbered] = true
|
162
95
|
super
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module BIPM
|
3
|
+
class Converter < Metanorma::Generic::Converter
|
4
|
+
def metadata_committee(node, xml)
|
5
|
+
return unless node.attr("committee-en") || node.attr("committee-fr")
|
6
|
+
|
7
|
+
xml.editorialgroup do |a|
|
8
|
+
metadata_committee1(node, a)
|
9
|
+
i = 2
|
10
|
+
while node.attr("committee-en_#{i}") || node.attr("committee-fr_#{i}")
|
11
|
+
metadata_committee2(node, a, i)
|
12
|
+
i += 1
|
13
|
+
end
|
14
|
+
metadata_workgroup(node, a)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def metadata_committee1(node, xml)
|
19
|
+
xml.committee **attr_code(acronym:
|
20
|
+
node.attr("committee-acronym")) do |c|
|
21
|
+
e = node.attr("committee-en") and
|
22
|
+
c.variant e, language: "en", script: "Latn"
|
23
|
+
e = node.attr("committee-fr") and
|
24
|
+
c.variant e, language: "fr", script: "Latn"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def metadata_committee2(node, xml, num)
|
29
|
+
xml.committee **attr_code(acronym:
|
30
|
+
node.attr("committee-acronym_#{num}")) do |c|
|
31
|
+
%w(en fr).each do |lg|
|
32
|
+
e = node.attr("committee-#{lg}_#{num}") and
|
33
|
+
c.variant e, language: lg, script: "Latn"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def metadata_workgroup(node, xml)
|
39
|
+
xml.workgroup(node.attr("workgroup"),
|
40
|
+
**attr_code(acronym: node.attr("workgroup-acronym")))
|
41
|
+
i = 2
|
42
|
+
while node.attr("workgroup_#{i}")
|
43
|
+
xml.workgroup(
|
44
|
+
node.attr("workgroup_#{i}"),
|
45
|
+
**attr_code(acronym: node.attr("workgroup-acronym_#{i}")),
|
46
|
+
)
|
47
|
+
i += 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def metadata_relations(node, xml)
|
52
|
+
super
|
53
|
+
relation_supersedes_self(node, xml, "")
|
54
|
+
i = 2
|
55
|
+
while relation_supersedes_self(node, xml, "_#{i}")
|
56
|
+
i += 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def relation_supersedes_self(node, xml, suffix)
|
61
|
+
d = node.attr("supersedes-date#{suffix}")
|
62
|
+
draft = node.attr("supersedes-draft#{suffix}")
|
63
|
+
edition = node.attr("supersedes-edition#{suffix}")
|
64
|
+
return false unless d || draft || edition
|
65
|
+
|
66
|
+
relation_supersedes_self1(xml, d, edition, draft)
|
67
|
+
end
|
68
|
+
|
69
|
+
def relation_supersedes_self1(xml, date, edition, draft)
|
70
|
+
xml.relation **{ type: "supersedes" } do |r|
|
71
|
+
r.bibitem do |b|
|
72
|
+
date and b.date(date,
|
73
|
+
**{ type: edition ? "published" : "circulated" })
|
74
|
+
edition and b.edition edition
|
75
|
+
draft and b.version do |v|
|
76
|
+
v.draft draft
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def personal_role(node, xml, suffix)
|
83
|
+
role = node.attr("role#{suffix}") || "author"
|
84
|
+
unless %w(author editor).include?(role.downcase)
|
85
|
+
desc = role
|
86
|
+
role = "editor"
|
87
|
+
end
|
88
|
+
xml.role desc, **{ type: role.downcase }
|
89
|
+
end
|
90
|
+
|
91
|
+
def title(node, xml)
|
92
|
+
["en", "fr"].each do |lang|
|
93
|
+
at = { language: lang, format: "text/plain" }
|
94
|
+
xml.title **attr_code(at.merge(type: "main")) do |t1|
|
95
|
+
t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
|
96
|
+
end
|
97
|
+
%w(cover appendix annex part subpart provenance).each do |w|
|
98
|
+
typed_title(node, xml, lang, w)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def typed_title(node, xml, lang, type)
|
104
|
+
at = { language: lang, format: "text/plain" }
|
105
|
+
return unless title = node.attr("title-#{type}-#{lang}")
|
106
|
+
|
107
|
+
xml.title **attr_code(at.merge(type: type)) do |t1|
|
108
|
+
t1 << Metanorma::Utils::asciidoc_sub(title)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|