metanorma-ieee 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -93,6 +93,8 @@ module IsoDoc
93
93
  doctype(isoxml, _out)
94
94
  set(:full_doctitle, fulltitle(@metadata[:doctype], draft))
95
95
  set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft))
96
+ prov = isoxml&.at(ns("//bibdata/title[@type='provenance']")) and
97
+ set(:provenance_doctitle, prov.children.to_xml)
96
98
  end
97
99
 
98
100
  def fulltitle(type, draft)
@@ -101,23 +103,6 @@ module IsoDoc
101
103
  title
102
104
  end
103
105
 
104
- def relations(isoxml, _out)
105
- super
106
- relations_get(isoxml, "updates")
107
- relations_get(isoxml, "merges")
108
- end
109
-
110
- def relations_get(isoxml, type)
111
- std = isoxml.xpath(ns("//bibdata/relation[@type = '#{type}']"))
112
- return if std.empty?
113
-
114
- ret = std.map do |x|
115
- x.at(ns(".//docidentifier[@primary = 'true']"))&.text ||
116
- x.at(ns(".//docidentifier"))&.text
117
- end
118
- set(type.to_sym, ret)
119
- end
120
-
121
106
  def ddMMMyyyy(isodate)
122
107
  return nil if isodate.nil?
123
108
 
@@ -14,7 +14,7 @@ module IsoDoc
14
14
  if %w(techreport standard).include?(bib[:type])
15
15
  node["citeas"] + " #{bib[:ord]}"
16
16
  else
17
- "#{bib[:title]} " + node["citeas"]
17
+ "#{bib[:author]} " + node["citeas"]
18
18
  end
19
19
  end
20
20
 
@@ -23,8 +23,10 @@ module IsoDoc
23
23
  .each_with_object({}) do |b, m|
24
24
  m[b["id"]] =
25
25
  { docid: pref_ref_code(b), type: b["type"],
26
- title: b.at(ns("./title"))&.text ||
27
- b.at(ns("./formattedref"))&.text,
26
+ title: (b.at(ns("./title")) ||
27
+ b.at(ns("./formattedref")))&.text,
28
+ author: @author[b["id"]] || (b.at(ns("./title")) ||
29
+ b.at(ns("./formattedref")))&.text,
28
30
  ord: b.at(ns("./docidentifier[@type = 'metanorma' or "\
29
31
  "@type = 'metanorma-ordinal']")).text }
30
32
  end
@@ -35,13 +37,22 @@ module IsoDoc
35
37
  i18nhash: @i18n.get)
36
38
  end
37
39
 
38
- def bibrender_relaton(xml)
39
- bib = xml.dup
40
- bib["suppress_identifier"] == true and
41
- bib.xpath(ns("./docidentifier")).each(&:remove)
40
+ def citestyle
41
+ "author-date"
42
+ end
43
+
44
+ def references_render(docxml)
45
+ @author = {}
46
+ super
47
+ end
48
+
49
+ def bibrender_relaton(xml, renderings)
50
+ f = renderings[xml["id"]][:formattedref]
51
+ f &&= "<formattedref>#{f}</formattedref>"
42
52
  xml.children =
43
- "#{bibrenderer.render(bib.to_xml)}"\
44
- "#{xml.xpath(ns('./docidentifier | ./uri | ./note | ./title')).to_xml}"
53
+ "#{f}#{xml.xpath(ns('./docidentifier | ./uri | ./note | ./title'))
54
+ .to_xml}"
55
+ @author[xml["id"]] = renderings[xml["id"]][:author]
45
56
  end
46
57
 
47
58
  def creatornames(bibitem)
@@ -26,25 +26,24 @@ module IsoDoc
26
26
 
27
27
  def unwrap_multidef(coll)
28
28
  if coll.all? do |c|
29
- c.elements.size == 1 && c.elements.first.name == "p"
30
- end
29
+ c.elements.size == 1 && c.elements.first.name == "p"
30
+ end
31
31
  ret = coll.map do |c|
32
32
  c.elements.first.children.to_xml
33
33
  end
