metanorma-nist 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  clause: Section
2
2
  annex: Appendix
3
+ draft-internal-boilerplate: This document is currently under development and is <br/><b>NOT INTENDED FOR PUBLIC RELEASE.</b>
3
4
  draft-wip-boilerplate: This document is currently under development. The draft is not yet complete, and organizations should not attempt to implement it. The content is in an early stage of development, rough, incomplete and experimental; it has not been extensively edited or vetted. This provides an insider view of the iterative process to develop the content and it gives NIST an opportunity to share early thoughts, ideas, and approaches with the community. NIST welcomes early informal feedback and comments, which will be adjudicated after the specified public comment period.
4
5
  draft-prelim-boilerplate: This document incorporates comments from the work-in-progress draft. It is a relatively cohesive document and is considered stable, although there are gaps in the content and the overall document is incomplete. Some changes are expected. Organizations may consider experimenting with guidelines, with the understanding that they will identify gaps and challenges. NIST welcomes early informal feedback and comments, which will be adjudicated after the specified public comment period; a full public draft is expected to follow.
5
- draft-public-boilerplate: This draft represents a complete document that is released for public comment as part of NIST’s official review process, in support of an open and transparent process for developing guidelines and standards. The language is normalized and is consistent throughout the document. Comments received during previous review cycles (if any) have been adjudicated and are addressed in this release. Early adopters may attempt to implement the guidelines in a test or development environment; however, comments received on this draft may cause NIST to determine that a subsequent public draft and comment period is necessary. The content of this document will not be considered as “final” until formally published and announced by NIST.
6
+ draft-public-boilerplate: This draft represents a complete document that is released for public comment as part of NIST’s official review process, in support of an open and transparent process for developing guidelines and standards. The language is normalized and is consistent throughout the document. Comments received during previous review cycles (if any) have been adjudicated and are addressed in this release. Early adopters may attempt to implement the guidelines in a test or development environment; however, comments received on this draft may cause NIST to determine that a subsequent public draft and comment period are necessary. The content of this document will not be considered “final” until it is formally published and announced by NIST.
7
+ withdrawal-pending-boilerplate: This document has been superseded by the document identified below. It will remain active until the withdrawal date, when it will be officially withdrawn.
8
+ draft-retired-boilerplate: The attached draft document has been RETIRED. NIST has discontinued additional development of this document, which is provided here in its entirety for historical purposes.
9
+ draft-withdrawn-boilerplate: The attached draft document has been withdrawn, and is provided solely for historical purposes. It has been superseded by the document identified below.
10
+ publication-withdrawn-boilerplate: The attached publication has been withdrawn (archived), and is provided solely for historical purposes. It may have been superseded by another publication (indicated below).
@@ -1,4 +1,5 @@
1
1
  require "isodoc"
2
+ require "twitter_cldr"
2
3
 
3
4
  module IsoDoc
4
5
  module NIST
@@ -12,11 +13,15 @@ module IsoDoc
12
13
  def title(isoxml, out)
13
14
  main = isoxml&.at(ns("//bibdata/title[@type = 'main']"))&.text
14
15
  set(:doctitle, main)
16
+ short = isoxml&.at(ns("//bibdata/title[@type = 'short-title']"))&.text
17
+ set(:doctitle_short, short || main)
15
18
  end
16
19
 
17
20
  def subtitle(isoxml, _out)
18
21
  main = isoxml&.at(ns("//bibdata/title[@type = 'subtitle']"))&.text
19
22
  set(:docsubtitle, main) if main
23
+ short = isoxml&.at(ns("//bibdata/title[@type = 'short-subtitle']"))&.text
24
+ set(:docsubtitle_short, short || main) if (short || main)
20
25
  main = isoxml&.at(ns("//bibdata/title[@type = 'document-class']"))&.text
21
26
  set(:docclasstitle, main) if main
22
27
  end
@@ -25,6 +30,8 @@ module IsoDoc
25
30
  tc = isoxml.at(ns("//bibdata/editorialgroup/committee"))
26
31
  set(:tc, tc.text.upcase) if tc
27
32
  personal_authors(isoxml)
33
+ subdiv = isoxml.at(ns("//bibdata/contributor[role/@type = 'publisher']/organization/subdivision"))
34
+ set(:nist_subdiv, subdiv.text) if subdiv
28
35
  end
29
36
 
30
37
  def docid(isoxml, _out)
