metanorma-iso 3.1.1 → 3.1.3

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.
@@ -23,32 +23,26 @@ module IsoDoc
23
23
 
24
24
  def docstatus(isoxml, _out)
25
25
  docstatus = isoxml.at(ns("//bibdata/status/stage"))
26
- set(:unpublished, false)
26
+ published = published_default(isoxml)
27
27
  revdate = isoxml.at(ns("//bibdata/version/revision-date"))
28
28
  set(:revdate, revdate&.text)
29
- docstatus and docstatus1(isoxml, docstatus)
29
+ docstatus and docstatus1(isoxml, docstatus, published)
30
30
  docscheme = isoxml.at(ns("//presentation-metadata[name" \
31
31
  "[text() = 'document-scheme']]/value"))
32
32
  docscheme and set(:document_scheme, docscheme.text)
33
33
  end
34
34
 
35
- def docstatus1(isoxml, docstatus)
35
+ def docstatus1(isoxml, docstatus, published)
36
36
  set(:stage, docstatus.text)
37
37
  set(:stage_int, docstatus.text.to_i)
38
38
  set(:substage_int, isoxml.at(ns("//bibdata/status/substage"))&.text)
39
- set(:unpublished, unpublished(docstatus.text))
40
39
  set(:statusabbr,
41
40
  status_abbrev(docstatus["abbreviation"] || "??",
42
41
  isoxml.at(ns("//bibdata/status/substage"))&.text,
43
42
  isoxml.at(ns("//bibdata/status/iteration"))&.text,
44
43
  isoxml.at(ns("//bibdata/version/draft"))&.text,
45
44
  isoxml.at(ns("//bibdata/ext/doctype"))&.text))
46
- unpublished(docstatus.text) and
47
- set(:stageabbr, docstatus["abbreviation"])
48
- end
49
-
50
- def unpublished(status)
51
- status.to_i.positive? && status.to_i < 60
45
+ !published and set(:stageabbr, docstatus["abbreviation"])
52
46
  end
53
47
 
54
48
  def docid(isoxml, _out)
@@ -73,7 +67,7 @@ module IsoDoc
73
67
 
74
68
  def part_title(part, titlenums, lang)
75
69
  part or return ""
76
- suffix = part.children.to_xml
70
+ suffix = to_xml(part.children)
77
71
  p = titlenums[:part]
78
72
  titlenums[:part] && titlenums[:subpart] and
79
73
  p = "#{titlenums[:part]}&#x2013;#{titlenums[:subpart]}"
@@ -102,11 +96,11 @@ module IsoDoc
102
96
  end
103
97
 
104
98
  def compose_title(tparts, tnums, lang)
105
- t = tparts[:main].nil? ? "" : tparts[:main].children.to_xml
99
+ t = tparts[:main].nil? ? "" : to_xml(tparts[:main].children)
106
100
  tparts[:intro] and
107
- t = "#{tparts[:intro].children.to_xml}&#xa0;&#x2014; #{t}"
101
+ t = "#{to_xml(tparts[:intro].children)}&#xa0;&#x2014; #{t}"
108
102
  tparts[:complementary] and
109
- t = "#{t}&#xa0;&#x2014; #{tparts[:complementary].children.to_xml}"
103
+ t = "#{t}&#xa0;&#x2014; #{to_xml(tparts[:complementary].children)}"
110
104
  if tparts[:part]
111
105
  suffix = part_title(tparts[:part], tnums, lang)
112
106
  t = "#{t}&#xa0;&#x2014; #{suffix}"
@@ -138,19 +132,19 @@ module IsoDoc
138
132
  # intro, main, complementary, part, amd = title_parts(isoxml, lang)
139
133
  tp = title_parts(isoxml, lang)
140
134
  tn = title_nums(isoxml)
141
- set(:doctitlemain, tp[:main] ? tp[:main].children.to_xml : "")
135
+ set(:doctitlemain, tp[:main] ? to_xml(tp[:main].children) : "")
142
136
  main = compose_title(tp, tn, lang)
143
137
  set(:doctitle, main)
144
- tp[:intro] and set(:doctitleintro, tp[:intro].children.to_xml)
138
+ tp[:intro] and set(:doctitleintro, to_xml(tp[:intro].children))
145
139
  tp[:complementary] and
