metanorma-nist 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,27 +19,16 @@
19
19
  -->
20
20
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
21
21
  <include href="reqt.rng"/>
22
- <include href="biblio.rng">
23
- <define name="status">
24
- <element name="status">
25
- <choice>
26
- <value>proposal</value>
27
- <value>working_draft</value>
28
- <value>committee_draft</value>
29
- <value>draft_standard</value>
30
- <value>final_draft</value>
31
- <value>published</value>
32
- <value>withdrawn</value>
33
- </choice>
34
- </element>
35
- </define>
36
- </include>
22
+ <include href="biblio.rng"/>
37
23
  <start>
38
24
  <ref name="standard-document"/>
39
25
  </start>
40
26
  <define name="standard-document">
41
27
  <element name="standard-document">
42
28
  <ref name="bibdata"/>
29
+ <optional>
30
+ <ref name="boilerplate"/>
31
+ </optional>
43
32
  <optional>
44
33
  <ref name="preface"/>
45
34
  </optional>
@@ -64,6 +53,42 @@
64
53
  </oneOrMore>
65
54
  </element>
66
55
  </define>
56
+ <define name="boilerplate">
57
+ <element name="boilerplate">
58
+ <optional>
59
+ <ref name="copyright-statement"/>
60
+ </optional>
61
+ <optional>
62
+ <ref name="license-statement"/>
63
+ </optional>
64
+ <optional>
65
+ <ref name="legal-statement"/>
66
+ </optional>
67
+ <optional>
68
+ <ref name="feedback-statement"/>
69
+ </optional>
70
+ </element>
71
+ </define>
72
+ <define name="copyright-statement">
73
+ <element name="copyright-statement">
74
+ <ref name="Content-Section"/>
75
+ </element>
76
+ </define>
77
+ <define name="license-statement">
78
+ <element name="license-statement">
79
+ <ref name="Content-Section"/>
80
+ </element>
81
+ </define>
82
+ <define name="legal-statement">
83
+ <element name="legal-statement">
84
+ <ref name="Content-Section"/>
85
+ </element>
86
+ </define>
87
+ <define name="feedback-statement">
88
+ <element name="feedback-statement">
89
+ <ref name="Content-Section"/>
90
+ </element>
91
+ </define>
67
92
  <define name="sections">
68
93
  <element name="sections">
69
94
  <oneOrMore>
@@ -533,6 +558,9 @@
533
558
  <attribute name="id">
534
559
  <data type="ID"/>
535
560
  </attribute>
561
+ <optional>
562
+ <attribute name="alt"/>
563
+ </optional>
536
564
  <optional>
537
565
  <ref name="tname"/>
538
566
  </optional>
@@ -868,6 +896,9 @@
868
896
  <attribute name="type">
869
897
  <ref name="ReferenceFormat"/>
870
898
  </attribute>
899
+ <optional>
900
+ <attribute name="alt"/>
901
+ </optional>
871
902
  <text/>
872
903
  </element>
873
904
  </define>
@@ -268,22 +268,6 @@
268
268
  <ref name="FormattedString"/>
269
269
  </element>
270
270
  </define>
271
- <define name="status">
272
- <element name="status">
273
- <choice>
274
- <ref name="FormattedString"/>
275
- <group>
276
- <ref name="stage"/>
277
- <optional>
278
- <ref name="substage"/>
279
- </optional>
280
- <optional>
281
- <ref name="iteration"/>
282
- </optional>
283
- </group>
284
- </choice>
285
- </element>
286
- </define>
287
271
  <define name="btitle">
288
272
  <element name="title">
289
273
  <choice>
@@ -756,6 +740,9 @@
756
740
  <zeroOrMore>
757
741
  <ref name="termdocsource"/>
758
742
  </zeroOrMore>
743
+ <optional>
744
+ <ref name="boilerplate"/>
745
+ </optional>
759
746
  <ref name="preface"/>
760
747
  <oneOrMore>
761
748
  <ref name="sections"/>
@@ -817,40 +804,6 @@
817
804
  <ref name="Content-Section"/>
818
805
  </element>
819
806
  </define>