@@ -36,6 +43,7 @@ module IsoDoc
36
43
  set(:docidentifier_long, docid_long)
37
44
  d = draft_prefix(isoxml) and set(:draft_prefix, d)
38
45
  d = iter_code(isoxml) and set(:iteration_code, d)
46
+ d = iter_ordinal(isoxml) and set(:iteration_ordinal, d)
39
47
  set(:docnumber, docnumber)
40
48
  end
41
49
 
@@ -57,6 +65,15 @@ module IsoDoc
57
65
  "#{iter}PD"
58
66
  end
59
67
 
68
+ def iter_ordinal(isoxml)
69
+ docstatus = isoxml.at(ns("//bibdata/status/stage"))&.text
70
+ return nil unless docstatus == "draft-public"
71
+ iter = isoxml.at(ns("//bibdata/status/iteration"))&.text || "1"
72
+ return "Initial" if iter == "1"
73
+ return "Final" if iter.downcase == "final"
74
+ iter.to_i.localize.to_rbnf_s("SpelloutRules", "spellout-ordinal")
75
+ end
76
+
60
77
  def draftinfo(draft, revdate)
61
78
  draftinfo = ""
62
79
  if draft
@@ -67,16 +84,19 @@ module IsoDoc
67
84
 
68
85
  def docstatus(isoxml, _out)
69
86
  docstatus = isoxml.at(ns("//bibdata/status/stage"))&.text
70
- iter = isoxml.at(ns("//bibdata/status/iteration"))&.text
71
87
  set(:unpublished, !/^draft/.match(docstatus).nil?)
88
+ substage = isoxml.at(ns("//bibdata/status/substage"))&.text
89
+ substage and set(:substage, substage)
90
+ iter = isoxml.at(ns("//bibdata/status/iteration"))&.text
72
91
  set(:iteration, iter) if iter
73
92
  set(:status, status_print(docstatus || "final"))
93
+ set(:errata, true) if isoxml.at(ns("//errata"))
74
94
  end
75
95
 
76
96
  def status_print(status)
77
97
  case status
78
98
  when "draft-internal" then "Internal Draft"
79
- when "draft-wip" then "Work In Progress Draft"
99
+ when "draft-wip" then "Work-in-Progress Draft"
80
100
  when "draft-prelim" then "Preliminary Draft"
81
101
  when "draft-public" then "Public Draft"
82
102
  when "draft-retire" then "Retired Draft"
@@ -89,8 +109,36 @@ module IsoDoc
89
109
 
90
110
  def version(isoxml, _out)
91
111
  super
112
+ set(:revision, isoxml&.at(ns("//bibdata/revision"))&.text)
92
113
  revdate = get[:revdate]
93
114
  set(:revdate_monthyear, monthyr(revdate))
115
+ set(:revdate_MMMddyyyy, MMMddyyyy(revdate))
116
+ end
117
+
118
+ def bibdate(isoxml, _out)
119
+ super
120
+ isoxml.xpath(ns("//bibdata/date")).each do |d|
121
+ val = Common::date_range(d)
122
+ next if val == "XXX"
123
+ set("#{d['type']}date_monthyear".to_sym, daterange_proc(val, :monthyr))
124
+ set("#{d['type']}date_mmddyyyy".to_sym, daterange_proc(val, :mmddyyyy))
125
+ set("#{d['type']}date_MMMddyyyy".to_sym, daterange_proc(val, :MMMddyyyy))
126
+ end
127
+ withdrawal_pending(isoxml)
128
+ end
129
+
130
+ def withdrawal_pending(isoxml)
131
+ d = isoxml&.at(ns("//bibdata/date[@type = 'obsoleted']"))&.text or return
132
+ date = Date.parse(d) or return
133
+ set(:withdrawal_pending, true) if date > Date.today
134
+ end
135
+
136
+ def daterange_proc(val, fn)
137
+ m = /^(?<date1>[^&]+)(?<ndash>\&ndash;)?(?<date2>.*)$/.match val
138
+ val_monthyear = self.send(fn, m[:date1])
139
+ val_monthyear += "&ndash;" if m[:ndash]
140
+ val_monthyear += self.send(fn, m[:date2]) unless m[:date2].empty?
141
+ val_monthyear
94
142
  end
95
143
 
96
144
  def series(isoxml, _out)
@@ -101,25 +149,19 @@ module IsoDoc
101
149
  set(:subseries, subseries) if subseries