146
- set(:doctitlecomplementary, tp[:complementary].children.to_xml)
140
+ set(:doctitlecomplementary, to_xml(tp[:complementary].children))
147
141
  set(:doctitlepartlabel, part_prefix(tn, lang))
148
- set(:doctitlepart, tp[:part].children.to_xml) if tp[:part]
142
+ set(:doctitlepart, to_xml(tp[:part].children)) if tp[:part]
149
143
  set(:doctitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
150
- set(:doctitleamd, tp[:amd].children.to_xml) if tp[:amd]
144
+ set(:doctitleamd, to_xml(tp[:amd].children)) if tp[:amd]
151
145
  set(:doctitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
152
146
  set(:doctitleaddlabel, add_prefix(tn, lang)) if tn[:add]
153
- set(:doctitleadd, tp[:add].children.to_xml) if tp[:add]
147
+ set(:doctitleadd, to_xml(tp[:add].children)) if tp[:add]
154
148
  end
155
149
 
156
150
  def subtitle(isoxml, _out)
@@ -158,18 +152,18 @@ module IsoDoc
158
152
  tp = title_parts(isoxml, lang)
159
153
  tn = title_nums(isoxml)
160
154
 
161
- set(:docsubtitlemain, tp[:main] ? tp[:main].children.to_xml : "")
155
+ set(:docsubtitlemain, tp[:main] ? to_xml(tp[:main].children) : "")
162
156
  main = compose_title(tp, tn, lang)
163
157
  set(:docsubtitle, main)
164
- tp[:intro] and set(:docsubtitleintro, tp[:intro].children.to_xml)
158
+ tp[:intro] and set(:docsubtitleintro, to_xml(tp[:intro].children))
165
159
  tp[:complementary] and
166
- set(:docsubtitlecomplementary, tp[:complementary].children.to_xml)
160
+ set(:docsubtitlecomplementary, to_xml(tp[:complementary].children))
167
161
  set(:docsubtitlepartlabel, part_prefix(tn, lang))
168
- tp[:part] and set(:docsubtitlepart, tp[:part].children.to_xml)
162
+ tp[:part] and set(:docsubtitlepart, to_xml(tp[:part].children))
169
163
  set(:docsubtitleamdlabel, amd_prefix(tn, lang)) if tn[:amd]
170
- set(:docsubtitleamd, tp[:amd].children.to_xml) if tp[:amd]
164
+ set(:docsubtitleamd, to_xml(tp[:amd].children)) if tp[:amd]
171
165
  set(:docsubtitleaddlabel, add_prefix(tn, lang)) if tn[:add]
172
- set(:docsubtitleadd, tp[:add].children.to_xml) if tp[:add]
166
+ set(:docsubtitleadd, to_xml(tp[:add].children)) if tp[:add]
173
167
  set(:docsubtitlecorrlabel, corr_prefix(tn, lang)) if tn[:corr]
174
168
  end
175
169
 
@@ -187,13 +181,13 @@ module IsoDoc
187
181
  set(:tc, tcid)
188
182
  end
189
183
 
184
+ COMMITTEE = "//bibdata/contributor[role/@type = 'author'] " \
185
+ "[role/description = 'committee']/organization".freeze
186
+
190
187
  def tc_base(xml, grouptype)
191
- tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/" \
192
- "technical-committee/@number")) or return nil
193
- tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/" \
194
- "@type"))&.text || "TC"
195
- tc_type == "Other" and tc_type = ""
196
- "#{tc_type} #{tc_num.text}".strip
188
+ s = xml.at(ns("#{COMMITTEE}/subdivision[@type = 'Technical committee']"))
189
+ s or return nil
190
+ s.at(ns("./identifier[not(@type = 'full')]"))&.text
197
191
  end
198
192
 
199
193
  def sc(xml)
@@ -202,12 +196,9 @@ module IsoDoc
202
196
  end
203
197
 
204
198
  def sc_base(xml, grouptype)
