metanorma-ieee 0.0.1 → 0.0.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/README.adoc +1 -1
- data/lib/html2doc/ieee/lists.rb +44 -0
- data/lib/html2doc/ieee/notes.rb +57 -0
- data/lib/html2doc/ieee.rb +4 -86
- data/lib/isodoc/ieee/base_convert.rb +56 -0
- data/lib/isodoc/ieee/html/header.html +1 -2
- data/lib/isodoc/ieee/html/header_amd.html +105 -0
- data/lib/isodoc/ieee/html/html_ieee_titlepage.html +14 -12
- data/lib/isodoc/ieee/html/htmlstyle.css +2 -1
- data/lib/isodoc/ieee/html/htmlstyle.scss +1 -0
- data/lib/isodoc/ieee/html/ieee.css +46 -273
- data/lib/isodoc/ieee/html/ieee.scss +46 -257
- data/lib/isodoc/ieee/html/word_ieee_intro.html +1 -1
- data/lib/isodoc/ieee/html/word_ieee_titlepage.html +12 -1
- data/lib/isodoc/ieee/html/wordstyle.css +20 -23
- data/lib/isodoc/ieee/html/wordstyle.scss +20 -17
- data/lib/isodoc/ieee/html_convert.rb +37 -1
- data/lib/isodoc/ieee/i18n-en.yaml +5 -0
- data/lib/isodoc/ieee/ieee.amendment.xsl +5488 -3540
- data/lib/isodoc/ieee/ieee.standard.xsl +5488 -3540
- data/lib/isodoc/ieee/metadata.rb +35 -51
- data/lib/isodoc/ieee/pdf_convert.rb +2 -2
- data/lib/isodoc/ieee/presentation_ref.rb +70 -0
- data/lib/isodoc/ieee/presentation_terms.rb +105 -32
- data/lib/isodoc/ieee/presentation_xml_convert.rb +136 -0
- data/lib/isodoc/ieee/word_authority.rb +73 -3
- data/lib/isodoc/ieee/word_cleanup.rb +55 -65
- data/lib/isodoc/ieee/word_cleanup_blocks.rb +151 -0
- data/lib/isodoc/ieee/word_convert.rb +98 -2
- data/lib/isodoc/ieee/xref.rb +31 -0
- data/lib/metanorma/ieee/boilerplate.xml +72 -23
- data/lib/metanorma/ieee/cleanup.rb +142 -77
- data/lib/metanorma/ieee/cleanup_ref.rb +126 -0
- data/lib/metanorma/ieee/converter.rb +8 -0
- data/lib/metanorma/ieee/front.rb +44 -53
- data/lib/metanorma/ieee/ieee.rng +44 -6
- data/lib/metanorma/ieee/isodoc.rng +32 -1
- data/lib/metanorma/ieee/reqt.rng +1 -1
- data/lib/metanorma/ieee/term_lookup_cleanup.rb +11 -0
- data/lib/metanorma/ieee/validate.rb +105 -57
- data/lib/metanorma/ieee/validate_section.rb +14 -7
- data/lib/metanorma/ieee/validate_style.rb +58 -1
- data/lib/metanorma/ieee/version.rb +1 -1
- data/lib/relaton/render/config.yml +44 -0
- data/lib/relaton/render/general.rb +13 -0
- data/metanorma-itu.gemspec +1 -1
- metadata +13 -4
@@ -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
|
-
<
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
{
|
248
|
+
<membership>
|
249
|
+
<ul>
|
250
|
+
<li><dl><dt>name</dt><dd><Chair Name></dd><dt>role</dt><dd>Chair</dd></dl></li>
|
251
|
+
<li><dl><dt>name</dt><dd><Vice-chair Name></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><Name></dd><dt>role</dt><dd>Chair</dd></dl></li>
|
285
|
+
<li><dl><dt>name</dt><dd><Name></dd><dt>role</dt><dd>Vice Chair</dd></dl></li>
|
286
|
+
<li><dl><dt>name</dt><dd><Name></dd><dt>role</dt><dd>Past Chair</dd></dl></li>
|
287
|
+
<li><dl><dt>name</dt><dd><Name></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 {{
|
310
|
+
<p>All rights reserved. Published {{ issueddate }}. Printed in the United States of America.</p>
|
276
311
|
</clause>
|
277
312
|
|
278
313
|
<clause>
|
@@ -280,7 +315,7 @@
|
|
280
315
|
</clause>
|
281
316
|
|
282
317
|
<clause>
|
283
|
-
<table unnumbered="true">
|
318
|
+
<table unnumbered="true" id="_isbn_pdf_print">
|
284
319
|
<tbody>
|
285
320
|
<tr><td>PDF:</td> <td>ISBN {{ isbn_pdf }}</td> <td>{{ stdid_pdf}}</td></tr>
|
286
321
|
<tr><td>Print:</td> <td>ISBN {{ isbn_print}}</td> <td>{{ stdid_print}}</td></tr>
|
@@ -289,10 +324,24 @@
|
|
289
324
|
</clause>
|
290
325
|
|
291
326
|
<clause>
|
292
|
-
<p>IEEE prohibits discrimination, harassment, and bullying.</
|
293
|
-
|
294
|
-
|
327
|
+
<p><em>IEEE prohibits discrimination, harassment, and bullying.</em><br/>
|
328
|
+
<em>For more information, visit <link target="https://www.ieee.org/about/corporate/governance/p9-26.html"/>.</em><br/>
|
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,40 +1,45 @@
|
|
1
|
+
require_relative "cleanup_ref"
|
2
|
+
require_relative "term_lookup_cleanup"
|
3
|
+
|
1
4
|
module Metanorma
|
2
5
|
module IEEE
|
3
6
|
class Converter < Standoc::Converter
|
4
|
-
BIBLIO =
|
5
|
-
"//bibliography/references[@normative = 'false'][not(@hidden)] | "\
|
6
|
-
"//bibliography/clause[.//references[@normative = 'false']] | "\
|
7
|
-
"//annex//references[@normative = 'false'][not(@hidden)]".freeze
|
8
|
-
|
9
|
-
def boilerplate_cleanup(xmldoc)
|
10
|
-
f = xmldoc.at(BIBLIO) and biblio_preface(f)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def biblio_preface(ref)
|
15
|
-
if ref.at("./note[@type = 'boilerplate']")
|
16
|
-
unwrap_boilerplate_clauses(ref, ".")
|
17
|
-
else
|
18
|
-
pref = @i18n.biblio_pref
|
19
|
-
ref.at("./title").next = "<p>#{pref}</p>"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
7
|
def initial_boilerplate(xml, isodoc)
|
24
8
|
intro_boilerplate(xml, isodoc)
|
25
|
-
super
|
9
|
+
super if @document_scheme == "ieee-sa-2021"
|
10
|
+
initial_note(xml)
|
11
|
+
word_usage(xml)
|
12
|
+
participants(xml)
|
26
13
|
end
|
27
14
|
|
28
15
|
def intro_boilerplate(xml, isodoc)
|
29
16
|
return unless intro = xml.at("//introduction/title")
|
30
17
|
|
31
18
|
template = <<~ADM
|
32
|
-
This introduction is not part of P{{ docnumeric }}{% if draft %}/D{{ draft }}{% endif %}, {{
|
19
|
+
This introduction is not part of P{{ docnumeric }}{% if draft %}/D{{ draft }}{% endif %}, {{ full_doctitle }}
|
33
20
|
ADM
|
34
21
|
adm = isodoc.populate_template(template)
|
35
22
|
intro.next = "<admonition>#{adm}</admonition>"
|
36
23
|
end
|
37
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
|
+
|
38
43
|
def obligations_cleanup_norm(xml)
|
39
44
|
super
|
40
45
|
xml.xpath("//sections/clause").each do |r|
|
@@ -70,90 +75,150 @@ module Metanorma
|
|
70
75
|
ins << "<fn><p>#{@i18n.note_inform_fn}</p></fn>"
|
71
76
|
end
|
72
77
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
78
|
+
def table_footnote_renumber1(fnote, idx, seen)
|
79
|
+
content = footnote_content(fnote)
|
80
|
+
idx += 1
|
81
|
+
if seen[content]
|
82
|
+
fnote.children = "<p>See Footnote #{seen[content]}.</p>"
|
83
|
+
else seen[content] = idx
|
76
84
|
end
|
85
|
+
fnote["reference"] = (idx - 1 + "a".ord).chr
|
86
|
+
fnote["table"] = true
|
87
|
+
[idx, seen]
|
77
88
|
end
|
78
89
|
|
79
|
-
|
80
|
-
|
90
|
+
def other_footnote_renumber1(fnote, idx, seen)
|
91
|
+
return [idx, seen] if fnote["table"]
|
81
92
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
93
|
+
content = footnote_content(fnote)
|
94
|
+
idx += 1
|
95
|
+
if seen[content]
|
96
|
+
fnote.children = "<p>See Footnote #{seen[content]}.</p>"
|
97
|
+
else seen[content] = idx
|
98
|
+
end
|
99
|
+
fnote["reference"] = idx.to_s
|
100
|
+
[idx, seen]
|
87
101
|
end
|
88
102
|
|
89
|
-
|
103
|
+
TERM_CLAUSE = "//sections//terms".freeze
|
104
|
+
|
105
|
+
def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
|
106
|
+
once = true
|
90
107
|
super
|
91
|
-
normref_reorder(xmldoc)
|
92
108
|
end
|
93
109
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
110
|
+
def term_defs_boilerplate_cont(src, term, isodoc); end
|
111
|
+
|
112
|
+
def termlookup_cleanup(xmldoc)
|
113
|
+
Metanorma::IEEE::TermLookupCleanup.new(xmldoc, @log).call
|
98
114
|
end
|
99
115
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
104
124
|
end
|
105
125
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
116
138
|
end
|
117
139
|
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
m[e["bibitemid"]] = true
|
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
|
123
144
|
end
|
145
|
+
t.replace(populate_participants1(s || t))
|
124
146
|
end
|
125
147
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
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
|
129
156
|
end
|
130
157
|
|
131
|
-
def
|
132
|
-
|
133
|
-
|
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" }
|
134
165
|
end
|
135
166
|
end
|
136
167
|
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
143
178
|
end
|
144
179
|
|
145
|
-
def
|
146
|
-
|
147
|
-
|
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)
|
148
186
|
end
|
187
|
+
map["role"] ||= "member"
|
188
|
+
map
|
149
189
|
end
|
150
190
|
|
151
|
-
def
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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)
|
157
222
|
end
|
158
223
|
end
|
159
224
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Metanorma
|
2
|
+
module IEEE
|
3
|
+
class Converter < Standoc::Converter
|
4
|
+
BIBLIO =
|
5
|
+
"//bibliography/references[@normative = 'false'][not(@hidden)] | "\
|
6
|
+
"//bibliography/clause[.//references[@normative = 'false']] | "\
|
7
|
+
"//annex//references[@normative = 'false'][not(@hidden)]".freeze
|
8
|
+
|
9
|
+
def boilerplate_cleanup(xmldoc)
|
10
|
+
f = xmldoc.at(BIBLIO) and biblio_preface(f)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def biblio_preface(ref)
|
15
|
+
if ref.at("./note[@type = 'boilerplate']")
|
16
|
+
unwrap_boilerplate_clauses(ref, ".")
|
17
|
+
else
|
18
|
+
pref = @i18n.biblio_pref
|
19
|
+
ref.at("./title").next = "<p>#{pref}</p>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def sort_biblio(bib)
|
24
|
+
bib.sort do |a, b|
|
25
|
+
sort_biblio_key(a) <=> sort_biblio_key(b)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
|
30
|
+
"@type = 'ISBN'".freeze
|
31
|
+
|
32
|
+
# Alphabetic by rendering: author surname or designation, followed by title
|
33
|
+
def sort_biblio_key(bib)
|
34
|
+
name = designator_or_name(bib)
|
35
|
+
title = bib.at("./title[@type = 'main']")&.text ||
|
36
|
+
bib.at("./title")&.text || bib.at("./formattedref")&.text
|
37
|
+
title.gsub!(/[[:punct:]]/, "")
|
38
|
+
"#{name}. #{title}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def designator_or_name(bib)
|
42
|
+
case bib["type"]
|
43
|
+
when "standard", "techreport"
|
44
|
+
n = bib.at("./docidentifier[@primary]") ||
|
45
|
+
bib.at("./docidentifier[not(#{OTHERIDS})]")
|
46
|
+
n&.text || "ZZZZ"
|
47
|
+
else
|
48
|
+
bib1 = bib.dup
|
49
|
+
bib1.add_namespace(nil, self.class::XML_NAMESPACE)
|
50
|
+
i = IsoDoc::IEEE::PresentationXMLConvert.new({ lang: @lang,
|
51
|
+
script: @script })
|
52
|
+
i.i18n_init(@lang, @script)
|
53
|
+
i.creatornames(bib1)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def normref_cleanup(xmldoc)
|
58
|
+
super
|
59
|
+
normref_reorder(xmldoc)
|
60
|
+
end
|
61
|
+
|
62
|
+
def normref_reorder(xmldoc)
|
63
|
+
xmldoc.xpath("//references[@normative = 'true']").each do |r|
|
64
|
+
biblio_reorder1(r)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# end of citeas generation
|
69
|
+
def quotesource_cleanup(xmldoc)
|
70
|
+
super
|
71
|
+
trademark_ieee_erefs(xmldoc)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Style manual 12.3.5
|
75
|
+
def trademark_ieee_erefs(xmldoc)
|
76
|
+
ieee = xmldoc.xpath("//references/bibitem")
|
77
|
+
.each_with_object({}) do |b, m|
|
78
|
+
n = b.at("./contributor[role/@type = 'publisher']/organization/name")
|
79
|
+
n&.text == "Institute of Electrical and Electronics Engineers" and
|
80
|
+
m[b["id"]] = b.at("./docidentifier[@scope = 'trademark']")&.text
|
81
|
+
end
|
82
|
+
trademark_ieee_erefs1(xmldoc, "//preface//eref", ieee)
|
83
|
+
trademark_ieee_erefs1(xmldoc, "//sections//eref | //annex//eref", ieee)
|
84
|
+
end
|
85
|
+
|
86
|
+
def trademark_ieee_erefs1(xmldoc, path, ieee)
|
87
|
+
xmldoc.xpath(path).each_with_object({}) do |e, m|
|
88
|
+
ieee[e["bibitemid"]] or next
|
89
|
+
m[e["bibitemid"]] or e["citeas"] = ieee[e["bibitemid"]]
|
90
|
+
m[e["bibitemid"]] = true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def biblio_renumber(xmldoc)
|
95
|
+
i = 0
|
96
|
+
xmldoc.xpath("//references[not(@normative = 'true')]"\
|
97
|
+
"[not(@hidden = 'true')]").each do |r|
|
98
|
+
r.xpath("./bibitem[not(@hidden = 'true')]").each do |b|
|
99
|
+
i += 1
|
100
|
+
biblio_renumber1(b, i)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def biblio_renumber1(bib, idx)
|
106
|
+
docid = bib.at("./docidentifier[@type = 'metanorma' or "\
|
107
|
+
"@type = 'metanorma-ordinal']")
|
108
|
+
if /^\[?\d+\]?$/.match?(docid&.text)
|
109
|
+
docid.children = "[B#{idx}]"
|
110
|
+
elsif docid = bib.at("./docidentifier") || bib.at("./title[last()]") ||
|
111
|
+
bib.at("./formattedref")
|
112
|
+
docid.next =
|
113
|
+
"<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
|
114
|
+
end
|
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
|
124
|
+
end
|
125
|
+
end
|
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")
|