820
- <define name="stage">
821
- <element name="stage">
822
- <choice>
823
- <value>00</value>
824
- <value>10</value>
825
- <value>20</value>
826
- <value>30</value>
827
- <value>40</value>
828
- <value>50</value>
829
- <value>60</value>
830
- <value>90</value>
831
- <value>95</value>
832
- </choice>
833
- </element>
834
- </define>
835
- <define name="substage">
836
- <element name="substage">
837
- <choice>
838
- <value>00</value>
839
- <value>20</value>
840
- <value>60</value>
841
- <value>90</value>
842
- <value>92</value>
843
- <value>93</value>
844
- <value>98</value>
845
- <value>99</value>
846
- </choice>
847
- </element>
848
- </define>
849
- <define name="iteration">
850
- <element name="iteration">
851
- <data type="int"/>
852
- </element>
853
- </define>
854
807
  <define name="documentnumber">
855
808
  <element name="project-number">
856
809
  <optional>
@@ -62,17 +62,6 @@
62
62
  </choice>
63
63
  </element>
64
64
  </define>
65
- <define name="status">
66
- <element name="status">
67
- <ref name="stage"/>
68
- <optional>
69
- <ref name="substage"/>
70
- </optional>
71
- <optional>
72
- <ref name="iteration"/>
73
- </optional>
74
- </element>
75
- </define>
76
65
  <define name="BibItemType" combine="choice">
77
66
  <value>standard</value>
78
67
  </define>
@@ -171,7 +160,6 @@
171
160
  </define>
172
161
  <define name="preface">
173
162
  <element name="preface">
174
- <ref name="authority"/>
175
163
  <optional>
176
164
  <ref name="preface_abstract"/>
177
165
  </optional>
@@ -420,32 +408,6 @@
420
408
  <ref name="Basic-Section"/>
421
409
  </element>
422
410
  </define>
423
- <define name="authority">
424
- <element name="authority">
425
- <optional>
426
- <element name="title">
427
- <text/>
428
- </element>
429
- </optional>
430
- <element name="authority1">
431
- <ref name="Basic-Section"/>
432
- </element>
433
- <element name="authority2">
434
- <ref name="Basic-Section"/>
435
- </element>
436
- <element name="authority3">
437
- <ref name="Basic-Section"/>
438
- </element>
439
- <optional>
440
- <element name="authority4">
441
- <ref name="Basic-Section"/>
442
- </element>
443
- </optional>
444
- <element name="authority5">
445
- <ref name="Basic-Section"/>
446
- </element>
447
- </element>
448
- </define>
449
411
  <define name="revision">
450
412
  <element name="revision">
451
413
  <text/>
@@ -457,6 +419,9 @@
457
419
  <zeroOrMore>
458
420
  <ref name="termdocsource"/>
459
421
  </zeroOrMore>
422
+ <optional>
423
+ <ref name="boilerplate"/>
424
+ </optional>
460
425
  <ref name="preface"/>
461
426
  <oneOrMore>
462
427
  <ref name="sections"/>
@@ -1,33 +1,36 @@
1
- <authority>
2
- <title>Authority</title>
1
+ <boilerplate>
2
+ <legal-statement>
3
3
 
4
- <authority1>
4
+ <clause id="authority1">
5
+ <title>Authority</title>
5
6
  <p>This publication has been developed by NIST in accordance with its statutory responsibilities under the Federal Information Security Modernization Act (FISMA) of 2014, 44 U.S.C. &#xa7; 3551 <em>et seq.</em>, Public Law (P.L.) 113-283. NIST is responsible for developing information security standards and guidelines, including minimum requirements for federal information systems, but such standards and guidelines shall not apply to national security systems without the express approval of appropriate federal officials exercising policy authority over such systems. This guideline is consistent with the requirements of the Office of Management and Budget (OMB) Circular A-130.</p>
6
7
 
7
8
  <p>Nothing in this publication should be taken to contradict the standards and guidelines made mandatory and binding on federal agencies by the Secretary of Commerce under statutory authority. Nor should these guidelines be interpreted as altering or superseding the existing authorities of the Secretary of Commerce, Director of the OMB, or any other federal official. This publication may be used by nongovernmental organizations on a voluntary basis and is not subject to copyright in the United States. Attribution would, however, be appreciated by NIST.</p>
8
- </authority1>
9
+ </clause>
9
10
 
10
- <authority2>
11
- <p align="center">National Institute of Standards and Technology {{ docidentifier_long | remove: "NIST " }} <br/>
12
- Natl. Inst. Stand. Technol. {{ docidentifier | remove: "NIST " | replace: " Volume ", " Vol. " }}, ({{ revdate_monthyear }}) <br/>
11
+ <clause id="authority2">
12
+ <p align="center">National Institute of Standards and Technology {{ docidentifier_long_undated | remove: "NIST " }} <br/>
13
+ Natl. Inst. Stand. Technol. {{ docidentifier_undated | remove: "NIST " | replace: " Volume ", " Vol. " }}, ({{ most_recent_date_monthyear }}{% if updateddate_mmddyyyy %}, including updates as of {{updateddate_mmddyyyy}}{% endif %}) <br/>
13
14
  CODEN: NSPUE2</p>