205
- sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
206
- "@number")) or return nil
207
- sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
208
- "@type"))&.text || "SC"
209
- sc_type == "Other" and sc_type = ""
210
- "#{sc_type} #{sc_num.text}"
199
+ s = xml.at(ns("#{COMMITTEE}/subdivision[@type = 'Subcommittee']"))
200
+ s or return nil
201
+ s.at(ns("./identifier[not(@type = 'full')]"))&.text
211
202
  end
212
203
 
213
204
  def wg(xml)
@@ -216,23 +207,27 @@ module IsoDoc
216
207
  end
217
208
 
218
209
  def wg_base(xml, grouptype)
219
- wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
220
- "@number")) or return
221
- wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
222
- "@type"))&.text || "WG"
223
- wg_type == "Other" and wg_type = ""
224
- "#{wg_type} #{wg_num.text}"
210
+ s = xml.at(ns("#{COMMITTEE}/subdivision[@type = 'Workgroup']"))
211
+ s or return nil
212
+ s.at(ns("./identifier[not(@type = 'full')]"))&.text
225
213
  end
226
214
 
227
215
  def editorialgroup(xml)
228
- a = xml.at(ns("//bibdata/ext/editorialgroup/@identifier")) and
229
- set(:editorialgroup, a.text)
230
- a = xml.at(ns("//bibdata/ext/approvalgroup/@identifier")) and
231
- set(:approvalgroup, a.text)
216
+ xpath = "#{COMMITTEE}/subdivision/identifier[@type = 'full']"
217
+ a = xml.xpath(ns(xpath))
218
+ a.empty? or set(:editorialgroup,
219
+ connectives_strip(@i18n.boolean_conj(a.map(&:text),
220
+ "and")))
221
+ a = xml.xpath(ns(xpath.sub("author", "authorizer")))
222
+ a.empty? or set(:approvalgroup,
223
+ connectives_strip(@i18n.boolean_conj(a.map(&:text),
224
+ "and")))
232
225
  end
233
226
 
234
227
  def secretariat(xml)
235
- sec = xml.at(ns("//bibdata/ext/editorialgroup/secretariat"))
228
+ sec = xml.at(ns("//bibdata/contributor[role/@type = 'author']" \
229
+ "[role/description = 'secretariat']/organization/subdivision" \
230
+ "[@type = 'Secretariat']/name"))
236
231
  set(:secretariat, sec.text) if sec
237
232
  end
238
233
 
@@ -1,35 +1,6 @@
1
1
  module IsoDoc
2
2
  module Iso
3
3
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
- def bibdata(docxml)
5
- super
6
- editorialgroup_identifier(docxml)
7
- end
8
-
9
- def editorialgroup_identifier(docxml)
10
- %w(editorialgroup approvalgroup).each do |v|
11
- docxml.xpath(ns("//bibdata/ext/#{v}")).each do |a|
12
- editorialgroup_identifier1(a)
13
- end
14
- end
15
- end
16
-
17
- def editorialgroup_identifier1(group)
18
- agency = group.xpath(ns("./agency"))&.map(&:text)
19
- ret = %w(technical-committee subcommittee workgroup)
20
- .each_with_object([]) do |v, m|
21
- m << editorialgroup_identifier2(group, v)
22
- end
23
- group["identifier"] = (agency + ret.compact).join("/")
24
- end
25
-
26
- def editorialgroup_identifier2(group, level)
27
- a = group.at(ns("./#{level}")) or return nil
28
- type = a["type"]
29
- type&.casecmp("other")&.zero? and type = ""
30
- "#{type} #{a['number']}".strip
31
- end
32
-
33
4
  def bibdata_i18n(bib)
34
5
  hash_translate(bib, @i18n.get["doctype_dict"], "./ext/doctype",
35
6
  "//presentation-metadata/doctype-alias", @lang)
@@ -37,6 +8,8 @@ module IsoDoc
37
8
  bib.at(ns("./ext/doctype")))
38
9
  hash_translate(bib, @i18n.get["substage_dict"],
39
10
  "./status/substage", nil, @lang)
11
+ hash_translate(bib, @i18n.get["contributor_role_desc_dict"],
12
+ "./contributor/role/description", nil, @lang)
40
13
  edition_translate(bib)
41
14
  end
42
15
 
@@ -15,9 +15,9 @@ module IsoDoc
15
15
 