34
- "<p>#{ret.join}</p>"
35
- else
36
- coll.map { |c| c.children.to_xml }.join
34
+ return "<p>#{ret.join}</p>"
37
35
  end
36
+ coll.map { |c| c.children.to_xml }.join
38
37
  end
39
38
 
40
39
  def unwrap_definition(docxml)
41
40
  docxml.xpath(ns("//definition/verbal-definition")).each do |v|
42
41
  next unless v.elements.all? { |e| %w(termsource p).include?(e.name) }
43
42
 
44
- s = v.xpath(ns("./termsource"))
45
43
  p = v.xpath(ns("./p"))
46
44
  v.children =
47
- "<p>#{p.map(&:children).map(&:to_xml).join("\n")}</p>#{s.to_xml}"
45
+ "<p>#{p.map(&:children).map(&:to_xml).join("\n")}</p>"\
46
+ "#{v.xpath(ns('./termsource')).to_xml}"
48
47
  end
49
48
  super
50
49
  end
@@ -61,12 +60,13 @@ module IsoDoc
61
60
  def term_related_collapse(coll)
62
61
  prev = 0
63
62
  coll[1..-1].each_with_index do |r, i|
64
- if coll[prev]["type"] == r["type"]
65
- coll[prev].at(ns("./preferred")) << "; #{r.at(ns('./preferred'))
66
- .children.to_xml}"
67
- r.remove
68
- else prev = i
63
+ if coll[prev]["type"] != r["type"]
64
+ prev = i
65
+ next
69
66
  end
67
+ coll[prev].at(ns("./preferred")) << "; #{r.at(ns('./preferred'))
68
+ .children.to_xml}"
69
+ r.remove
70
70
  end
71
71
  end
72
72
 
@@ -74,8 +74,14 @@ module IsoDoc
74
74
  d = term.at(ns("./preferred/expression/name | "\
75
75
  "./preferred/letter-symbol/name | "\
76
76
  "./preferred/graphical-symbol/figure/name | "\
77
- "./preferred/graphical-symbol/figure/@id"))
78
- HTMLEntities.new.decode(d&.text&.strip&.downcase) || "ZZZ"
77
+ "./preferred/graphical-symbol/figure/@id | "\
78
+ "./preferred"))
79
+ f = term.at(ns("./field-of-application")) || term.at(ns("./domain"))
80
+ HTMLEntities.new.decode("#{sort_terms_key1(d)} :: #{sort_terms_key1(f)}")
81
+ end
82
+
83
+ def sort_terms_key1(elem)
84
+ elem&.text&.strip&.downcase || "zzzz"
79
85
  end
80
86
 
81
87
  def term_related_reorder(coll)
@@ -110,8 +116,12 @@ module IsoDoc
110
116
  end
111
117
 
112
118
  def admitted_to_related(docxml)
113
- docxml.xpath(ns("//term/admitted")).each do |a|
114
- admitted_to_related1(a, a.parent.at(ns("./preferred")))
119
+ docxml.xpath(ns("//term")).each do |t|
120
+ t.xpath(ns("./admitted | ./preferred")).each_with_index do |a, i|
121
+ (i.zero? ||
122
+ a.at(ns("./abbreviation-type | ./graphical-symbol"))) and next
123
+ admitted_to_related1(a, t.at(ns("./preferred")))
124
+ end
115
125
  end
116
126
  term_reorder(docxml)
117
127
  end
@@ -217,12 +227,15 @@ module IsoDoc
217
227
  end
218
228
 
219
229
  def merge_second_preferred(term)
220
- prefs = term.xpath(ns("./preferred[expression/name]"))
221
- prefs.size > 1 or return
222
- alts = prefs[1..-1].map do |p|
230
+ pref =
231
+ term.at(ns("./preferred[not(abbreviation-type)]/expression/name"))
232
+ x = term.xpath(ns("./preferred[expression/name][abbreviation-type] | "\
233
+ "./admitted[expression/name][abbreviation-type]"))
234
+ (pref && !x.empty?) or return
235
+ tail = x.map do |p|
223
236
  p.remove.at(ns("./expression/name")).children.to_xml.strip