14
15
 
15
16
  {% if doi %}
16
17
  <p align="center">This publication is available free of charge from: <br/>
17
18
  <link target="{{doi}}"/></p>
18
19
  {% endif %}
19
- </authority2>
20
+ </clause>
20
21
 
21
- <authority3>
22
+ <clause id="authority3">
22
23
  <p>Any mention of commercial products or reference to commercial organizations is for information only; it does not imply recommendation or endorsement by the United States Government, nor does it imply that the products mentioned are necessarily the best available for the purpose.</p>
23
24
 
24
25
  <p>There may be references in this publication to other publications currently under development by NIST in accordance with its assigned statutory responsibilities. The information in this publication, including concepts and methodologies, may be used by Federal agencies even before the completion of such companion publications. Thus, until each publication is completed, current requirements, guidelines, and procedures, where they exist, remain operative. For planning and transition purposes, Federal agencies may wish to closely follow the development of these new publications by NIST.</p>
25
26
 
26
27
  <p>Organizations are encouraged to review all draft publications during public comment periods and provide feedback to NIST. Many NIST cybersecurity publications, other than the ones noted above, are available at <link target="https://csrc.nist.gov/publications"/>
27
- </authority3>
28
+ </clause>
29
+ </legal-statement>
28
30
 
31
+ <feedback-statement>
29
32
  {% if unpublished %}
30
- <authority4>
33
+ <clause id="authority4">
31
34
  {% if comment_extended %}
32
35
  <p align="center">[{{ comment_extended}}: Comment period extended]</p>
33
36
  {% endif %}
@@ -39,10 +42,10 @@ CODEN: NSPUE2</p>
39
42
  <p align="center"><strong>Public comment period: from <em>{{ comment_from }}</em></strong></p>
40
43
  {% endif %}
41
44
  {% endif %}
42
- </authority4>
45
+ </clause>
43
46
  {% endif %}
44
47
 
45
- <authority5>
48
+ <clause id="authority5">
46
49
  <p align="center"><strong>Comments on this publication may be submitted to:</strong></p>
47
50
 
48
51
  <p align="center">National Institute of Standards and Technology <br/>
@@ -53,5 +56,6 @@ CODEN: NSPUE2</p>
53
56
  {% endif %}</p>
54
57
 
55
58
  <p align="center">All comments are subject to release under the Freedom of Information Act (FOIA).</p>
56
- </authority5>
57
- </authority>
59
+ </clause>
60
+ </feedback-statement>
61
+ </boilerplate>
@@ -23,15 +23,13 @@ module IsoDoc
23
23
  end
24
24
  end
25
25
 
26
- FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract')]".freeze
26
+ FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or local-name() = 'foreword')]".freeze
27
27
 
28
- # All "[preface]" sections should have class "IntroTitle" to prevent
28
+ # All "[preface]" sections should have class "IntroTitle" to prevent
29
29
  # page breaks
30
30
  # But for the Exec Summary
31
31
  def preface(isoxml, out)
32
32
  isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
33
- foreword(isoxml, out) and next if c.name == "foreword"
34
- authority_parse(c, out) and next if c.name == "authority"
35
33
  next if skip_render(c, isoxml)
36
34
  title = c&.at(ns("./title"))
37
35
  patent = ["Call for Patent Claims", "Patent Disclosure Notice"].include? title&.text
@@ -113,20 +111,17 @@ module IsoDoc
113
111
  when "requirement" then requirement_parse(node, out)
114
112
  when "permission" then permission_parse(node, out)
115
113
  when "errata" then errata_parse(node, out)
116
- when "authority" then authority_parse(node, out)
117
- when "authority1" then authority1_parse(node, out, "authority1")
118
- when "authority2" then authority1_parse(node, out, "authority2")
119
- when "authority3" then authority1_parse(node, out, "authority3")
120
- when "authority4" then authority1_parse(node, out, "authority4")
121
- when "authority5" then authority1_parse(node, out, "authority5")
114
+ when "legal-statement" then children_parse(node, out)
115
+ when "feedback-statement" then children_parse(node, out)
122
116
  else
123
117
  super
