metanorma-iso 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isodoc/iso/base_convert.rb +1 -0
- data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/style-human.css +3 -0
- data/lib/isodoc/iso/html/style-human.scss +4 -0
- data/lib/isodoc/iso/html/style-iso.css +3 -0
- data/lib/isodoc/iso/html/style-iso.scss +4 -0
- data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/wordstyle-dis.css +4 -4
- data/lib/isodoc/iso/html/wordstyle-dis.scss +4 -4
- data/lib/isodoc/iso/iso.amendment.xsl +42 -13
- data/lib/isodoc/iso/iso.international-standard.xsl +42 -13
- data/lib/isodoc/iso/metadata.rb +22 -25
- data/lib/isodoc/iso/presentation_bibdata.rb +9 -3
- data/lib/isodoc/iso/presentation_xml_convert.rb +14 -17
- data/lib/isodoc/iso/presentation_xref.rb +3 -3
- data/lib/isodoc/iso/word_dis_cleanup.rb +7 -34
- data/lib/isodoc/iso/word_dis_convert.rb +33 -6
- data/lib/metanorma/iso/basicdoc.rng +0 -1
- data/lib/metanorma/iso/biblio.rng +1 -1
- data/lib/metanorma/iso/cleanup.rb +18 -16
- data/lib/metanorma/iso/front.rb +21 -5
- data/lib/metanorma/iso/front_id.rb +114 -186
- data/lib/metanorma/iso/isodoc.rng +2 -1
- data/lib/metanorma/iso/processor.rb +1 -1
- data/lib/metanorma/iso/section.rb +6 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/relaton/render/general.rb +1 -0
- data/metanorma-iso.gemspec +1 -1
- metadata +6 -6
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -6,7 +6,6 @@ module IsoDoc
|
|
6
6
|
def initialize(lang, script, locale, i18n)
|
7
7
|
super
|
8
8
|
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = nil }
|
9
|
-
set(:editorialgroup, [])
|
10
9
|
set(:obsoletes, nil)
|
11
10
|
set(:obsoletes_part, nil)
|
12
11
|
end
|
@@ -100,7 +99,7 @@ module IsoDoc
|
|
100
99
|
main = ""
|
101
100
|
tparts[:main].nil? or
|
102
101
|
main = @c.encode(tparts[:main].text, :hexadecimal)
|
103
|
-
tparts[:intro]
|
102
|
+
tparts[:intro] and
|
104
103
|
main = "#{@c.encode(tparts[:intro].text,
|
105
104
|
:hexadecimal)} — #{main}"
|
106
105
|
if tparts[:part]
|
@@ -119,20 +118,19 @@ module IsoDoc
|
|
119
118
|
end
|
120
119
|
|
121
120
|
def title_parts(isoxml, lang)
|
122
|
-
{ intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and "\
|
121
|
+
{ intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and " \
|
123
122
|
"@language='#{lang}']")),
|
124
|
-
main: isoxml.at(ns("//bibdata/title[@type='title-main' and "\
|
123
|
+
main: isoxml.at(ns("//bibdata/title[@type='title-main' and " \
|
125
124
|
"@language='#{lang}']")),
|
126
|
-
part: isoxml.at(ns("//bibdata/title[@type='title-part' and "\
|
125
|
+
part: isoxml.at(ns("//bibdata/title[@type='title-part' and " \
|
127
126
|
"@language='#{lang}']")),
|
128
|
-
amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and "\
|
127
|
+
amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and " \
|
129
128
|
"@language='#{lang}']")) }
|
130
129
|
end
|
131
130
|
|
132
131
|
def title(isoxml, _out)
|
133
132
|
lang = case @lang
|
134
|
-
when "fr" then
|
135
|
-
when "ru" then "ru"
|
133
|
+
when "fr", "ru" then @lang
|
136
134
|
else "en"
|
137
135
|
end
|
138
136
|
# intro, main, part, amd = title_parts(isoxml, lang)
|
@@ -179,58 +177,57 @@ module IsoDoc
|
|
179
177
|
tc(xml)
|
180
178
|
sc(xml)
|
181
179
|
wg(xml)
|
182
|
-
|
180
|
+
editorialgroup(xml)
|
183
181
|
secretariat(xml)
|
184
182
|
end
|
185
183
|
|
186
184
|
def tc(xml)
|
187
185
|
tcid = tc_base(xml, "editorialgroup") or return
|
188
186
|
set(:tc, tcid)
|
189
|
-
set(:editorialgroup, get[:editorialgroup] << tcid)
|
190
187
|
end
|
191
188
|
|
192
189
|
def tc_base(xml, grouptype)
|
193
|
-
tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/"\
|
190
|
+
tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/" \
|
194
191
|
"technical-committee/@number")) or return nil
|
195
|
-
tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/"\
|
192
|
+
tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/" \
|
196
193
|
"@type"))&.text || "TC"
|
197
|
-
"
|
194
|
+
tc_type == "Other" and tc_type = ""
|
195
|
+
"#{tc_type} #{tc_num.text}".strip
|
198
196
|
end
|
199
197
|
|
200
198
|
def sc(xml)
|
201
199
|
scid = sc_base(xml, "editorialgroup") or return
|
202
200
|
set(:sc, scid)
|
203
|
-
set(:editorialgroup, get[:editorialgroup] << scid)
|
204
201
|
end
|
205
202
|
|
206
203
|
def sc_base(xml, grouptype)
|
207
|
-
sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
|
204
|
+
sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
|
208
205
|
"@number")) or return nil
|
209
|
-
sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
|
206
|
+
sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
|
210
207
|
"@type"))&.text || "SC"
|
208
|
+
sc_type == "Other" and sc_type = ""
|
211
209
|
"#{sc_type} #{sc_num.text}"
|
212
210
|
end
|
213
211
|
|
214
212
|
def wg(xml)
|
215
213
|
wgid = wg_base(xml, "editorialgroup") or return
|
216
214
|
set(:wg, wgid)
|
217
|
-
set(:editorialgroup, get[:editorialgroup] << wgid)
|
218
215
|
end
|
219
216
|
|
220
217
|
def wg_base(xml, grouptype)
|
221
|
-
wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
|
218
|
+
wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
|
222
219
|
"@number")) or return
|
223
|
-
wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
|
220
|
+
wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
|
224
221
|
"@type"))&.text || "WG"
|
222
|
+
wg_type == "Other" and wg_type = ""
|
225
223
|
"#{wg_type} #{wg_num.text}"
|
226
224
|
end
|
227
225
|
|
228
|
-
def
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
set(:approvalgroup, ret.compact)
|
226
|
+
def editorialgroup(xml)
|
227
|
+
a = xml.at(ns("//bibdata/ext/editorialgroup/@identifier")) and
|
228
|
+
set(:editorialgroup, a.text)
|
229
|
+
a = xml.at(ns("//bibdata/ext/approvalgroup/@identifier")) and
|
230
|
+
set(:approvalgroup, a.text)
|
234
231
|
end
|
235
232
|
|
236
233
|
def secretariat(xml)
|
@@ -49,10 +49,16 @@ module IsoDoc
|
|
49
49
|
agency = group.xpath(ns("./agency"))&.map(&:text)
|
50
50
|
ret = %w(technical-committee subcommittee workgroup)
|
51
51
|
.each_with_object([]) do |v, m|
|
52
|
-
|
53
|
-
m << "#{a['type']} #{a['number']}"
|
52
|
+
m << editorialgroup_identifier2(group, v)
|
54
53
|
end
|
55
|
-
group["identifier"] = (agency + ret).join("/")
|
54
|
+
group["identifier"] = (agency + ret.compact).join("/")
|
55
|
+
end
|
56
|
+
|
57
|
+
def editorialgroup_identifier2(group, level)
|
58
|
+
a = group.at(ns("./#{level}")) or return nil
|
59
|
+
type = a["type"]
|
60
|
+
type.casecmp("other").zero? and type = ""
|
61
|
+
"#{type} #{a['number']}".strip
|
56
62
|
end
|
57
63
|
|
58
64
|
def bibdata_i18n(bib)
|
@@ -96,7 +96,8 @@ module IsoDoc
|
|
96
96
|
def concept_term(docxml)
|
97
97
|
docxml.xpath(ns("//term")).each do |f|
|
98
98
|
m = {}
|
99
|
-
f.xpath(ns(".//concept"))
|
99
|
+
(f.xpath(ns(".//concept")) - f.xpath(ns(".//term//concept")))
|
100
|
+
.each { |c| concept_term1(c, m) }
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
@@ -113,11 +114,13 @@ module IsoDoc
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def concept1_ref_content(ref)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
prev = "("
|
118
|
+
foll = ")"
|
119
|
+
if ref.name == "termref"
|
120
|
+
prev, foll = @i18n.term_defined_in.split("%")
|
121
|
+
end
|
122
|
+
ref.previous = prev
|
123
|
+
ref.next = foll
|
121
124
|
end
|
122
125
|
|
123
126
|
def concept1(node)
|
@@ -128,7 +131,6 @@ module IsoDoc
|
|
128
131
|
|
129
132
|
# we're assuming terms and clauses in the right place for display,
|
130
133
|
# to cope with multiple terms sections
|
131
|
-
|
132
134
|
def display_order(docxml)
|
133
135
|
i = 0
|
134
136
|
i = display_order_xpath(docxml, "//preface/*", i)
|
@@ -157,8 +159,7 @@ module IsoDoc
|
|
157
159
|
|
158
160
|
def insertall_after_here(node, insert, name)
|
159
161
|
node.children.each do |n|
|
160
|
-
|
161
|
-
|
162
|
+
n.name == name or next
|
162
163
|
insert.next = n.remove
|
163
164
|
insert = n
|
164
165
|
end
|
@@ -166,8 +167,7 @@ module IsoDoc
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def termexamples_before_termnotes(node)
|
169
|
-
|
170
|
-
|
170
|
+
insert = node.at(ns("./definition")) or return
|
171
171
|
insert = insertall_after_here(node, insert, "termexample")
|
172
172
|
insertall_after_here(node, insert, "termnote")
|
173
173
|
end
|
@@ -181,11 +181,9 @@ module IsoDoc
|
|
181
181
|
|
182
182
|
def admonition1(elem)
|
183
183
|
super
|
184
|
-
|
185
|
-
|
184
|
+
n = elem.at(ns("./name")) or return
|
186
185
|
p = n.next_element
|
187
|
-
|
188
|
-
|
186
|
+
p.name == "p" or return
|
189
187
|
p.children.first.previous = admonition_name(to_xml(n.remove.children))
|
190
188
|
end
|
191
189
|
|
@@ -199,8 +197,7 @@ module IsoDoc
|
|
199
197
|
end
|
200
198
|
|
201
199
|
def bibrender_formattedref(formattedref, xml)
|
202
|
-
|
203
|
-
|
200
|
+
%w(techreport standard).include? xml["type"] and return
|
204
201
|
super
|
205
202
|
end
|
206
203
|
|
@@ -113,11 +113,11 @@ module IsoDoc
|
|
113
113
|
delim = " "
|
114
114
|
@xrefs.anchor(container, :label)
|
115
115
|
# 7 a) : Clause 7 a), but Clause 7 List 1 a)
|
116
|
-
else
|
117
|
-
anchor_xref(node, container)
|
116
|
+
else anchor_xref(node, container)
|
118
117
|
end
|
119
118
|
|
120
|
-
|
119
|
+
ref and linkend = ref + delim + linkend
|
120
|
+
l10n(linkend)
|
121
121
|
end
|
122
122
|
|
123
123
|
def expand_citeas(text)
|
@@ -204,46 +204,13 @@ module IsoDoc
|
|
204
204
|
docxml
|
205
205
|
end
|
206
206
|
|
207
|
-
def authority_cleanup(docxml)
|
208
|
-
super
|
209
|
-
if @meta.get[:stage_int].to_s[0] == "9" ||
|
210
|
-
@meta.get[:stage_int].to_s[0] == "6"
|
211
|
-
copyright_prf(docxml)
|
212
|
-
else
|
213
|
-
copyright_dis(docxml)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def copyright_prf(docxml)
|
218
|
-
docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
|
219
|
-
p["class"] = "zzCopyright"
|
220
|
-
p["style"] = "text-indent:20.15pt;"
|
221
|
-
p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright' " \
|
222
|
-
"style='text-indent:20.15pt;'>"))
|
223
|
-
end
|
224
|
-
docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
|
225
|
-
# p["class"] = "zzCopyright"
|
226
|
-
p.remove
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
def copyright_dis(docxml)
|
231
|
-
docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
|
232
|
-
p["class"] = "zzCopyright"
|
233
|
-
p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright'>"))
|
234
|
-
end
|
235
|
-
docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each do |p|
|
236
|
-
p.remove
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
207
|
def word_section_end_empty_para(docxml)
|
241
208
|
docxml.at("//div[@class='WordSection1']/p[last()]").remove
|
242
209
|
end
|
243
210
|
|
244
211
|
def word_table_cell_para(docxml)
|
245
212
|
docxml.xpath("//td | //th").each do |t|
|
246
|
-
s = t
|
213
|
+
s = word_table_cell_para_style(t)
|
247
214
|
t.delete("header")
|
248
215
|
if t.at("./p |./div")
|
249
216
|
t.xpath("./p | ./div").each { |p| p["class"] = s }
|
@@ -253,6 +220,12 @@ module IsoDoc
|
|
253
220
|
end
|
254
221
|
end
|
255
222
|
|
223
|
+
def word_table_cell_para_style(cell)
|
224
|
+
ret = cell["header"] == "true" ? "Tableheader" : "Tablebody"
|
225
|
+
cell["class"] == "rouge-code" and ret = "Code"
|
226
|
+
ret
|
227
|
+
end
|
228
|
+
|
256
229
|
def table_toc_class
|
257
230
|
["Table title", "Tabletitle", "Annex Table Title", "AnnexTableTitle"] +
|
258
231
|
super
|
@@ -3,7 +3,7 @@ require_relative "word_dis_cleanup"
|
|
3
3
|
module IsoDoc
|
4
4
|
module Iso
|
5
5
|
class WordDISConvert < WordConvert
|
6
|
-
attr_accessor :bgstripcolor
|
6
|
+
attr_accessor :bgstripcolor
|
7
7
|
|
8
8
|
def default_file_locations(_options)
|
9
9
|
{ wordstylesheet: html_doc_path("wordstyle-dis.scss"),
|
@@ -21,8 +21,7 @@ module IsoDoc
|
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
|
-
def init_dis(opt)
|
25
|
-
end
|
24
|
+
def init_dis(opt); end
|
26
25
|
|
27
26
|
def convert1(docxml, filename, dir)
|
28
27
|
update_coverpage(docxml)
|
@@ -48,7 +47,7 @@ module IsoDoc
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def span_parse(node, out)
|
51
|
-
out.span
|
50
|
+
out.span class: node["class"] do |x|
|
52
51
|
node.children.each { |n| parse(n, x) }
|
53
52
|
end
|
54
53
|
end
|
@@ -88,7 +87,7 @@ module IsoDoc
|
|
88
87
|
end
|
89
88
|
|
90
89
|
def middle_title_dis(out)
|
91
|
-
out.p(
|
90
|
+
out.p(class: "zzSTDTitle") do |p|
|
92
91
|
p << @meta.get[:doctitleintro]
|
93
92
|
@meta.get[:doctitleintro] && @meta.get[:doctitlemain] and p << " — "
|
94
93
|
p << @meta.get[:doctitlemain]
|
@@ -104,7 +103,7 @@ module IsoDoc
|
|
104
103
|
end
|
105
104
|
|
106
105
|
def middle_title_dis_amd(para)
|
107
|
-
para.span(
|
106
|
+
para.span(style: "font-weight:normal") do |p|
|
108
107
|
if a = @meta.get[:doctitleamdlabel]
|
109
108
|
p << " #{a}"
|
110
109
|
a = @meta.get[:doctitleamd] and p << ": #{a}"
|
@@ -114,6 +113,34 @@ module IsoDoc
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
end
|
116
|
+
|
117
|
+
def authority_cleanup(docxml)
|
118
|
+
super
|
119
|
+
if @meta.get[:stage_int].to_s[0] == "9" ||
|
120
|
+
@meta.get[:stage_int].to_s[0] == "6"
|
121
|
+
copyright_prf(docxml)
|
122
|
+
else
|
123
|
+
copyright_dis(docxml)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def copyright_prf(docxml)
|
128
|
+
docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
|
129
|
+
p["class"] = "zzCopyright"
|
130
|
+
p["style"] = "text-indent:20.15pt;"
|
131
|
+
p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright' " \
|
132
|
+
"style='text-indent:20.15pt;'>"))
|
133
|
+
end
|
134
|
+
docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each(&:remove)
|
135
|
+
end
|
136
|
+
|
137
|
+
def copyright_dis(docxml)
|
138
|
+
docxml.xpath("//p[@id = 'boilerplate-address']")&.each do |p|
|
139
|
+
p["class"] = "zzCopyright"
|
140
|
+
p.replace(to_xml(p).gsub(%r{<br/>}, "</p>\n<p class='zzCopyright'>"))
|
141
|
+
end
|
142
|
+
docxml.xpath("//p[@class = 'zzCopyrightHdr']")&.each(&:remove)
|
143
|
+
end
|
117
144
|
end
|
118
145
|
end
|
119
146
|
end
|
@@ -1316,7 +1316,7 @@
|
|
1316
1316
|
<value>commentaryOf</value>
|
1317
1317
|
<value>hasCommentary</value>
|
1318
1318
|
<value>related</value>
|
1319
|
-
<value>
|
1319
|
+
<value>hasComplement</value>
|
1320
1320
|
<value>complementOf</value>
|
1321
1321
|
<value>obsoletes</value>
|
1322
1322
|
<value>obsoletedBy</value>
|
@@ -4,14 +4,14 @@ require "htmlentities"
|
|
4
4
|
module Metanorma
|
5
5
|
module ISO
|
6
6
|
class Converter < Standoc::Converter
|
7
|
-
PRE_NORMREF_FOOTNOTES = "//preface//fn | "\
|
7
|
+
PRE_NORMREF_FOOTNOTES = "//preface//fn | " \
|
8
8
|
"//clause[@type = 'scope']//fn".freeze
|
9
9
|
|
10
10
|
NORMREF_FOOTNOTES =
|
11
11
|
"//references[@normative = 'true']//fn".freeze
|
12
12
|
|
13
13
|
POST_NORMREF_FOOTNOTES =
|
14
|
-
"//sections//clause[not(@type = 'scope')]//fn | "\
|
14
|
+
"//sections//clause[not(@type = 'scope')]//fn | " \
|
15
15
|
"//annex//fn | //references[@normative = 'false']//fn".freeze
|
16
16
|
|
17
17
|
def other_footnote_renumber(xmldoc)
|
@@ -33,7 +33,7 @@ module Metanorma
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def get_id_prefix(xmldoc)
|
36
|
-
xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']"\
|
36
|
+
xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']" \
|
37
37
|
"/organization").each_with_object([]) do |x, prefix|
|
38
38
|
x1 = x.at("abbreviation")&.text || x.at("name")&.text
|
39
39
|
# (x1 == "ISO" and prefix.unshift("ISO")) or prefix << x1
|
@@ -44,14 +44,18 @@ module Metanorma
|
|
44
44
|
# ISO as a prefix goes first
|
45
45
|
def docidentifier_cleanup(xmldoc)
|
46
46
|
prefix = get_id_prefix(xmldoc)
|
47
|
+
=begin
|
47
48
|
id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
|
48
49
|
id.content = id_prefix(prefix, id)
|
50
|
+
=end
|
49
51
|
id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
|
50
52
|
id.content = id_prefix(prefix, id)
|
53
|
+
=begin
|
51
54
|
%w(iso-with-lang iso-reference iso-undated).each do |t|
|
52
55
|
id = xmldoc.at("//bibdata/docidentifier[@type = '#{t}']") and
|
53
56
|
id.content = id_prefix(prefix, id)
|
54
57
|
end
|
58
|
+
=end
|
55
59
|
end
|
56
60
|
|
57
61
|
def format_ref(ref, type)
|
@@ -60,23 +64,21 @@ module Metanorma
|
|
60
64
|
end
|
61
65
|
|
62
66
|
TERM_CLAUSE =
|
63
|
-
"//sections//terms | "\
|
67
|
+
"//sections//terms | " \
|
64
68
|
"//sections//clause[descendant::terms][not(descendant::definitions)]"
|
65
69
|
.freeze
|
66
70
|
|
67
71
|
PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
|
68
72
|
|
69
|
-
OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
|
70
|
-
"@type = 'ISBN'".freeze
|
71
|
-
|
72
73
|
def pub_class(bib)
|
73
74
|
return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
|
74
|
-
return 1 if bib.at("#{PUBLISHER}[name = 'International Organization "\
|
75
|
+
return 1 if bib.at("#{PUBLISHER}[name = 'International Organization " \
|
75
76
|
"for Standardization']")
|
76
77
|
return 2 if bib.at("#{PUBLISHER}[abbreviation = 'IEC']")
|
77
|
-
return 2 if bib.at("#{PUBLISHER}[name = 'International "\
|
78
|
+
return 2 if bib.at("#{PUBLISHER}[name = 'International " \
|
78
79
|
"Electrotechnical Commission']")
|
79
|
-
return 3 if bib.at("./docidentifier[@type]
|
80
|
+
return 3 if bib.at("./docidentifier[@type]" \
|
81
|
+
"[not(#{skip_docid} or @type = 'metanorma')]") ||
|
80
82
|
bib.at("./docidentifier[not(@type)]")
|
81
83
|
|
82
84
|
4
|
@@ -99,15 +101,15 @@ module Metanorma
|
|
99
101
|
pubclass = pub_class(bib)
|
100
102
|
num = bib&.at("./docnumber")&.text
|
101
103
|
id = bib&.at("./docidentifier[@primary]") ||
|
102
|
-
bib&.at("./docidentifier[not(#{
|
104
|
+
bib&.at("./docidentifier[not(#{skip_docid} or @type = 'metanorma')]")
|
103
105
|
metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
|
104
106
|
abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
|
105
107
|
/\d-(?<partid>\d+)/ =~ id&.text
|
106
108
|
type = id["type"] if id
|
107
109
|
title = bib&.at("./title[@type = 'main']")&.text ||
|
108
110
|
bib&.at("./title")&.text || bib&.at("./formattedref")&.text
|
109
|
-
"#{pubclass} :: #{type} :: "\
|
110
|
-
"#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: "\
|
111
|
+
"#{pubclass} :: #{type} :: " \
|
112
|
+
"#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: " \
|
111
113
|
"#{sprintf('%09d', partid.to_i)} :: #{id&.text} :: #{title}"
|
112
114
|
end
|
113
115
|
|
@@ -148,7 +150,7 @@ module Metanorma
|
|
148
150
|
end
|
149
151
|
|
150
152
|
def unpublished_note(xmldoc)
|
151
|
-
xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]"\
|
153
|
+
xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]" \
|
152
154
|
"[not(note[@type = 'Unpublished-Status'])]").each do |b|
|
153
155
|
next if pub_class(b) > 2
|
154
156
|
next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
|
@@ -179,7 +181,7 @@ module Metanorma
|
|
179
181
|
|
180
182
|
def replacement_standard(biblio)
|
181
183
|
r = biblio.at("./relation[@type = 'updates']/bibitem") or return nil
|
182
|
-
id = r.at("./formattedref | ./docidentifier[@primary = 'true'] | "\
|
184
|
+
id = r.at("./formattedref | ./docidentifier[@primary = 'true'] | " \
|
183
185
|
"./docidentifier | ./formattedref") or return nil
|
184
186
|
id.text
|
185
187
|
end
|
@@ -234,7 +236,7 @@ module Metanorma
|
|
234
236
|
end
|
235
237
|
|
236
238
|
def extract_publishers(xmldoc)
|
237
|
-
xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/"\
|
239
|
+
xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/" \
|
238
240
|
"organization").each_with_object([]) do |p, m|
|
239
241
|
x = p.at("./abbreviation") || p.at("./name") or next
|
240
242
|
m << x.text
|
data/lib/metanorma/iso/front.rb
CHANGED
@@ -12,12 +12,27 @@ module Metanorma
|
|
12
12
|
def metadata_ext(node, xml)
|
13
13
|
super
|
14
14
|
structured_id(node, xml)
|
15
|
-
|
16
|
-
|
15
|
+
id = iso_id_default(iso_id_params(node))
|
16
|
+
id.stage and
|
17
|
+
xml.stagename metadata_stagename(id)&.strip,
|
18
|
+
**attr_code(abbreviation: id.typed_stage_abbrev&.strip)
|
17
19
|
@amd && a = node.attr("updates-document-type") and
|
18
20
|
xml.updates_document_type a
|
19
21
|
end
|
20
22
|
|
23
|
+
def metadata_stagename(id)
|
24
|
+
if @amd
|
25
|
+
id.amendments&.first&.stage&.name ||
|
26
|
+
id.corrigendums&.first&.stage&.name
|
27
|
+
else
|
28
|
+
begin
|
29
|
+
id.typed_stage_name
|
30
|
+
rescue StandardError
|
31
|
+
id.stage&.name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
21
36
|
def metadata_subdoctype(node, xml)
|
22
37
|
super
|
23
38
|
a = node.attr("horizontal") and xml.horizontal a
|
@@ -32,7 +47,7 @@ module Metanorma
|
|
32
47
|
publishers = node.attr("publisher") || "ISO"
|
33
48
|
csv_split(publishers).each do |p|
|
34
49
|
xml.contributor do |c|
|
35
|
-
c.role
|
50
|
+
c.role type: "author"
|
36
51
|
c.organization do |a|
|
37
52
|
organization(a, p, false, node, !node.attr("publisher"))
|
38
53
|
end
|
@@ -44,7 +59,7 @@ module Metanorma
|
|
44
59
|
publishers = node.attr("publisher") || "ISO"
|
45
60
|
csv_split(publishers).each do |p|
|
46
61
|
xml.contributor do |c|
|
47
|
-
c.role
|
62
|
+
c.role type: "publisher"
|
48
63
|
c.organization do |a|
|
49
64
|
organization(a, p, true, node, !node.attr("publisher"))
|
50
65
|
end
|
@@ -73,8 +88,9 @@ module Metanorma
|
|
73
88
|
def metadata_status(node, xml)
|
74
89
|
stage = get_stage(node)
|
75
90
|
substage = get_substage(node)
|
91
|
+
abbrev = iso_id_default(iso_id_params(node)).stage&.abbr
|
76
92
|
xml.status do |s|
|
77
|
-
s.stage stage, **attr_code(abbreviation:
|
93
|
+
s.stage stage, **attr_code(abbreviation: abbrev)
|
78
94
|
s.substage substage
|
79
95
|
node.attr("iteration") && (s.iteration node.attr("iteration"))
|
80
96
|
end
|