102
150
  end
103
151
 
104
- MONTHS = {
105
- "01": "January",
106
- "02": "February",
107
- "03": "March",
108
- "04": "April",
109
- "05": "May",
110
- "06": "June",
111
- "07": "July",
112
- "08": "August",
113
- "09": "September",
114
- "10": "October",
115
- "11": "November",
116
- "12": "December",
117
- }.freeze
118
-
119
152
  def monthyr(isodate)
120
- m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
121
- return isodate unless m && m[:yr] && m[:mo]
122
- return "#{MONTHS[m[:mo].to_sym]} #{m[:yr]}"
153
+ return nil if isodate.nil?
154
+ DateTime.parse(isodate).localize(:en).to_additional_s("yMMMM")
155
+ end
156
+
157
+ def mmddyyyy(isodate)
158
+ return nil if isodate.nil?
159
+ Date.parse(isodate).strftime("%m-%d-%Y")
160
+ end
161
+
162
+ def MMMddyyyy(isodate)
163
+ return nil if isodate.nil?
164
+ Date.parse(isodate).strftime("%B %d, %Y")
123
165
  end
124
166
 
125
167
  def keywords(isoxml, _out)
@@ -164,6 +206,76 @@ module IsoDoc
164
206
  set(:supersedes, ret) unless ret.empty?
165
207
  ret = relations1(isoxml, "supersededBy")
166
208
  set(:supersededby, ret) unless ret.empty?
209
+ superseding_doc(isoxml)
210
+ end
211
+
212
+ def superseding_doc(isoxml)
213
+ d = isoxml.at(ns("//bibdata/relation[@type = 'obsoletedBy']/bibitem"))
214
+ return unless d
215
+ set(:superseding_status,
216
+ status_print(d.at(ns("./status/stage"))&.text || "final"))
217
+ superseding_iteration(d)
218
+ docid = d.at(ns("./docidentifier[@type = 'nist']"))&.text and
219
+ set(:superseding_docidentifier, docid)
220
+ docid_long = d.at(ns("./docidentifier[@type = 'nist-long']"))&.text and
221
+ set(:superseding_docidentifier_long, docid_long)
222
+ superseding_dates(d)
223
+ doi = d.at(ns("./uri[@type = 'doi']"))&.text and
224
+ set(:superseding_doi, doi)
225
+ uri = d.at(ns("./uri[@type = 'uri']"))&.text and
226
+ set(:superseding_uri, uri)
227
+ superseding_titles(isoxml, d)
228
+ authors = d.xpath(ns("./contributor[role/@type = 'author']/person"))
229
+ authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author']/person")) if authors.empty?
230
+ set(:superseding_authors, extract_person_names(authors))
231
+ end
232
+
233
+ def superseding_titles(isoxml, d)
234
+ title = d.at(ns("./title[@type = 'main']"))&.text
235
+ if title
236
+ set(:superseding_title, d.at(ns("./title[@type = 'main']"))&.text)
237
+ set(:superseding_subtitle, d.at(ns("./title[@type = 'subtitle']"))&.text)
238
+ else
239
+ set(:superseding_title, isoxml.at(ns("//bibdata/title[@type = 'main']"))&.text)
240
+ set(:superseding_subtitle, isoxml.at(ns("//bibdata/title[@type = 'subtitle']"))&.text)
241
+ end
242
+ end
243
+
244
+ def superseding_iteration(d)
245
+ return unless d.at(ns("./status/stage"))&.text == "draft-public"
246
+ iter = d.at(ns("./status/iteration"))&.text || "1"
247
+ case iter.downcase
248
+ when "1"
249
+ set(:superseding_iteration_ordinal, "Initial")
250
+ set(:superseding_iteration_code, "IPD")
251
+ when "final"
252
+ set(:superseding_iteration_ordinal, "Final")
253
+ set(:superseding_iteration_code, "FPD")
254
+ else
255
+ set(:superseding_iteration_ordinal,
256
+ iter.to_i.localize.to_rbnf_s("SpelloutRules", "spellout-ordinal"))
257
+ set(:superseding_iteration_code, "#{iter}PD")
258
+ end
259
+ end
260
+
261
+ def superseding_dates(d)
262
+ if cdate = d.at(ns("./date[@type = 'circulated']/on"))&.text
263
+ set(:superseding_circulated_date, cdate)
264
+ set(:superseding_circulated_date_monthyear, monthyr(cdate))
265
+ end
266
+ if cdate = d.at(ns("./date[@type = 'published']/on"))&.text
267
+ set(:superseding_published_date, cdate)
268
+ set(:superseding_published_date_monthyear, monthyr(cdate))
269
+ end
270
+ end
271
+
272
+ def note(xml, _out)
273
+ note = xml.at(ns("//bibdata/note[@type = 'additional-note']"))&.text and
274
+ set(:additional_note, note)
275
+ note = xml.at(ns("//bibdata/note[@type = 'withdrawal-note']"))&.text and
276
+ set(:withdrawal_note, note)
277
+ note = xml.at(ns("//bibdata/note[@type = 'withdrawal-announcement-link']"))&.text and
278
+ set(:withdrawal_announcement_link, note)
167
279
  end
