metanorma-ieee 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,7 @@ module IsoDoc
46
46
  officeholder_style(p)
47
47
  end
48
48
  officemember_style(docxml)
49
+ officeorgrep_style(docxml)
49
50
  three_column_officemembers(docxml
50
51
  .at("//div[@id = 'boilerplate-participants']"))
51
52
  end
@@ -53,9 +54,9 @@ module IsoDoc
53
54
  def officeholder_style(para)
54
55
  n = para.next_element
55
56
  p = para.previous_element
56
- n && n.name == "p" && n["type"] == "officeholder" and
57
+ n && n.name == "p" && n["type"] != "officeholder" and
57
58
  klass = "IEEEStdsNamesCtrCxSpLast"
58
- p && p.name == "p" && p["type"] == "officeholder" and
59
+ p && p.name == "p" && p["type"] != "officeholder" and
59
60
  klass = "IEEEStdsNamesCtrCxSpFirst"
60
61
  para["class"] = klass || "IEEEStdsNamesCtrCxSpMiddle"
61
62
  end
@@ -68,7 +69,8 @@ module IsoDoc
68
69
  BREAK
69
70
 
70
71
  def officemember_style(docxml)
71
- docxml.xpath("//p[@type = 'officemember']").each do |p|
72
+ docxml.xpath("//p[@type = 'officemember' or @type = 'officeorgmember']")
73
+ .each do |p|
72
74
  p["class"] = "IEEEStdsNamesList"
73
75
  end
74
76
  docxml.xpath("//p[@type = 'emeritus_sign']").each do |p|
@@ -76,6 +78,19 @@ module IsoDoc
76
78
  end
77
79
  end
78
80
 
81
+ def officeorgrep_style(docxml)
82
+ docxml.xpath("//p[@type = 'officeorgrepmemberhdr']").each do |p|
83
+ p["class"] = "IEEEStdsNamesList"
84
+ p["style"] =
85
+ "margin-bottom:6.0pt;tab-stops:right 432.0pt;"
86
+ end
87
+ docxml.xpath("//p[@type = 'officeorgrepmember']").each do |p|
88
+ p["class"] = "IEEEStdsNamesList"
89
+ p["style"] =
90
+ "margin-top:6.0pt;tab-stops:right dotted 432.0pt;"
91
+ end
92
+ end
93
+
79
94
  def three_column_officemembers(div)
80
95
  return unless div
81
96
 
@@ -85,6 +100,7 @@ module IsoDoc
85
100
 
86
101
  def three_column_officemembers_split(div)
87
102
  prev = false
103
+ div.xpath(".//div").each { |d| d.replace(d.children) }
88
104
  div.elements.each_with_object([[]]) do |e, m|
89
105
  member = e.name == "p" && e["type"] == "officemember"
90
106
  (prev == member and m[-1] << e.to_xml) or m << [e.to_xml]
@@ -12,6 +12,14 @@ module IsoDoc
12
12
  super
13
13
  end
14
14
 
15
+ def convert1(docxml, filename, dir)
16
+ doctype = docxml.at(ns("//bibdata/ext/doctype"))
17
+ if %w(amendment corrigendum).include?(doctype&.text)
18
+ @header = html_doc_path("header_amd.html")
19
+ end
20
+ super
21
+ end
22
+
15
23
  def default_fonts(options)