224
- end
225
- prefs.first.at(ns("./expression/name")) << " (#{alts.join(', ')})"
237
+ end.join(", ")
238
+ pref << " (#{tail})"
226
239
  end
227
240
 
228
241
  def termnote1(elem)
@@ -166,13 +166,26 @@ module IsoDoc
166
166
  ulist.xpath(ns("./li")).each { |list| participants1(list, idx) }
167
167
  ulist.replace(ulist.children)
168
168
  end
169
+ affiliation_header(clause)
170
+ end
171
+
172
+ def affiliation_header(clause)
173
+ clause.xpath(ns(".//p[@type = 'officeorgrepmember']")).each do |p|
174
+ prev = p.previous_element
175
+ prev && prev.name == "p" &&
176
+ prev["type"] == "officeorgrepmember" and next
177
+ p.previous = <<~HDR
178
+ <p type='officeorgrepmemberhdr'><em>Organization
179
+ Represented</em><tab/><em>Name of Representative</em></p>
180
+ HDR
181
+ end
169
182
  end
170
183
 
171
184
  def participants1(list, idx)
172
185
  key = ""
173
186
  map = list.xpath(ns(".//dt | .//dd")).each_with_object({}) do |dtd, m|
174
187
  (dtd.name == "dt" and key = dtd.text) or
175
- m[key] = dtd.text.strip
188
+ m[key] = @c.encode(dtd.text.strip, :hexadecimal)
176
189
  end
177
190
  list.replace(participant_para(map, idx))
178
191
  end
@@ -187,8 +200,12 @@ module IsoDoc
187
200
  end
188
201
 
189
202
  def participant_member_para(map, name, _idx)
190
- (map["company"] and "<p type='officeorgmember'>#{name}</p>") or
191
- "<p type='officemember'>#{name}</p>"
203
+ if map["company"] && (map["name"] || map["surname"])
204
+ pers = map["name"] || "#{map['given']} #{map['surname']}"
205
+ "<p type='officeorgrepmember'>#{name}<tab/>#{pers}</p>"
206
+ elsif map["company"] then "<p type='officeorgmember'>#{name}</p>"
207
+ else "<p type='officemember'>#{name}</p>"
208
+ end
192
209
  end
193
210
 
194
211
  def participant_officeholder_para(map, name, idx)
@@ -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
@@ -77,6 +78,19 @@ module IsoDoc
77
78
  end
78
79
  end
79
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
+
80
94
  def three_column_officemembers(div)
81
95
  return unless div
82
96
 
@@ -225,9 +225,9 @@
225
225
  <zeroOrMore>
226
226
  <ref name="forename"/>
227
227
  </zeroOrMore>
228
- <zeroOrMore>
229
- <ref name="initial"/>
230
- </zeroOrMore>
228
+ <optional>
229
+ <ref name="formatted-initials"/>
230
+ </optional>
231
231
  <ref name="surname"/>
232
232
  <zeroOrMore>
233
233
  <ref name="addition"/>
@@ -247,8 +247,8 @@
247
247
  <ref name="LocalizedString"/>
248
248
  </element>
249
249
  </define>
250
- <define name="initial">
251
- <element name="initial">
250
+ <define name="formatted-initials">
251
+ <element name="formatted-initials">
252
252
  <ref name="LocalizedString"/>
253
253
  </element>
254
254
  </define>
@@ -264,6 +264,9 @@
264
264
  </define>
265
265
  <define name="forename">
266
266
  <element name="forename">
267
+ <optional>
268
+ <attribute name="initial"/>
269
+ </optional>
267
270
  <ref name="LocalizedString"/>
268
271
  </element>
269
272
  </define>
@@ -6,7 +6,7 @@ module Metanorma
6
6
  class Converter < Standoc::Converter
7
7
  def initial_boilerplate(xml, isodoc)
8
8
  intro_boilerplate(xml, isodoc)
9
- super
9
+ super if @document_scheme == "ieee-sa-2021"
10
10
  initial_note(xml)