168
280
  end
169
281
  end
@@ -1,6 +1,7 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
3
  require "fileutils"
4
+ require_relative "base_convert"
4
5
 
5
6
  module IsoDoc
6
7
  module NIST
@@ -91,64 +92,6 @@ module IsoDoc
91
92
  end
92
93
  end
93
94
 
94
- def abstract(isoxml, out)
95
- f = isoxml.at(ns("//preface/abstract")) || return
96
- page_break(out)
97
- out.div **attr_code(id: f["id"]) do |s|
98
- clause_name(nil, @abstract_lbl, s, class: "AbstractTitle")
99
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
100
- end
101
- end
102
-
103
- def keywords(_docxml, out)
104
- kw = @meta.get[:keywords]
105
- kw.empty? and return
106
- out.div **{ class: "Section3" } do |div|
107
- clause_name(nil, "Keywords", div, class: "IntroTitle")
108
- div.p kw.sort.join("; ")
109
- end
110
- end
111
-
112
- FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract')]".freeze
113
-
114
- def preface(isoxml, out)
115
- isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
116
- foreword(isoxml, out) and next if c.name == "foreword"
117
- authority_parse(isoxml, out) and next if c.name == "authority"
118
- next if skip_render(c, isoxml)
119
- out.div **attr_code(id: c["id"]) do |s|
120
- clause_name(get_anchors[c['id']][:label],
121
- c&.at(ns("./title"))&.content, s, nil)
122
- c.elements.reject { |c1| c1.name == "title" }.each do |c1|
123
- parse(c1, s)
124
- end
125
- end
126
- end
127
- end
128
-
129
- def skip_render(c, isoxml)
130
- return false unless c.name == "reviewernote"
131
- status = isoxml&.at(ns("//bibdata/status/stage"))&.text
132
- return true if status.nil?
133
- /^final/.match status
134
- end
135
-
136
- def term_defs_boilerplate(div, source, term, preface)
137
- if source.empty? && term.nil?
138
- div << @no_terms_boilerplate
139
- else
140
- div << term_defs_boilerplate_cont(source, term)
141
- end
142
- end
143
-
144
- def i18n_init(lang, script)
145
- super
146
- end
147
-
148
- def fileloc(loc)
149
- File.join(File.dirname(__FILE__), loc)
150
- end
151
-
152
95
  def authority_cleanup(docxml)
153
96
  dest = docxml.at("//div[@id = 'authority']") || return
154
97
  auth = docxml.at("//div[@class = 'authority']") || return
@@ -167,191 +110,6 @@ module IsoDoc
167
110
  docxml
168
111
  end
169
112
 