16
24
  { bodyfont: (if options[:script] == "Hans"
17
25
  '"Source Han Sans",serif'
@@ -65,6 +73,10 @@ module IsoDoc
65
73
  def middle_title_ieee(_docxml, out)
66
74
  out.p(**{ class: "IEEEStdsTitle", style: "margin-top:70.0pt" }) do |p|
67
75
  p << @meta.get[:full_doctitle]
76
+ @meta.get[:amd] || @meta.get[:corr] and p << "<br/>"
77
+ @meta.get[:amd] and p << "Amendment #{@meta.get[:amd]}"
78
+ @meta.get[:amd] && @meta.get[:corr] and p << " "
79
+ @meta.get[:corr] and p << "Corrigenda #{@meta.get[:corr]}"
68
80
  end
69
81
  end
70
82
 
@@ -243,26 +243,61 @@
243
243
  </clause>
244
244
  <clause id="boilerplate-participants">
245
245
  <title>Participants</title>
246
+ <clause id="boilerplate-participants-wg">
246
247
  <p>At the time this draft {{ doctype }} was completed, the {{ working_group }} Working Group had the following membership:</p>
247
- <p align="center" type="officeholder"><strong>{{ wg_members["chair"] }}</strong>, <em>Chair</em></p>
248
- <p align="center" type="officeholder"><strong>{{ wg_members["vice-chair"] }}</strong>, <em>Vice Chair</em></p>
249
- {% if wg_members["secretary"] %}<p align="center" type="officeholder"><strong>{{ wg_members["secretary"] }}</strong>, <em>Secretary</em></p>{% endif %}
250
- {% for m in wg_members["members"] %}
251
- <p type="officemember">{{ m }}</p>
252
- {% endfor %}
253
- <p>The following members of the {{ balloting_group }} Standards Association balloting group voted on this {{ doctype }}. Balloters may have voted for approval, disapproval, or abstention.</p>
254
- {% for m in balloting_group_members %}
255
- <p type="officemember">{{ m }}</p>
256
- {% endfor %}
257
- <p>When the IEEE SA Standards Board approved this {{ doctype }} on {{ confirmed_date }}, it had the following membership:</p>
258
- <p align="center" type="officeholder"><strong>{{ std_board["chair"] }}</strong>, <em>Chair</em></p>
259
- <p align="center" type="officeholder"><strong>{{ std_board["vice-chair"] }}</strong>, <em>Vice Chair</em></p>
260
- <p align="center" type="officeholder"><strong>{{ std_board["past-chair"] }}</strong>, <em>Past Chair</em></p>
261
- <p align="center" type="officeholder"><strong>{{ std_board["secretary"] }}</strong>, <em>Secretary</em></p>
262
- {% for m in std_board["members"] %}
263
- <p type="officemember">{{ m }}</p>
264
- {% endfor %}
248
+ <membership>
249
+ <ul>
250
+ <li><dl><dt>name</dt><dd>&#x3c;Chair Name&#x3e;</dd><dt>role</dt><dd>Chair</dd></dl></li>
251
+ <li><dl><dt>name</dt><dd>&#x3c;Vice-chair Name&#x3e;</dd><dt>role</dt><dd>Vice Chair</dd></dl></li>
252
+ <li><dl><dt>name</dt><dd>Participant1</dd><dt>role</dt><dd>Member</dd></dl></li>
253
+ <li><dl><dt>name</dt><dd>Participant2</dd><dt>role</dt><dd>Member</dd></dl></li>
254
+ <li><dl><dt>name</dt><dd>Participant3</dd><dt>role</dt><dd>Member</dd></dl></li>
255
+ <li><dl><dt>name</dt><dd>Participant4</dd><dt>role</dt><dd>Member</dd></dl></li>
256
+ <li><dl><dt>name</dt><dd>Participant5</dd><dt>role</dt><dd>Member</dd></dl></li>
257
+ <li><dl><dt>name</dt><dd>Participant6</dd><dt>role</dt><dd>Member</dd></dl></li>
258
+ <li><dl><dt>name</dt><dd>Participant7</dd><dt>role</dt><dd>Member</dd></dl></li>
259
+ <li><dl><dt>name</dt><dd>Participant8</dd><dt>role</dt><dd>Member</dd></dl></li>
260
+ <li><dl><dt>name</dt><dd>Participant9</dd><dt>role</dt><dd>Member</dd></dl></li>
261
+ </ul>
262
+ </membership>
263
+ </clause>
264
+ <clause id="boilerplate-participants-bg">
265
+ <p>The following members of the {{ balloting_group_type }} {{ balloting_group }} Standards Association balloting group voted on this {{ doctype }}. Balloters may have voted for approval, disapproval, or abstention.</p>
266
+ <membership>
267
+ <ul>
268
+ <li><dl><dt>name</dt><dd>Balloter1</dd><dt>role</dt><dd>Member</dd></dl></li>
269
+ <li><dl><dt>name</dt><dd>Balloter2</dd><dt>role</dt><dd>Member</dd></dl></li>
270
+ <li><dl><dt>name</dt><dd>Balloter3</dd><dt>role</dt><dd>Member</dd></dl></li>
271
+ <li><dl><dt>name</dt><dd>Balloter4</dd><dt>role</dt><dd>Member</dd></dl></li>
272
+ <li><dl><dt>name</dt><dd>Balloter5</dd><dt>role</dt><dd>Member</dd></dl></li>
273
+ <li><dl><dt>name</dt><dd>Balloter6</dd><dt>role</dt><dd>Member</dd></dl></li>
274
+ <li><dl><dt>name</dt><dd>Balloter7</dd><dt>role</dt><dd>Member</dd></dl></li>
275
+ <li><dl><dt>name</dt><dd>Balloter8</dd><dt>role</dt><dd>Member</dd></dl></li>
276
+ <li><dl><dt>name</dt><dd>Balloter9</dd><dt>role</dt><dd>Member</dd></dl></li>
277
+ </ul>
278
+ </membership>
279
+ </clause>
280
+ <clause id="boilerplate-participants-sb">
281
+ <p>When the IEEE SA Standards Board approved this {{ doctype }} on {{ issueddate }}, it had the following membership:</p>
282
+ <membership>
283
+ <ul>
284
+ <li><dl><dt>name</dt><dd>&#x3c;Name&#x3e;</dd><dt>role</dt><dd>Chair</dd></dl></li>
285
+ <li><dl><dt>name</dt><dd>&#x3c;Name&#x3e;</dd><dt>role</dt><dd>Vice Chair</dd></dl></li>
286
+ <li><dl><dt>name</dt><dd>&#x3c;Name&#x3e;</dd><dt>role</dt><dd>Past Chair</dd></dl></li>
287
+ <li><dl><dt>name</dt><dd>&#x3c;Name&#x3e;</dd><dt>role</dt><dd>Secretary</dd></dl></li>
288
+ <li><dl><dt>name</dt><dd>SBMember1</dd><dt>role</dt><dd>Member</dd></dl></li>
289
+ <li><dl><dt>name</dt><dd>SBMember2</dd><dt>role</dt><dd>Member</dd></dl></li>
290
+ <li><dl><dt>name</dt><dd>SBMember3</dd><dt>role</dt><dd>Member</dd></dl></li>
291
+ <li><dl><dt>name</dt><dd>SBMember4</dd><dt>role</dt><dd>Member</dd></dl></li>
292
+ <li><dl><dt>name</dt><dd>SBMember5</dd><dt>role</dt><dd>Member</dd></dl></li>
293
+ <li><dl><dt>name</dt><dd>SBMember6</dd><dt>role</dt><dd>Member</dd></dl></li>
294
+ <li><dl><dt>name</dt><dd>SBMember7</dd><dt>role</dt><dd>Member</dd></dl></li>
295
+ <li><dl><dt>name</dt><dd>SBMember8</dd><dt>role</dt><dd>Member</dd></dl></li>
296
+ <li><dl><dt>name</dt><dd>SBMember9</dd><dt>role</dt><dd>Member</dd></dl></li>
297
+ </ul>
298
+ </membership>
265
299
  <p type="emeritus_sign">*Member Emeritus</p>
300
+ </clause>
266
301
  </clause>
267
302
  </legal-statement>
268
303
  <feedback-statement>
@@ -272,7 +307,7 @@
272
307
 
273
308
  <clause>
274
309
  <p>Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc.</p>
275
- <p>All rights reserved. Published {{ issued_date }}. Printed in the United States of America.</p>
310
+ <p>All rights reserved. Published {{ issueddate }}. Printed in the United States of America.</p>
276
311
  </clause>
277
312
 
278
313
  <clause>
@@ -294,5 +329,19 @@
294
329
  <em>No part of this publication may be reproduced in any form, in an electronic retrieval system or otherwise, without the prior written permission of the publisher.</em></p>
295
330
  </clause>
296
331
  </feedback-statement>
332
+ {% if docsubtype == "Amendment" or docsubtype == "Corrigendum" %}
333
+ <note id="boilerplate_front">
334
+ <p>The editing instructions contained in this {{ docsubtype | downcase }} define how to merge the material contained therein into the existing base standard and its amendments to form the comprehensive standard.</p>
335
+ <p>The editing instructions are shown in <strong><em>bold italic</em></strong>. Four editing instructions are used: change, delete, insert, and replace. <strong><em>Change</em></strong> is used to make corrections in existing text or tables. The editing instruction specifies the location of the change and describes what is being changed by using <strike>strikethrough</strike> (to remove old material) and <underline>underscore</underline> (to add new material). <strong><em>Delete</em></strong> removes existing material. <strong><em>Insert</em></strong> adds new material without disturbing the existing material. Insertions may require renumbering. If so, renumbering instructions are given in the editing instruction. <strong><em>Replace</em></strong> is used to make changes in figures or equations by removing the existing figure or equation and replacing it with a new one. Editing instructions, change markings, and this NOTE will not be carried over into future editions because the changes will be incorporated into the base standard.</p>
336
+ </note>
337
+ {% else %}
338
+ <clause id="boilerplate_word_usage">
339
+ <title>Word usage</title>
340
+ <p>The word <em>shall</em> indicates mandatory requirements strictly to be followed in order to conform to the standard and from which no deviation is permitted (<em>shall</em> equals <em>is required to</em>).<fn><p>The use of the word <em>must</em> is deprecated and cannot be used when stating mandatory requirements; <em>must</em> is used only to describe unavoidable situations.</p></fn><fn><p>The use of <em>will</em> is deprecated and cannot be used when stating mandatory requirements; <em>will</em> is only used in statements of fact.</p></fn></p>
341
+ <p>The word <em>should</em> indicates that among several possibilities one is recommended as particularly suitable, without mentioning or excluding others; or that a certain course of action is preferred but not necessarily required (<em>should</em> equals <em>is recommended that</em>).</p>
342
+ <p>The word <em>may</em> is used to indicate a course of action permissible within the limits of the standard (<em>may</em> equals <em>is permitted to</em>).</p>
343
+ <p>The word <em>can</em> is used for statements of possibility and capability, whether material, physical, or causal (<em>can</em> equals <em>is able to</em>).</p>
344
+ </clause>
345
+ {% endif %}
297
346
  </boilerplate>
298
347
 
@@ -1,11 +1,15 @@
1
1
  require_relative "cleanup_ref"
2
+ require_relative "term_lookup_cleanup"
2
3
 
3
4
  module Metanorma
4
5
  module IEEE
5
6
  class Converter < Standoc::Converter
6
7
  def initial_boilerplate(xml, isodoc)
7
8
  intro_boilerplate(xml, isodoc)
8
- super
9
+ super if @document_scheme == "ieee-sa-2021"
10
+ initial_note(xml)
11
+ word_usage(xml)
12
+ participants(xml)
9
13
  end
10
14
 
11
15
  def intro_boilerplate(xml, isodoc)
@@ -18,6 +22,24 @@ module Metanorma
18
22
  intro.next = "<admonition>#{adm}</admonition>"
19
23
  end
20
24
 
25
+ def initial_note(xml)
26
+ n = xml.at("//boilerplate//note[@id = 'boilerplate_front']")
27
+ s = xml.at("//sections")
28
+ (n && s) or return
29
+ s.children.empty? and s << " "
30
+ s.children.first.previous = n.remove
31
+ end
32
+
33
+ def word_usage(xml)
34
+ return unless @document_scheme == "ieee-sa-2021"
35
+
36
+ n = xml.at("//boilerplate//clause[@id = 'boilerplate_word_usage']")
37
+ &.remove
38
+ s = xml.at("//clause[@type = 'overview']")
39
+ (n && s) or return
40
+ s << n
41
+ end
42
+
21
43
  def obligations_cleanup_norm(xml)
22
44
  super
23
45
  xml.xpath("//sections/clause").each do |r|
@@ -53,39 +75,6 @@ module Metanorma
53
75
  ins << "<fn><p>#{@i18n.note_inform_fn}</p></fn>"
54
76
  end
55
77
 
56
- def termdef_cleanup(xmldoc)
57
- term_reorder(xmldoc)
58
- super
59
- end
60
-
61
- def term_reorder(xmldoc)
62
- xmldoc.xpath("//terms").each do |t|
63
- term_reorder1(t)
64
- end
65
- end
66
-
67
- def term_reorder1(terms)
68
- ins = terms.at("./term")&.previous_element or return
69
- coll = terms.xpath("./term")
70
- ret = sort_terms(coll)
71
- coll.each(&:remove)
72
- ret.reverse.each { |t| ins.next = t }
73
- end
74
-
75
- def sort_terms(terms)
76
- terms.sort do |a, b|
77
- sort_terms_key(a) <=> sort_terms_key(b)
78
- end
79
- end
80
-
81
- def sort_terms_key(term)
82
- d = term.at("./preferred/expression/name | "\
83
- "./preferred/letter-designation/name | "\
84
- "./preferred/graphical-symbol/figure/name | "\
85
- "./preferred/graphical-symbol/figure/@id")
86
- d.text.downcase
87
- end
88
-
89
78
  def table_footnote_renumber1(fnote, idx, seen)
90
79
  content = footnote_content(fnote)
91
80
  idx += 1
@@ -119,6 +108,118 @@ module Metanorma
119
108
  end
120
109
 
121
110
  def term_defs_boilerplate_cont(src, term, isodoc); end
111
+
112
+ def termlookup_cleanup(xmldoc)
113
+ Metanorma::IEEE::TermLookupCleanup.new(xmldoc, @log).call
114
+ end
115
+
116
+ def boilerplate_isodoc(xmldoc)
117
+ x = xmldoc.dup
118
+ x.root.add_namespace(nil, self.class::XML_NAMESPACE)
119
+ xml = Nokogiri::XML(x.to_xml)
120
+ i = isodoc(@lang, @script)
121
+ i.bibdata_i18n(xml.at("//xmlns:bibdata"))
122
+ i.info(xml, nil)
123
+ i
124
+ end
125
+
126
+ def participants(xml)
127
+ return unless @document_scheme == "ieee-sa-2021"
128
+
129
+ { "boilerplate-participants-wg": "working group",
130
+ "boilerplate-participants-bg": "balloting group",
131
+ "boilerplate-participants-sb": "standards board" }.each do |k, v|
132
+ populate_participants(xml, k.to_s, v)
133
+ end
134
+ p = xml.at(".//p[@type = 'emeritus_sign']")
135
+ ul = xml.at("//clause[@id = 'boilerplate-participants-sb']//ul")
136
+ p && ul and ul.next = p
137
+ xml.at("//clause[@type = 'participants']")&.remove
138
+ end
139
+
140
+ def populate_participants(xml, target, subtitle)
141
+ t = xml.at("//clause[@id = '#{target}']/membership")
142
+ s = xml.xpath("//clause[@type = 'participants']/clause").detect do |x|
143
+ n = x.at("./title") and n.text.strip.downcase == subtitle
144
+ end
145
+ t.replace(populate_participants1(s || t))
146
+ end
147
+
148
+ def populate_participants1(clause)
149
+ participants_dl_to_ul(clause)
150
+ clause.xpath(".//ul | .//ol").each do |ul|
151
+ ul.name = "ul"
152
+ ul.xpath("./li").each { |li| populate_participants2(li) }
153
+ ul.xpath(".//p[normalize-space() = '']").each(&:remove)
154
+ end
155
+ clause.children.to_xml
156
+ end
157
+
158
+ def participants_dl_to_ul(clause)
159
+ clause.xpath(".//dl").each do |dl|
160
+ next unless dl.ancestors("dl, ul, ol").empty?
161
+
162
+ dl.name = "ul"
163
+ dl.xpath("./dt").each(&:remove)
164
+ dl.xpath("./dd").each { |li| li.name = "li" }
165
+ end
166
+ end
167
+
168
+ def populate_participants2(list)
169
+ if dl = list.at("./dl")
170
+ ret = extract_participants(dl)
171
+ dl.children = ret.keys.map do |k|
172
+ "<dt>#{k}</dt><dd>#{ret[k]}</dd>"
173
+ end.join
174
+ else
175
+ list.children = "<dl><dt>name</dt><dd>#{list.children.to_xml}</dd>"\
176
+ "<dt>role</dt><dd>member</dd></dl>"
177
+ end
178
+ end
179
+
180
+ def extract_participants(dlist)
181
+ key = ""
182
+ map = dlist.xpath("./dt | ./dd").each_with_object({}) do |dtd, m|
183
+ (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) or
184
+ m[key.strip.downcase] =
185
+ @c.encode(@c.decode(dtd.text.strip), :hexadecimal)
186
+ end
187
+ map["role"] ||= "member"
188
+ map
189
+ end
190
+
191
+ def bibdata_cleanup(xmldoc)
192
+ super
193
+ provenance_title(xmldoc)
194
+ end
195
+
196
+ def provenance_title(xmldoc)
197
+ u = xmldoc.xpath("//bibdata/relation[@type = 'updates']")
198
+ m = xmldoc.xpath("//bibdata/relation[@type = 'merges']")
199
+ u.empty? and m.empty? and return
200
+ ins = xmldoc.at("//bibdata/title")
201
+ t = provenance_title1(u, m)
202
+ ins.next = "<title type='provenance' language='en' "\
203
+ "format='application/xml'>#{t}</title>"
204
+ end
205
+
206
+ def provenance_title1(updates, merges)
207
+ ret = ""
208
+ u = @isodoc.i18n.boolean_conj(tm_id_extract(updates), "and")
209
+ m = @isodoc.i18n.boolean_conj(tm_id_extract(merges), "and")
210
+ u.empty? or ret += "Revision of #{u}"
211
+ !u.empty? && !m.empty? and ret += "<br/>"
212
+ m.empty? or ret += "Incorporates #{m}"
213
+ ret
214
+ end
215
+
216
+ def tm_id_extract(relations)
217
+ relations.map do |u|
218
+ u.at("./bibitem/docidentifier[@scope = 'trademark']") ||
219
+ u.at("./bibitem/docidentifier[@primary = 'true']") ||
220
+ u.at("./bibitem/docidentifier")
221
+ end.map(&:text)
222
+ end
122
223
  end
123
224
  end
124
225
  end
@@ -34,6 +34,7 @@ module Metanorma
34
34
  name = designator_or_name(bib)
35
35
  title = bib.at("./title[@type = 'main']")&.text ||
36
36
  bib.at("./title")&.text || bib.at("./formattedref")&.text
37
+ title.gsub!(/[[:punct:]]/, "")
37
38
  "#{name}. #{title}"
38
39
  end
39
40
 
@@ -76,7 +77,7 @@ module Metanorma
76
77
  .each_with_object({}) do |b, m|
77
78
  n = b.at("./contributor[role/@type = 'publisher']/organization/name")
78
79
  n&.text == "Institute of Electrical and Electronics Engineers" and
79
- m[b["id"]] = true
80
+ m[b["id"]] = b.at("./docidentifier[@scope = 'trademark']")&.text
80
81
  end
81
82
  trademark_ieee_erefs1(xmldoc, "//preface//eref", ieee)
82
83
  trademark_ieee_erefs1(xmldoc, "//sections//eref | //annex//eref", ieee)
@@ -85,7 +86,7 @@ module Metanorma
85
86
  def trademark_ieee_erefs1(xmldoc, path, ieee)
86
87
  xmldoc.xpath(path).each_with_object({}) do |e, m|
87
88
  ieee[e["bibitemid"]] or next
88
- m[e["bibitemid"]] or e["citeas"] += "\u2122"
89
+ m[e["bibitemid"]] or e["citeas"] = ieee[e["bibitemid"]]
89
90
  m[e["bibitemid"]] = true
90
91
  end
91
92
  end
@@ -112,6 +113,14 @@ module Metanorma
112
113
  "<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
113
114
  end
114
115
  end
116
+
117
+ def select_docid(ref)
118
+ ret = super
119
+ if %w(standard techreport).include?(ref["type"]) then ret
120
+ else
121
+ ref.at("./docidentifier[@type = 'metanorma-ordinal']") || ret
122
+ end
123
+ end
115
124
  end
116
125
  end
117
126
  end
@@ -16,6 +16,7 @@ module Metanorma
16
16
 
17
17
  def init(node)
18
18
  super
19
+ @document_scheme ||= "ieee-sa-2021"
19
20
  @hierarchical_assets = node.attr("hierarchical-object-numbering")
20
21
  end
21
22
 
@@ -34,10 +35,17 @@ module Metanorma
34
35
  when "Overview" then attrs[:type] = "overview"
35
36
  when "Scope" then attrs[:type] = "scope"
36
37
  when "Word Usage" then attrs[:type] = "word-usage"
38
+ when "Participants" then attrs[:type] = "participants"
37
39
  end
38
40
  super
39
41
  end
40
42
 
43
+ def termsource_attrs(node, matched)
44
+ ret = super
45
+ node.option? "adapted" and ret[:status] = "adapted"
46
+ ret
47
+ end
48
+
41
49
  def outputs(node, ret)
42
50
  File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
43
51
  presentation_xml_converter(node).convert("#{@filename}.xml")
@@ -1,9 +1,14 @@
1
+ require "isoics"
2
+
1
3
  module Metanorma
2
4
  module IEEE
3
5
  class Converter < Standoc::Converter
4
6
  def metadata_committee(node, xml)
5
7
  return unless node.attr("committee") || node.attr("society")
6
8
 
9
+ node.attr("balloting-group") && !node.attr("balloting-group-type") and
10
+ node.set_attr("balloting-group-type", "individual")
11
+
7
12
  xml.editorialgroup do |a|
8
13
  committee_component("society", node, a)
9
14
  committee_component("balloting-group", node, a)
@@ -29,59 +34,6 @@ module Metanorma
29
34
  xml.docnumber node.attr("docnumber")
30
35
  end
31
36
 
32
- def metadata_author(node, xml)
33
- super
34
- wg_members(node, xml)
35
- bg_members(node, xml)
36
- std_board_members(node, xml)
37
- end
38
-
39
- def metadata_editor(name, role, xml)
40
- xml.contributor do |c|
41
- c.role role, **{ type: "editor" }
42
- c.person do |p|
43
- p.name do |n|
44
- n.completename name
45
- end
46
- end
47
- end
48
- end
49
-
50
- def metadata_multi_editors(names, role, xml)
51
- csv_split(names).each do |n|
52
- metadata_editor(n, role, xml)
53
- end
54
- end
55
-
56
- def wg_members(node, xml)
57
- a = node.attr("wg-chair") and
58
- metadata_editor(a, "Working Group Chair", xml)
59
- a = node.attr("wg-vicechair") and
60
- metadata_editor(a, "Working Group Vice-Chair", xml)
61
- a = node.attr("wg-secretary") and
62
- metadata_editor(a, "Working Group Secretary", xml)
63
- a = node.attr("wg-members") and
64
- metadata_multi_editors(a, "Working Group Member", xml)
65
- end
66
-
67
- def bg_members(node, xml)
68
- a = node.attr("balloting-group-members") and
69
- metadata_multi_editors(a, "Balloting Group Member", xml)
70
- end
71
-
72
- def std_board_members(node, xml)
73
- a = node.attr("std-board-chair") and
74
- metadata_editor(a, "Standards Board Chair", xml)
75
- a = node.attr("std-board-vicechair") and
76
- metadata_editor(a, "Standards Board Vice-Chair", xml)
77
- a = node.attr("std-board-pastchair") and
78
- metadata_editor(a, "Standards Board Past Chair", xml)
79
- a = node.attr("std-board-secretary") and
80
- metadata_editor(a, "Standards Board Secretary", xml)
81
- a = node.attr("balloting-group-members") and
82
- metadata_multi_editors(a, "Standards Board Member", xml)
83
- end
84
-
85
37
  def metadata_publisher(node, xml)
86
38
  publishers = node.attr("publisher") || "IEEE"
87
39
  csv_split(publishers).each do |p|
@@ -112,6 +64,23 @@ module Metanorma
112
64
  end
113
65
  end
114
66
 
67
+ def metadata_status(node, xml)
68
+ status = node.attr("status") || node.attr("docstage") ||
69
+ (node.attr("draft") ? "draft" : "approved")
70
+ xml.status do |s|
71
+ s.stage status
72
+ end
73
+ end
74
+
75
+ def datetypes
76
+ super + %w{feedback-ended}
77
+ end
78
+
79
+ def metadata_subdoctype(node, xml)
80
+ xml.subdoctype (node.attr("docsubtype") || "document")
81
+ s = node.attr("trial-use") and xml.trial_use s
82
+ end
83
+
115
84
  def org_abbrev
116
85
  { "Institute of Electrical and Electronic Engineers" => "IEEE" }
117
86
  end
@@ -119,6 +88,37 @@ module Metanorma
119
88
  def relaton_relations
120
89
  super + %w(merges updates)
121
90
  end
91
+
92
+ def metadata_ics(node, xml)
93
+ ics = node.attr("library-ics")
94
+ ics&.split(/,\s*/)&.each do |i|
95
+ xml.ics {
96
+ |elem| elem.code i
97
+ icsdata = Isoics.fetch i
98
+ elem.text_ icsdata.description
99
+ }
100
+ end
101
+ end
102
+
103
+ def metadata_ext(node, xml)
104
+ super
105
+ structured_id(node, xml)
106
+ end
107
+
108
+ def structured_id(node, xml)
109
+ return unless node.attr("docnumber")
110
+
111
+ xml.structuredidentifier do |i|
112
+ i.docnumber node.attr("docnumber")
113
+ i.agency "IEEE"
114
+ i.class_ doctype(node)
115
+ a = node.attr("edition") and i.edition a
116
+ a = node.attr("draft") and i.version a
117
+ a = node.attr("amendment-number") and i.amendment a
118
+ a = node.attr("corrigendum-number") and i.corrigendum a
119
+ a = node.attr("copyright-year") and i.year a
120
+ end
121
+ end
122
122
  end
123
123
  end
124
124
  end