124
118
  end
125
119
  end
126
120
 
127
- def authority_parse(node, out)
121
+ def boilerplate(node, out)
122
+ boilerplate = node.at(ns("//boilerplate")) or return
128
123
  out.div **{class: "authority"} do |s|
129
- node.children.each do |n|
124
+ boilerplate.children.each do |n|
130
125
  if n.name == "title"
131
126
  s.h1 do |h|
132
127
  n.children.each { |nn| parse(nn, h) }
@@ -136,19 +131,12 @@ module IsoDoc
136
131
  end
137
132
  end
138
133
  end
134
+ page_break(out)
139
135
  end
140
136
 
141
- def authority1_parse(node, out, classname)
142
- out.div **{class: classname} do |s|
143
- node.children.each do |n|
144
- if n.name == "title"
145
- s.h2 do |h|
146
- n.children.each { |nn| parse(nn, h) }
147
- end
148
- else
149
- parse(n, s)
150
- end
151
- end
137
+ def children_parse(node, out)
138
+ node.children.each do |n|
139
+ parse(n, out)
152
140
  end
153
141
  end
154
142
 
@@ -201,24 +189,11 @@ module IsoDoc
201
189
  t.tbody do |b|
202
190
  node.xpath(ns("./row")).each do |row|
203
191
  b.tr do |tr|
204
- tr.td do |td|
205
- row&.at(ns("./date"))&.children.each do |n|
206
- parse(n, td)
207
- end
208
- end
209
- tr.td do |td|
210
- row&.at(ns("./type"))&.children.each do |n|
211
- parse(n, td)
212
- end
213
- end
214
- tr.td do |td|
215
- row&.at(ns("./change"))&.children.each do |n|
216
- parse(n, td)
217
- end
218
- end
219
- tr.td do |td|
220
- row&.at(ns("./pages"))&.children.each do |n|
221
- parse(n, td)
192
+ %w{date type change pages}.each do |hdr|
193
+ tr.td do |td|
194
+ row&.at(ns("./#{hdr}"))&.children.each do |n|
195
+ parse(n, td)
196
+ end
222
197
  end
223
198
  end
224
199
  end
@@ -252,10 +227,12 @@ module IsoDoc
252
227
  "//bibliography/clause".freeze
253
228
 
254
229
  def initial_anchor_names(d)
255
- d.xpath("//xmlns:preface/child::*").each do |c|
230
+ d.xpath("//xmlns:boilerplate/child::* | //xmlns:preface/child::*").each do |c|
256
231
  preface_names(c)
257
232
  end
258
- sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
233
+ @in_execsummary = true
234
+ hierarchical_asset_names(d.xpath("//xmlns:executivesummary"), "ES")
235
+ @in_execsummary = false
259
236
  clause_names(d, 0)
260
237
  middle_section_asset_names(d)
261
238
  termnote_anchor_names(d)
@@ -276,71 +253,11 @@ module IsoDoc
276
253
  end
277
254
 
278
255
  def middle_section_asset_names(d)
279
- middle_sections =
280
- "//xmlns:preface/child::* | //xmlns:sections/child::*"
256
+ middle_sections = "//xmlns:preface/child::*[not(self::xmlns:executivesummary)] | "\
257
+ "//xmlns:sections/child::*"
281
258
  sequential_asset_names(d.xpath(middle_sections))
282
259
  end
283
260
 