16
16
  def warning_for_missing_metadata_create(docxml)
17
17
  ret = ""
18
- docxml.at(ns("//bibdata/ext//secretariat")) or
18
+ docxml.at(ns("//bibdata//contributor/role[description = 'secretariat']")) or
19
19
  ret += "<p>Secretariat is missing.</p>"
20
- docxml.at(ns("//bibdata/ext//editorialgroup")) or
20
+ docxml.at(ns("//bibdata//contributor/role[description = 'committee']")) or
21
21
  ret += "<p>Editorial groups are missing.</p>"
22
22
  docxml.at(ns("//bibdata/date[@type = 'published' or @type = 'issued' " \
23
23
  "or @type = 'created']")) ||
@@ -1291,13 +1291,13 @@ Restricted recursively to contain only other such inline elements with no identi
1291
1291
  <ref name="pure_strike"/>
1292
1292
  <ref name="pure_smallcap"/>
1293
1293
  <ref name="br"/>
1294
+ <ref name="stem"/>
1294
1295
  </choice>
1295
1296
  </define>
1296
1297
  <define name="NestedTextElement">
1297
1298
  <a:documentation>Contents of TextElement tags: leaves out tags that should occur only at top level of block: bookmark image hr pagebreak</a:documentation>
1298
1299
  <choice>
1299
1300
  <ref name="PureTextElement"/>
1300
- <ref name="stem"/>
1301
1301
  <ref name="eref"/>
1302
1302
  <ref name="xref"/>
1303
1303
  <ref name="hyperlink"/>
@@ -76,12 +76,6 @@ from other documents in the same doctype</a:documentation>
76
76
  <ref name="flavor">
77
77
  <a:documentation>Flavour of Metanorma used to process this document</a:documentation>
78
78
  </ref>
79
- <optional>
80
- <ref name="editorialgroup">
81
- <a:documentation>Groups associated with the production of the standards document, typically within
82
- a standards definition organization</a:documentation>
83
- </ref>
84
- </optional>
85
79
  <zeroOrMore>
86
80
  <ref name="ics">
87
81
  <a:documentation>Classification of the document contents taken from the International Classification of Standards</a:documentation>
@@ -130,49 +124,6 @@ a standards definition organization</a:documentation>
130
124
  However we prefer not to hardcode it, given ongoing extension.</a:documentation>
131
125
  <text/>
132
126
  </define>
133
- <define name="editorialgroup">
134
- <a:documentation>A group associated with the production of the standards document, typically within
135
- a standards definition organization</a:documentation>
136
- <element name="editorialgroup">
137
- <oneOrMore>
138
- <ref name="technical-committee">
139
- <a:documentation>A technical committee associated with the production of the standards document</a:documentation>
140
- </ref>
141
- </oneOrMore>
142
- </element>
143
- </define>
144
- <define name="technical-committee">
145
- <a:documentation>Technical committee associated with the production of a standards document</a:documentation>
146
- <element name="technical-committee">
147
- <ref name="IsoWorkgroup"/>
148
- </element>
149
- </define>
150
- <define name="IsoWorkgroup">
151
- <optional>
152
- <attribute name="number">
153
- <a:documentation>Numeric identifier of the technical committee</a:documentation>
154
- </attribute>
155
- </optional>
156
- <optional>
157
- <attribute name="type">
158
- <a:documentation>Type of the technical committee, used in identifying the technical committee</a:documentation>
159
- </attribute>
160
- </optional>
161
- <optional>
162
- <attribute name="identifier">
163
- <a:documentation>Non-numeric, complete identifier of the technical committee</a:documentation>
164
- </attribute>
165
- </optional>
166
- <optional>
167
- <attribute name="prefix">
168
- <a:documentation>Disambiguating prefix added to number to form the identifier of the technical committee,
169
- typically indicating its type</a:documentation>
170
- </attribute>
171
- </optional>
172
- <text>
173
- <a:documentation>Name of the technical committee</a:documentation>
174
- </text>
175
- </define>
176
127
  <define name="ics">
177
128
  <a:documentation>Classification taken from the International Classification of Standards.
178
129
  ICS is defined by ISO here -- https://www.iso.org/publication/PUB100033.html</a:documentation>