170
- def term_cleanup(docxml)
171
- docxml.xpath("//p[@class = 'Terms']").each do |d|
172
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
173
- h2.add_child("&nbsp;")
174
- h2.add_child(d.remove)
175
- end
176
- docxml
177
- end
178
-
179
- def requirement_cleanup(docxml)
180
- docxml.xpath("//div[@class = 'recommend' or @class = 'require' or "\
181
- "@class = 'permission'][title]").each do |d|
182
- title = d.at("./title")
183
- title.name = "b"
184
- n = title.next_element
185
- n&.children&.first&.add_previous_sibling(" ")
186
- n&.children&.first&.add_previous_sibling(title.remove)
187
- end
188
- docxml
189
- end
190
-
191
- def figure_parse(node, out)
192
- return pseudocode_parse(node, out) if node["type"] == "pseudocode"
193
- super
194
- end
195
-
196
- def pseudocode_parse(node, out)
197
- @in_figure = true
198
- name = node.at(ns("./name"))
199
- out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
200
- node.children.each do |n|
201
- parse(n, div) unless n.name == "name"
202
- end
203
- figure_name_parse(node, div, name) if name
204
- end
205
- @in_figure = false
206
- end
207
-
208
- def dl_parse(node, out)
209
- return glossary_parse(node, out) if node["type"] == "glossary"
210
- super
211
- end
212
-
213
- def glossary_parse(node, out)
214
- out.dl **attr_code(id: node["id"], class: "glossary") do |v|
215
- node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
216
- v.dt **attr_code(id: dt["id"]) do |term|
217
- dt_parse(dt, term)
218
- end
219
- v.dd **attr_code(id: dd["id"]) do |listitem|
220
- dd.children.each { |n| parse(n, listitem) }
221
- end
222
- end
223
- end
224
- node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
225
- end
226
-
227
- def error_parse(node, out)
228
- case node.name
229
- when "nistvariable" then nistvariable_parse(node, out)
230
- when "recommendation" then recommendation_parse(node, out)
231
- when "requirement" then requirement_parse(node, out)
232
- when "permission" then permission_parse(node, out)
233
- when "errata" then errata_parse(node, out)
234
- when "authority" then authority_parse(node, out)
235
- when "authority1" then authority1_parse(node, out, "authority1")
236
- when "authority2" then authority1_parse(node, out, "authority2")
237
- when "authority3" then authority1_parse(node, out, "authority3")
238
- when "authority4" then authority1_parse(node, out, "authority4")
239
- when "authority5" then authority1_parse(node, out, "authority5")
240
- else
241
- super
242
- end
243
- end
244
-
245
- def authority_parse(node, out)
246
- out.div **{class: "authority"} do |s|
247
- node.children.each do |n|
248
- if n.name == "title"
249
- s.h1 do |h|
250
- n.children.each { |nn| parse(nn, h) }
251
- end
252
- else
253
- parse(n, s)
254
- end
255
- end
256
- end
257
- end
258
- def authority1_parse(node, out, classname)
259
- out.div **{class: classname} do |s|
260
- node.children.each do |n|
261
- if n.name == "title"
262
- s.h2 do |h|
263
- n.children.each { |nn| parse(nn, h) }
264
- end
265
- else
266
- parse(n, s)
267
- end
268
- end
269
- end
270
- end
271
-
272
- def nistvariable_parse(node, out)
273
- out.span **{class: "nistvariable"} do |s|
274
- node.children.each { |n| parse(n, s) }
275
- end
276
- end
277
-
278
- def recommendation_parse(node, out)
279
- name = node["type"]
280
- out.div **{ class: "recommend" } do |t|
281
- t.title { |b| b << "Recommendation #{get_anchors[node['id']][:label]}:" }
282
- node.children.each do |n|
283
- parse(n, t)
284
- end
285
- end
286
- end
287
-
288
- def requirement_parse(node, out)
289
- name = node["type"]
290
- out.div **{ class: "require" } do |t|
291
- t.title { |b| b << "Requirement #{get_anchors[node['id']][:label]}:" }
292
- node.children.each do |n|
293
- parse(n, t)
294
- end
295
- end
296
- end
297
-
298
- def permission_parse(node, out)
299
- name = node["type"]
300
- out.div **{ class: "permission" } do |t|
301
- t.title { |b| b << "Permission #{get_anchors[node['id']][:label]}:" }
302
- node.children.each do |n|
303
- parse(n, t)
304
- end
305
- end
306
- end
307
-
308
- def errata_parse(node, out)
309
- out.table **make_table_attr(node) do |t|
310
- t.thead do |h|
311
- h.tr do |tr|
312
- %w(Date Type Change Pages).each do |hdr|
313
- tr.th hdr
314
- end
315
- end
316
- end
317
- t.tbody do |b|
318
- node.xpath(ns("./row")).each do |row|
319
- b.tr do |tr|
320
- tr.td do |td|
321
- row&.at(ns("./date"))&.children.each do |n|
322
- parse(n, td)
323
- end
324
- end
325
- tr.td do |td|
326
- row&.at(ns("./type"))&.children.each do |n|
327
- parse(n, td)
328
- end
329
- end
330
- tr.td do |td|
331
- row&.at(ns("./change"))&.children.each do |n|
332
- parse(n, td)
333
- end
334
- end
335
- tr.td do |td|
336
- row&.at(ns("./pages"))&.children.each do |n|
337
- parse(n, td)
338
- end
339
- end
340
- end
341
- end
342
- end
343
- end
344
- end
345
-
346
- MIDDLE_CLAUSE = "//clause[parent::sections]|//terms[parent::sections]".freeze
347
-
348
- def middle(isoxml, out)
349
- middle_title(out)
350
- clause isoxml, out
351
- bibliography isoxml, out
352
- annex isoxml, out
353
- end
354
-
355
113
  def bibliography(isoxml, out)