11
11
  word_usage(xml)
12
12
  participants(xml)
@@ -31,6 +31,8 @@ module Metanorma
31
31
  end
32
32
 
33
33
  def word_usage(xml)
34
+ return unless @document_scheme == "ieee-sa-2021"
35
+
34
36
  n = xml.at("//boilerplate//clause[@id = 'boilerplate_word_usage']")
35
37
  &.remove
36
38
  s = xml.at("//clause[@type = 'overview']")
@@ -122,12 +124,13 @@ module Metanorma
122
124
  end
123
125
 
124
126
  def participants(xml)
125
- populate_participants(xml, "boilerplate-participants-wg",
126
- "working group")
127
- populate_participants(xml, "boilerplate-participants-bg",
128
- "balloting group")
129
- populate_participants(xml, "boilerplate-participants-sb",
130
- "standards board")
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
131
134
  p = xml.at(".//p[@type = 'emeritus_sign']")
132
135
  ul = xml.at("//clause[@id = 'boilerplate-participants-sb']//ul")
133
136
  p && ul and ul.next = p
@@ -153,7 +156,9 @@ module Metanorma
153
156
  end
154
157
 
155
158
  def participants_dl_to_ul(clause)
156
- clause.xpath(".//dl[.//dl]").each do |dl|
159
+ clause.xpath(".//dl").each do |dl|
160
+ next unless dl.ancestors("dl, ul, ol").empty?
161
+
157
162
  dl.name = "ul"
158
163
  dl.xpath("./dt").each(&:remove)
159
164
  dl.xpath("./dd").each { |li| li.name = "li" }
@@ -161,11 +166,10 @@ module Metanorma
161
166
  end
162
167
 
163
168
  def populate_participants2(list)
164
- c = HTMLEntities.new
165
169
  if dl = list.at("./dl")
166
170
  ret = extract_participants(dl)
167
171
  dl.children = ret.keys.map do |k|
168
- "<dt>#{k}</dt><dd>#{c.encode(ret[k], :hexadecimal)}</dd>"
172
+ "<dt>#{k}</dt><dd>#{ret[k]}</dd>"
169
173
  end.join
170
174
  else
171
175
  list.children = "<dl><dt>name</dt><dd>#{list.children.to_xml}</dd>"\
@@ -177,11 +181,45 @@ module Metanorma
177
181
  key = ""
178
182
  map = dlist.xpath("./dt | ./dd").each_with_object({}) do |dtd, m|
179
183
  (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) or
180
- m[key.strip.downcase] = dtd.text.strip
184
+ m[key.strip.downcase] =
185
+ @c.encode(@c.decode(dtd.text.strip), :hexadecimal)
181
186
  end
182
187
  map["role"] ||= "member"
183
188
  map
184
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
185
223
  end
186
224
  end
187
225
  end
@@ -77,7 +77,7 @@ module Metanorma
77
77
  .each_with_object({}) do |b, m|
78
78
  n = b.at("./contributor[role/@type = 'publisher']/organization/name")
79
79
  n&.text == "Institute of Electrical and Electronics Engineers" and
80
- m[b["id"]] = true
80
+ m[b["id"]] = b.at("./docidentifier[@scope = 'trademark']")&.text
81
81
  end
82
82
  trademark_ieee_erefs1(xmldoc, "//preface//eref", ieee)
83
83
  trademark_ieee_erefs1(xmldoc, "//sections//eref | //annex//eref", ieee)
@@ -86,7 +86,7 @@ module Metanorma
86
86
  def trademark_ieee_erefs1(xmldoc, path, ieee)
87
87
  xmldoc.xpath(path).each_with_object({}) do |e, m|
88
88
  ieee[e["bibitemid"]] or next
89
- m[e["bibitemid"]] or e["citeas"] += "\u2122"
89
+ m[e["bibitemid"]] or e["citeas"] = ieee[e["bibitemid"]]
90
90
  m[e["bibitemid"]] = true
91
91
  end
92
92
  end