@@ -242,6 +242,8 @@ Detailed in https://www.relaton.org/model/creator/</a:documentation>
242
242
  </choice>
243
243
  </define>
244
244
  <define name="roledescription">
245
+ <a:documentation>A more detailed description of the role of the contributor
246
+ Some descriptions are reserved words; in particular, the editorial committee of a standard has the role description "committee"</a:documentation>
245
247
  <element name="description">
246
248
  <ref name="LocalizedMarkedUpString"/>
247
249
  </element>
@@ -443,7 +445,10 @@ real names (if the person is named with a pseudonym or user name); previous lega
443
445
  </oneOrMore>
444
446
  <zeroOrMore>
445
447
  <ref name="subdivision">
446
- <a:documentation>The subdivision of the organization directly involved with the production of the bibliographic item</a:documentation>
448
+ <a:documentation>The subdivision of the organization directly involved with the production of the bibliographic item.
449
+ Multiple subdivisions can be specified for an organization, with no implication of hierarchical
450
+ relation between them
451
+ Editorial and advisory groups are represented as consecutive subdivisions of the SDO</a:documentation>
447
452
  </ref>
448
453
  </zeroOrMore>
449
454
  <optional>
@@ -485,6 +490,11 @@ real names (if the person is named with a pseudonym or user name); previous lega
485
490
  <a:documentation>The type of subdivision</a:documentation>
486
491
  </attribute>
487
492
  </optional>
493
+ <optional>
494
+ <attribute name="subtype">
495
+ <a:documentation>The subtype of subdivision; e.g. different types of technical committee</a:documentation>
496
+ </attribute>
497
+ </optional>
488
498
  <ref name="OrganizationType">
489
499
  <a:documentation>The subdivision, modelled recursively as an organization</a:documentation>
490
500
  </ref>
@@ -100,30 +100,6 @@ module Metanorma
100
100
  super
101
101
  end
102
102
 
103
- def bibdata_cleanup(xmldoc)
104
- super
105
- approval_groups_rename(xmldoc)
106
- editorial_groups_agency(xmldoc)
107
- editorial_group_types(xmldoc)
108
- end
109
-
110
- def approval_groups_rename(xmldoc)
111
- %w(technical-committee subcommittee workgroup).each do |v|
112
- xmldoc.xpath("//bibdata//approval-#{v}").each { |a| a.name = v }
113
- end
114
- end
115
-
116
- def editorial_groups_agency(xmldoc)
117
- pubs = extract_publishers(xmldoc)
118
- xmldoc.xpath("//bibdata/ext/editorialgroup").each do |e|
119
- pubs.reverse_each do |p|
120
- if e.children.empty? then e << "<agency>#{p}</agency>"
121
- else e.children.first.previous = "<agency>#{p}</agency>"
122
- end
123
- end
124
- end
125
- end
126
-
127
103
  def extract_publishers(xmldoc)
128
104
  xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/" \
129
105
  "organization").each_with_object([]) do |p, m|
@@ -132,25 +108,34 @@ module Metanorma
132
108
  end
133
109
  end
134
110
 
111
+ def termdef_boilerplate_insert_locationx(xmldoc)
112
+ f = xmldoc.at(self.class::TERM_CLAUSE)
113
+ root = xmldoc.at("//sections/terms | //sections/clause[.//terms]")
114
+ !f || !root and return f || root
115
+ f.at("./preceding-sibling::clause") and return root
116
+ f
117
+ end
118
+
119
+ def published?(status, _xmldoc)
120
+ status.to_i.positive? && status.to_i >= 60
121
+ end
122
+
123
+ def bibdata_cleanup(xmldoc)
124
+ super
125
+ editorial_group_types(xmldoc)
126
+ end
127
+
135
128
  DEFAULT_EDGROUP_TYPE = { "technical-committee": "TC",
136
129
  subcommittee: "SC", workgroup: "WG" }.freeze
137
130
 
138
131
  def editorial_group_types(xmldoc)
139
132
  %w(technical-committee subcommittee workgroup).each do |v|