356
114
  f = isoxml.at(ns("//bibliography/clause | //bibliography/references")) || return
357
115
  page_break(out)
@@ -372,182 +130,27 @@ module IsoDoc
372
130
  end
373
131
  end
374
132
 
375
- def info(isoxml, out)
376
- @meta.keywords isoxml, out
377
- @meta.series isoxml, out
378
- @meta.commentperiod isoxml, out
379
- super
380
- end
381
-
382
- SECTIONS_XPATH =
383
- "//foreword | //introduction | //reviewnote | //execsummary | //annex | "\
384
- "//sections/clause | //bibliography/references | "\
385
- "//bibliography/clause".freeze
386
-
387
- def initial_anchor_names(d)
388
- d.xpath("//xmlns:preface/child::*").each do |c|
389
- preface_names(c)
390
- end
391
- sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
392
- clause_names(d, 0)
393
- middle_section_asset_names(d)
394
- termnote_anchor_names(d)
395
- termexample_anchor_names(d)
396
- end
397
-
398
- def back_anchor_names(docxml)
399
- docxml.xpath(ns("//annex")).each_with_index do |c, i|
400
- annex_names(c, (65 + i).chr.to_s)
401
- end
402
- docxml.xpath(ns("//bibliography/clause | "\
403
- "//bibliography/references")).each do |b|
404
- preface_names(b)
405
- end
406
- docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
407
- reference_names(ref)
408
- end
409
- end
410
-
411
- def middle_section_asset_names(d)
412
- middle_sections =
413
- "//xmlns:preface/child::* | //xmlns:sections/child::*"
414
- sequential_asset_names(d.xpath(middle_sections))
415
- end
416
-
417
- def sequential_asset_names(clause)
418
- super
419
- sequential_permission_names(clause)
420
- sequential_requirement_names(clause)
421
- sequential_recommendation_names(clause)
422
- end
423
-
424
- def sequential_permission_names(clause)
425
- clause.xpath(ns(".//permission")).each_with_index do |t, i|
426
- next if t["id"].nil? || t["id"].empty?
427
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Permission", "permission")
428
- end
429
- end
430
-
431
- def sequential_requirement_names(clause)
432
- clause.xpath(ns(".//requirement")).each_with_index do |t, i|
433
- next if t["id"].nil? || t["id"].empty?
434
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Requirement", "requirement")
435
- end
436
- end
437
-
438
- def sequential_recommendation_names(clause)
439
- clause.xpath(ns(".//recommendation")).each_with_index do |t, i|
440
- next if t["id"].nil? || t["id"].empty?
441
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Recommendation", "recommendation")
442
- end
443
- end
444
-
445
- def hierarchical_asset_names(clause, num)
446
- super
447
- hierarchical_permission_names(clause, num)
448
- hierarchical_requirement_names(clause, num)
449
- hierarchical_recommendation_names(clause, num)
450
- end
451
-
452
- def hierarchical_permission_names(clause, num)
453
- clause.xpath(ns(".//permission")).each_with_index do |t, i|
454
- next if t["id"].nil? || t["id"].empty?
455
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
456
- t, "Permission", "permission")
457
- end
458
- end
459
-
460
- def hierarchical_requirement_names(clause, num)
461
- clause.xpath(ns(".//requirement")).each_with_index do |t, i|
462
- next if t["id"].nil? || t["id"].empty?
463
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
464
- t, "Requirement", "requirement")
465
- end
466
- end
467
-
468
- def hierarchical_recommendation_names(clause, num)
469
- clause.xpath(ns(".//recommendation")).each_with_index do |t, i|
470
- next if t["id"].nil? || t["id"].empty?
471
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
472
- t, "Recommendation", "recommendation")
473
- end
474
- end
475
-
476
- def clause_names(docxml, sect_num)
477
- q = "//xmlns:sections/child::*"
478
- docxml.xpath(q).each_with_index do |c, i|
479
- section_names(c, (i + sect_num), 1)
480
- end
481
- end
482
-
483
- def get_linkend(node)
484
- link = anchor_linkend(node, docid_l10n(node["target"] || "[#{node['citeas']}]"))
485
- link += eref_localities(node.xpath(ns("./locality")), link)
486
- contents = node.children.select { |c| c.name != "locality" }
487
- return link if contents.nil? || contents.empty?
488
- Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
489
- # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
490
- # <locality type="section"><reference>3.1</reference></locality></origin>
491
- end
492
-
493
- def load_yaml(lang, script)
494
- y = if @i18nyaml then YAML.load_file(@i18nyaml)
495
- elsif lang == "en"
496
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
497
- else
498
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
499
- end
500
- super.merge(y)
501
- end
502
-
503
- def annex_name_lbl(clause, num)
504
- l10n("<b>#{@annex_lbl} #{num}</b>")
505
- end
506
-
507
- def annex_name(annex, name, div)
508
- div.h1 **{ class: "Annex" } do |t|
509
- t << "#{get_anchors[annex['id']][:label]} &mdash; "
510
- t.b do |b|
511
- if @bibliographycount == 1 && annex.at(ns("./references"))
512
- b << "References"
513
- else
514
- name&.children&.each { |c2| parse(c2, b) }
515
- end
133
+ def keywords(_docxml, out)
134
+ kw = @meta.get[:keywords]
135
+ kw.empty? and return
136
+ out.div **{ class: "Section3" } do |div|
137
+ out.div do |div|
138
+ clause_name(nil, "Keywords", div, class: "IntroTitle")
139
+ div.p kw.sort.join("; ")
516
140
  end