@@ -113,6 +113,14 @@ module Metanorma
113
113
  "<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
114
114
  end
115
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
116
124
  end
117
125
  end
118
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
 
@@ -1,3 +1,5 @@
1
+ require "isoics"
2
+
1
3
  module Metanorma
2
4
  module IEEE
3
5
  class Converter < Standoc::Converter
@@ -64,7 +66,7 @@ module Metanorma
64
66
 
65
67
  def metadata_status(node, xml)
66
68
  status = node.attr("status") || node.attr("docstage") ||
67
- (node.attr("draft") ? "developing" : "active")
69
+ (node.attr("draft") ? "draft" : "approved")
68
70
  xml.status do |s|
69
71
  s.stage status
70
72
  end
@@ -14,22 +14,32 @@
14
14
  <value>guide</value>
15
15
  <value>recommended-practice</value>
16
16
  <value>standard</value>
17
+ <value>whitepaper</value>
18
+ <value>redline</value>
19
+ <value>other</value>
17
20
  </choice>
18
21
  </define>
19
22
  <define name="stage">
20
23
  <element name="stage">
21
24
  <choice>
22
- <value>developing</value>
23
- <value>active</value>
24
- <value>inactive</value>
25
+ <value>draft</value>
26
+ <value>approved</value>
27
+ <value>superseded</value>
28
+ <value>withdrawn</value>
25
29
  </choice>
26
30
  </element>
27
31
  </define>
28
32
  <define name="editorialgroup">
29
33
  <element name="editorialgroup">
30
- <ref name="society"/>
31
- <ref name="balloting-group"/>
32
- <ref name="working-group"/>
34
+ <optional>
35
+ <ref name="society"/>
36
+ </optional>
37
+ <optional>
38
+ <ref name="balloting-group"/>
39
+ </optional>
40
+ <optional>
41
+ <ref name="working-group"/>
42
+ </optional>
33
43
  <oneOrMore>
34
44
  <ref name="committee"/>
35
45
  </oneOrMore>
@@ -52,14 +62,65 @@
52
62
  <optional>
53
63
  <ref name="trialuse"/>
54
64
  </optional>
55
- <ref name="editorialgroup"/>
65
+ <optional>
66
+ <ref name="editorialgroup"/>
67
+ </optional>
56
68
  <zeroOrMore>
57
69
  <ref name="ics"/>
58
70
  </zeroOrMore>
71
+ <optional>
72
+ <ref name="standard_status"/>
73
+ </optional>
74
+ <optional>
75
+ <ref name="standard_modified"/>
76
+ </optional>
77
+ <optional>
78
+ <ref name="pubstatus"/>
79
+ </optional>
80
+ <optional>
81
+ <ref name="holdstatus"/>
82
+ </optional>
59
83
  </define>
60
84
  </include>
85
+ <define name="standard_status">
86
+ <element name="standard_status">
87
+ <choice>
88
+ <value>Inactive</value>
89
+ <value>Active</value>
90
+ <value>Superseded</value>
91
+ </choice>
92
+ </element>
93
+ </define>
94
+ <define name="standard_modified">
95
+ <element name="standard_modified">
96
+ <choice>
97
+ <value>Draft</value>
98
+ <value>Withdrawn</value>
99
+ <value>Superseded</value>
100
+ <value>Approved</value>
101
+ <value>Reserved</value>
102
+ <value>Redline</value>
103
+ </choice>
104
+ </element>
105
+ </define>
106
+ <define name="pubstatus">
107
+ <element name="pubstatus">
108
+ <choice>
109
+ <value>Active</value>
110
+ <value>Inactive</value>
111
+ </choice>
112
+ </element>
113
+ </define>
114
+ <define name="holdstatus">
115
+ <element name="holdstatus">
116
+ <choice>
117
+ <value>Hold</value>
118
+ <value>Publish</value>
119
+ </choice>
120
+ </element>
121
+ </define>
61
122
  <define name="BibliographicDateType" combine="choice">
62
- <value>feecback-ended</value>
123
+ <value>feedback-ended</value>
63
124
  </define>