284
- def sequential_asset_names(clause)
285
- super
286
- sequential_permission_names(clause)
287
- sequential_requirement_names(clause)
288
- sequential_recommendation_names(clause)
289
- end
290
-
291
- def sequential_permission_names(clause)
292
- clause.xpath(ns(".//permission")).each_with_index do |t, i|
293
- next if t["id"].nil? || t["id"].empty?
294
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Permission", "permission")
295
- end
296
- end
297
-
298
- def sequential_requirement_names(clause)
299
- clause.xpath(ns(".//requirement")).each_with_index do |t, i|
300
- next if t["id"].nil? || t["id"].empty?
301
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Requirement", "requirement")
302
- end
303
- end
304
-
305
- def sequential_recommendation_names(clause)
306
- clause.xpath(ns(".//recommendation")).each_with_index do |t, i|
307
- next if t["id"].nil? || t["id"].empty?
308
- @anchors[t["id"]] = anchor_struct(i + 1, t, "Recommendation", "recommendation")
309
- end
310
- end
311
-
312
-
313
- def hierarchical_asset_names(clause, num)
314
- super
315
- hierarchical_permission_names(clause, num)
316
- hierarchical_requirement_names(clause, num)
317
- hierarchical_recommendation_names(clause, num)
318
- end
319
-
320
- def hierarchical_permission_names(clause, num)
321
- clause.xpath(ns(".//permission")).each_with_index do |t, i|
322
- next if t["id"].nil? || t["id"].empty?
323
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
324
- t, "Permission", "permission")
325
- end
326
- end
327
-
328
- def hierarchical_requirement_names(clause, num)
329
- clause.xpath(ns(".//requirement")).each_with_index do |t, i|
330
- next if t["id"].nil? || t["id"].empty?
331
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
332
- t, "Requirement", "requirement")
333
- end
334
- end
335
-
336
- def hierarchical_recommendation_names(clause, num)
337
- clause.xpath(ns(".//recommendation")).each_with_index do |t, i|
338
- next if t["id"].nil? || t["id"].empty?
339
- @anchors[t["id"]] = anchor_struct("#{num}.#{i + 1}",
340
- t, "Recommendation", "recommendation")
341
- end
342
- end
343
-
344
261
  def clause_names(docxml, sect_num)
345
262
  q = "//xmlns:sections/child::*"
346
263
  docxml.xpath(q).each_with_index do |c, i|
@@ -392,9 +309,12 @@ module IsoDoc
392
309
  def annex_names(clause, num)
393
310
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
394
311
  xref: "#{@annex_lbl} #{num}", level: 1 }
395
- clause.xpath(ns("./clause | ./terms | ./term | ./references")).each_with_index do |c, i|
312
+ clause.xpath(ns("./clause")).each_with_index do |c, i|
396
313
  annex_names1(c, "#{num}.#{i + 1}", 2)
397
314
  end
315
+ clause.xpath(ns("./terms | ./term | ./references")).each_with_index do |c, i|
316
+ annex_names1(c, "#{num}", 1)
317
+ end
398
318
  hierarchical_asset_names(clause, num)
399
319
  end
400
320
 
@@ -429,6 +349,66 @@ module IsoDoc
429
349
  biblio_list(node, div, true)
430
350
  end
431
351
  end
352
+
353
+ NIST_PUBLISHER_XPATH =
354
+ "./contributor[xmlns:role/@type = 'publisher']/"\
355
+ "organization[abbreviation = 'NIST' or xmlns:name = 'NIST']".freeze
356
+
357
+ # we are taking the ref number/code out as prefix to reference
358
+ def noniso_bibitem(list, b, ordinal, bibliography)
359
+ list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
360
+ if !b.at(ns("./formattedref"))
361
+ nist_reference_format(b, r)
362
+ else
363
+ reference_format(b, r)
364
+ end
365
+ end
366
+ end
367
+
368
+ def reference_format(b, r)
369
+ if ftitle = b.at(ns("./formattedref"))
370
+ ftitle&.children&.each { |n| parse(n, r) }
371
+ else
372
+ title = b.at(ns("./title[@language = '#{@language}']")) || b.at(ns("./title"))
373
+ r.i do |i|
374
+ title&.children&.each { |n| parse(n, i) }
375
+ end
376
+ end
377
+ r << "[#{iso_bibitem_ref_code(b)}] "
378
+ end
379
+
380
+ def omit_docid_prefix(prefix)
381
+ return true if prefix.nil? || prefix.empty?
382
+ return ["ISO", "IEC", "nist"].include? prefix
383
+ end
384
+
385
+ def nist_reference_format(b, r)
386
+ bibitem = b.dup.to_xml
387
+ r.parent.add_child ::Iso690Render.render(bibitem, true)
388
+ end
389
+
390
+ def pseudocode_parse(node, out)
391
+ @in_figure = true
392
+ name = node.at(ns("./name"))
393
+ out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
394
+ node.children.each do |n|
395
+ parse(n, div) unless n.name == "name"
396
+ end
397
+ figure_name_parse(node, div, name)
398
+ end
399
+ @in_figure = false
400
+ end
401
+
402
+ def foreword(isoxml, out)
403
+ f = isoxml.at(ns("//foreword")) || return
404
+ out.div **attr_code(id: f["id"]) do |s|
405
+ title = f.at(ns("./title"))
406
+ s.h1(**{ class: "ForewordTitle" }) do |h1|
407
+ title and title.children.each { |e| parse(e, h1) }
408
+ end
409
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
410
+ end
411
+ end
432
412
  end
433
413
  end
434
414
  end