517
141
  end
518
142
  end
519
143
 
520
- def hiersep
521
- "-"
522
- end
523
-
524
- def annex_names(clause, num)
525
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
526
- xref: "#{@annex_lbl} #{num}", level: 1 }
527
- clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
528
- annex_names1(c, "#{num}.#{i + 1}", 2)
529
- end
530
- hierarchical_asset_names(clause, num)
531
- end
532
-
533
- def annex_names1(clause, num, level)
534
- @anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
535
- level: level, type: "clause" }
536
- clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
537
- annex_names1(c, "#{num}.#{i + 1}", level + 1)
538
- end
539
- end
540
-
541
- def terms_parse(node, out)
542
- out.div **attr_code(id: node["id"]) do |div|
543
- node.at(ns("./title")) and
544
- clause_parse_title(node, div, node.at(ns("./title")), out)
545
- term_defs_boilerplate(div, node.xpath(ns(".//termdocsource")),
546
- node.at(ns(".//term")), node.at(ns("./p")))
547
- node.elements.each do |e|
548
- parse(e, div) unless %w{title source}.include? e.name
144
+ def pseudocode_parse(node, out)
145
+ @in_figure = true
146
+ name = node.at(ns("./name"))
147
+ out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
148
+ node.children.each do |n|
149
+ parse(n, div) unless n.name == "name"
549
150
  end
151
+ figure_name_parse(node, div, name) if name
550
152
  end
153
+ @in_figure = false
551
154
  end
552
155
 
553
156
  def termdef_parse(node, out)
@@ -564,26 +167,16 @@ module IsoDoc
564
167
  end
565
168
 
566
169
  def term_cleanup(docxml)
567
- docxml.xpath("//dl[@class = 'terms_dl']").each do |d|
170
+ docxml.xpath("//table[@class = 'terms_dl']").each do |d|
568
171
  prev = d.previous_element
569
- next unless prev.name == "dl" and prev["class"] == "terms_dl"
172
+ next unless prev.name == "table" and prev["class"] == "terms_dl"
570
173
  d.children.each { |n| prev.add_child(n.remove) }
571
174
  d.remove
572
175
  end
573
176
  docxml
574
177
  end
575
178
 
576
- def bibliography_parse(node, out)
577
- title = node&.at(ns("./title"))&.text || ""
578
- out.div do |div|
579
- node.parent.name == "annex" or
580
- div.h2 title, **{ class: "Section3" }
581
- node.elements.reject do |e|
582
- ["reference", "title", "bibitem"].include? e.name
583
- end.each { |e| parse(e, div) }
584
- biblio_list(node, div, true)
585
- end
586
- end
179
+ include BaseConvert
587
180
  end
588
181
  end
589
182
  end