140
- xmldoc.xpath("//bibdata//#{v} | //bibdata//approval-#{v}").each do |g|
141
- g["type"] and next
142
- g["type"] = DEFAULT_EDGROUP_TYPE[v.to_sym]
133
+ v1 = v.sub("-", " ").capitalize
134
+ xmldoc.xpath("//bibdata//subdivision[@type = '#{v1}']").each do |g|
135
+ g["subtype"] ||= DEFAULT_EDGROUP_TYPE[v.to_sym]
143
136
  end
144
137
  end
145
138
  end
146
-
147
- def termdef_boilerplate_insert_locationx(xmldoc)
148
- f = xmldoc.at(self.class::TERM_CLAUSE)
149
- root = xmldoc.at("//sections/terms | //sections/clause[.//terms]")
150
- !f || !root and return f || root
151
- f.at("./preceding-sibling::clause") and return root
152
- f
153
- end
154
139
  end
155
140
  end
156
141
  end
@@ -1,42 +1,72 @@
1
1
  module Metanorma
2
2
  module Iso
3
3
  class Converter < Standoc::Converter
4
- # def home_agency
5
- # "ISO"
6
- # end
7
-
8
4
  def default_publisher
9
5
  "ISO"
10
6
  end
11
7
 
12
8
  def org_abbrev
13
9
  { "International Organization for Standardization" => "ISO",
14
- "International Electrotechnical Commission" => "IEC" }
10
+ "International Electrotechnical Commission" => "IEC",
11
+ "International Organization for Standardization, International Electrotechnical Commission" => "ISO/IEC" }
15
12
  end
16
13
 
17
14
  def metadata_author(node, xml)
18
15
  org_contributor(node, xml,
19
16
  { source: ["publisher", "pub"], role: "author",
20
17
  default: default_publisher })
21
- committee_contributors(node, xml, false, default_publisher)
18
+ committee_contributors(node, xml, default_publisher,
19
+ { approval: false })
20
+ secretariat_contributor(node, xml, default_publisher)
22
21
  end
23
22
 
24
23
  def org_organization(node, xml, org)
25
- org[:committee] and
26
- contrib_committee_build(xml, org[:agency], org) or
27
- super
24
+ if org[:committee]
25
+ contrib_committee_build(xml, org[:agency], org)
26
+ else super
27
+ end
28
+ end
29
+
30
+ def secretariat_contributor(node, xml, agency)
31
+ node.attr("secretariat") or return
32
+ o = committee_contrib_org_prep(node, "secretariat", agency, {})
33
+ o[:desc] = "secretariat"
34
+ org_contributor(node, xml, o)
28
35
  end
29
36
 
30
- def committee_contributors(node, xml, approval, agency)
31
- metadata_approval_committee_types(approval ? node : nil).each do |v|
32
- node.attr("#{v}-number") or next
37
+ def committee_contributors(node, xml, agency, opt)
38
+ t = metadata_approval_committee_types(opt[:approval] ? node : nil)
39
+ v = t.first
40
+ if committee_number_or_name?(node, v, "")
33
41
  node.attr(v) or node.set_attr(v, "")
34
- o = { source: [v], role: approval ? "authorizer" : "author",
35
- default_org: false, committee: true, agency:,
36
- desc: v.sub(/^approval-/, "").tr("-", " ").capitalize }
42
+ o = committee_contrib_org_prep(node, v, agency, opt)
43
+ o[:groups] = t
44
+ o[:approval] = opt[:approval]
37
45
  org_contributor(node, xml, o)
38
46
  end
39
- approval or committee_contributors_approval(node, xml, agency)
47
+ opt[:approval] or committee_contributors_approval(node, xml, agency)
48
+ end
49
+
50
+ def committee_contrib_org_prep(node, type, agency, opt)
51
+ agency_arr, agency_abbrev =
52
+ committee_org_prep_agency(node, type, agency, [], [])
53
+ { source: [type], role: opt[:approval] ? "authorizer" : "author",
54
+ default_org: false, committee: true, agency: agency_arr,
55
+ agency_abbrev:, desc: "committee",
56
+ subdivtype: type.sub(/^approval-/, "").tr("-", " ").capitalize }
57
+ .compact
58
+ end
59
+
60
+ def committee_org_prep_agency(node, type, agency, agency_arr, agency_abbr)
61
+ i = 1
62
+ suffix = ""
63
+ while committee_number_or_name?(node, type, suffix)
64
+ agency_arr << (node.attr("#{type}-agency#{suffix}") || agency)
65
+ agency_abbr << node.attr("#{type}-agency-abbr#{suffix}")
66
+ i += 1
67
+ suffix = "_#{i}"
68
+ end
69
+ [agency_arr, agency_abbr]
40
70
  end