64
125
  <define name="trialuse">
65
126
  <element name="trial-use">
@@ -1285,7 +1285,12 @@
1285
1285
  </define>
1286
1286
  <define name="span">
1287
1287
  <element name="span">
1288
- <attribute name="class"/>
1288
+ <optional>
1289
+ <attribute name="class"/>
1290
+ </optional>
1291
+ <optional>
1292
+ <attribute name="style"/>
1293
+ </optional>
1289
1294
  <oneOrMore>
1290
1295
  <ref name="TextElement"/>
1291
1296
  </oneOrMore>
@@ -108,7 +108,7 @@
108
108
  </element>
109
109
  </define>
110
110
  <define name="label">
111
- <element name="label">
111
+ <element name="identifier">
112
112
  <oneOrMore>
113
113
  <ref name="TextElement"/>
114
114
  </oneOrMore>
@@ -29,7 +29,8 @@ module Metanorma
29
29
 
30
30
  def doctype_validate(xmldoc)
31
31
  doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
32
- %w(standard recommended-practice guide).include? doctype or
32
+ %w(standard recommended-practice guide whitepaper redline other)
33
+ .include? doctype or
33
34
  @log.add("Document Attributes", nil,
34
35
  "#{doctype} is not a recognised document type")
35
36
  docsubtype = xmldoc&.at("//bibdata/ext/subdoctype")&.text or return
@@ -40,7 +41,7 @@ module Metanorma
40
41
 
41
42
  def stage_validate(xmldoc)
42
43
  stage = xmldoc&.at("//bibdata/status/stage")&.text
43
- %w(active inactive developing).include? stage or
44
+ %w(draft approved superseded withdrawn).include? stage or
44
45
  @log.add("Document Attributes", nil,
45
46
  "#{stage} is not a recognised stage")
46
47
  end
@@ -148,13 +149,13 @@ module Metanorma
148
149
  pref = image_name_prefix(xmldoc)
149
150
  (xmldoc.xpath("//figure") - xmldoc.xpath("//table//figure"))
150
151
  .each do |f|
151
- i = f.at("./image") or next
152
- next if i["src"].start_with?("data:")
152
+ (i = f.at("./image") and !i["src"]&.start_with?("data:")) or next
153
153
 
154
154
  num = xrefs.anchor(f["id"], :label)
155
- File.basename(i["src"], ".*") == "#{pref}_fig#{num}" or
155
+ base = File.basename(i["src"], ".*")
156
+ base == "#{pref}_fig#{num}" or
156
157
  @log.add("Style", i,
157
- "Image name #{i['src']} is expected to be #{pref}_fig#{num}")
158
+ "Image name #{base} is expected to be #{pref}_fig#{num}")
158
159
  end
159
160
  end
160
161
 
@@ -169,13 +170,13 @@ module Metanorma
169
170
  def table_figure_name_validate(xmldoc, xrefs)
170
171
  xmldoc.xpath("//table[.//figure]").each do |t|
171
172
  xmldoc.xpath(".//figure").each do |f|
172
- i = f.at("./image") or next
173
- next if i["src"].start_with?("data:")
173
+ (i = f.at("./image") and !i["src"]&.start_with?("data:")) or next
174
174
 
175
175
  num = tablefigurenumber(t, f, xrefs)
176
- File.basename(i["src"]) == num or
176
+ base = File.basename(i["src"])
177
+ base == num or
177
178
  @log.add("Style", i,
178
- "Image name #{i['src']} is expected to be #{num}")
179
+ "Image name #{base} is expected to be #{num}")
179
180
  end
180
181
  end
181
182
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.0.3".freeze
3
+ VERSION = "0.0.6".freeze
4
4
  end
5
5
  end
@@ -3,6 +3,6 @@ require "asciidoctor"
3
3
  require "isodoc/ieee"
4
4
  require "html2doc/ieee"
5
5
 
6
- if defined? Metanorma
6
+ if defined? Metanorma::Registry
7
7
  Metanorma::Registry.instance.register(Metanorma::IEEE::Processor)
8
8
  end