41
71
 
42
72
  def committee_contributors_approval(node, xml, agency)
@@ -45,69 +75,31 @@ module Metanorma
45
75
  org_contributor(node, xml, o)
46
76
  end
47
77
 
48
- def extract_org_attrs_complex(node, opts, source, suffix)
49
- n = node.attr("#{source}-number#{suffix}")
50
- t = committee_abbrev(node.attr("#{source}-type#{suffix}"), n, source)
51
- super.merge(ident: t).compact
52
- end
53
-
54
- def contrib_committee_build(xml, agency, committee)
55
- name = org_abbrev.invert[agency] and agency = name
56
- xml.name agency
57
- xml.subdivision do |o|
58
- o.name committee[:name]
59
- committee[:abbr] and o.abbreviation committee[:abbr]
60
- committee[:ident] and o.identifier committee[:ident]
61
- end
62
- end
63
-
64
- COMMITTEE_ABBREVS =
78
+ def committee_abbrevs
65
79
  { "technical-committee" => "TC", "subcommittee" => "SC",
66
- "workgroup" => "WG" }.freeze
80
+ "workgroup" => "WG" }
81
+ end
67
82
 
68
- def committee_abbrev(type, number, level)
69
- type ||= COMMITTEE_ABBREVS[level.sub(/^approval-/, "")]
83
+ def committee_ident(type, number, level)
84
+ number.nil? || number.empty? and return
85
+ type ||= committee_abbrevs[level.sub(/^approval-/, "")]
70
86
  type == "Other" and type = ""
71
87
  "#{type} #{number}".strip
72
88
  end
73
89
 
74
- def org_attrs_parse(node, opts)
75
- super&.map do |x|
76
- x.merge(agency: opts[:agency], abbr: opts[:abbr],
77
- committee: opts[:committee], default_org: opts[:default_org])
78
- end
90
+ def contributors_committees_filter_empty?(committee)
91
+ committee[:name].empty? &&
92
+ (committee[:ident].nil? || %w(WG TC
93
+ SC).include?(committee[:ident]))
79
94
  end
80
95
 
81
96
  def metadata_publisher(node, xml)
82
97
  super
83
98
  # approvals
84
- committee_contributors(node, xml, true,
85
- node.attr("approval-agency") || default_publisher)
86
- end
87
-
88
- def metadata_committee(node, xml)
89
- metadata_editorial_committee(node, xml)
90
- metadata_approval_committee(node, xml)
91
- end
92
-
93
- def metadata_editorial_committee(node, xml)
94
- xml.editorialgroup do |a|
95
- %w(technical-committee subcommittee workgroup).each do |v|
96
- node.attr("#{v}-number") and committee_component(v, node, a)
97
- end
98
- node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
99
- end
100
- end
101
-
102
- def metadata_approval_committee(node, xml)
103
- types = metadata_approval_committee_types(node)
104
- xml.approvalgroup do |a|
105
- metadata_approval_agency(a, node.attr("approval-agency")
106
- &.split(%r{[/,;]}))
107
- types.each do |v|
108
- node.attr("#{v}-number") and committee_component(v, node, a)
109
- end
110
- end
99
+ committee_contributors(
100
+ node, xml,
101
+ node.attr("approval-agency") || default_publisher, { approval: true }
102
+ )
111
103
  end
112
104
 
113
105
  def metadata_approval_committee_types(node)
@@ -117,13 +109,6 @@ module Metanorma
117
109
  approval-workgroup)
118
110
  types
119
111
  end
120
-
121
- def metadata_approval_agency(xml, list)
122
- list = [default_publisher] if list.nil? || list.empty?
123
- list.each do |v|
124
- xml.agency v
125
- end
126
- end
127
112
  end
128
113
  end
129
114
  end