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.
@@ -11,7 +11,16 @@ module Asciidoctor
11
11
  class Converter < Standoc::Converter
12
12
 
13
13
  def datetypes
14
- super << "abandoned"
14
+ super + %w(abandoned superseded)
15
+ end
16
+
17
+ def metadata_version(node, xml)
18
+ xml.edition node.attr("edition") if node.attr("edition")
19
+ xml.revision node.attr("revision") if node.attr("revision")
20
+ xml.version do |v|
21
+ v.revision_date node.attr("revdate") if node.attr("revdate")
22
+ v.draft node.attr("draft") if node.attr("draft")
23
+ end
15
24
  end
16
25
 
17
26
  def title_subtitle(node, t, at)
@@ -19,6 +28,10 @@ module Asciidoctor
19
28
  t.title(**attr_code(at.merge(type: "subtitle"))) do |t1|
20
29
  t1 << asciidoc_sub(node.attr("title-sub"))
21
30
  end
31
+ node.attr("title-sub-short") and
32
+ t.title(**attr_code(at.merge(type: "short-subtitle"))) do |t1|
33
+ t1 << asciidoc_sub(node.attr("title-sub-short"))
34
+ end
22
35
  end
23
36
 
24
37
  def title_document_class(node, t, at)
@@ -32,6 +45,10 @@ module Asciidoctor
32
45
  t.title(**attr_code(at.merge(type: "main"))) do |t1|
33
46
  t1 << asciidoc_sub(node.attr("title-main") || node.title)
34
47
  end
48
+ node.attr("title-main-short") and
49
+ t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
50
+ t1 << asciidoc_sub(node.attr("title-main-short"))
51
+ end
35
52
  end
36
53
 
37
54
  def title(node, xml)
@@ -63,22 +80,34 @@ module Asciidoctor
63
80
 
64
81
  def metadata_id_compose(node, xml, dn0)
65
82
  return unless dn0
66
- dn = add_id_parts(dn0, node.attr("series"), node.attr("edition"), false)
67
- dn_long = add_id_parts(dn0, node.attr("series"), node.attr("edition"),
68
- true)
69
- xml.docidentifier dn, **attr_code(type: "nist")
70
- xml.docidentifier dn_long, **attr_code(type: "nist-long")
83
+ s = node.attr("series")
84
+ e = node.attr("revision")
85
+ v = node.attr("volume")
86
+ xml.docidentifier add_id_parts(dn0, s, e, v, false),
87
+ **attr_code(type: "nist")
88
+ xml.docidentifier add_id_parts(dn0, s, e, v, true),
89
+ **attr_code(type: "nist-long")
90
+ xml.docidentifier add_id_parts_mr(dn0, s, e, v, node.attr("revdate")),
91
+ **attr_code(type: "nist-mr")
71
92
  end
72
93
 
73
- def add_id_parts(dn, series, edition, long)
94
+ def add_id_parts(dn, series, revision, vol, long)
95
+ vol_delim = " Volume "
74
96
  ed_delim = " Revision "
75
97
  series and series_name = long ? SERIES.dig(series.to_sym) :
76
98
  SERIES_ABBR.dig(series.to_sym)
77
99
  dn = (series_name || "NIST #{series}") + " " + dn
78
- dn += "#{ed_delim}#{edition}" if edition
100
+ dn += "#{vol_delim}#{vol}" if vol
101
+ dn += "," if vol && revision
102
+ dn += "#{ed_delim}#{revision}" if revision
79
103
  dn
80
104
  end
81
105
 
106
+ def add_id_parts_mr(dn, series, revision, vol, revdate)
107
+ series and name = SERIES_ABBR.dig(series.to_sym).sub(/^NIST /, "")
108
+ "NIST.#{name}.#{vol}.#{revision}.#{revdate}"
109
+ end
110
+
82
111
  def metadata_author(node, xml)
83
112
  personal_author(node, xml)
84
113
  end
@@ -88,13 +117,18 @@ module Asciidoctor
88
117
  c.role **{ type: "publisher" }
89
118
  c.organization do |a|
90
119
  a.name "NIST"
120
+ d = node.attr("nist-division") and a.subdivision d
91
121
  end
92
122
  end
93
123
  end
94
124
 
95
125
  def metadata_committee(node, xml)
126
+ return unless node.attr("technical-committee") ||
127
+ node.attr("subcommittee") ||
128
+ node.attr("workgroup") || node.attr("workinggroup")
96
129
  xml.editorialgroup do |a|
97
- a.committee(node.attr("technical-committee"))
130
+ node.attr("technical-committee") and
131
+ a.committee(node.attr("technical-committee"))
98
132
  node.attr("subcommittee") and
99
133
  a.subcommittee(node.attr("subcommittee"),
100
134
  **attr_code(type: node.attr("subcommittee-type"),
@@ -110,6 +144,7 @@ module Asciidoctor
110
144
  status = node.attr("status") || "final"
111
145
  xml.status do |s|
112
146
  s.stage status
147
+ s.substage (node.attr("substage") || "active")
113
148
  s.iteration node.attr("iteration") if node.attr("iteration")
114
149
  end
115
150
  end
@@ -161,68 +196,94 @@ module Asciidoctor
161
196
  end
162
197
  end
163
198
 
199
+ def relaton_relations
200
+ super + %w(obsoletes obsoleted-by supersedes superseded-by)
201
+ end
202
+
164
203
  def metadata_getrelation(node, xml, type)
165
- docs = node.attr(type) || return
166
- docs.split(/,/).each do |d|
167
- xml.relation **{ type: type.sub(/-by$/, "By") } do |r|
168
- fetch_ref(r, d, nil, {})
204
+ if type == "obsoleted-by" and node.attr("superseding-status")
205
+ metadata_superseding_doc(node, xml)
206
+ else
207
+ super
208
+ end
209
+ end
210
+
211
+ def metadata_superseding_doc(node, xml)
212
+ xml.relation **{ type: "obsoletedBy" } do |r|
213
+ r.bibitem do |b|
214
+ metadata_superseding_titles(b, node)
215
+ doi = node.attr("superseding-doi") and
216
+ b.uri doi, **{ type: "doi" }
217
+ url = node.attr("superseding-url") and
218
+ b.uri url, **{ type: "uri" }
219
+ did = xml&.parent&.at("./ancestor::bibdata/docidentifier"\
220
+ "[@type = 'nist']")&.text
221
+ didl = xml&.parent&.at("./ancestor::bibdata/docidentifier"\
222
+ "[@type = 'nist-long']")&.text
223
+ b.docidentifier did, **{ type: "nist" }
224
+ b.docidentifier didl, **{ type: "nist-long" }
225
+ metadata_superseding_authors(b, node)
226
+ metadata_superseding_dates(b, node)
227
+ b.status do |s|
228
+ s.stage node.attr("superseding-status")
229
+ iter = node.attr("superseding-iteration") and
230
+ s.iteration iter
231
+ end
169
232
  end
170
233
  end
171
234
  end
172
235
 
173
- SERIES = {
174
- "nist-ams": "NIST Advanced Manufacturing Series",
175
- "building-science": "NIST Building Science Series",
176
- "nist-fips": "NIST Federal Information Processing Standards",
177
- "nist-gcr": "NIST Grant/Contract Reports",
178
- "nist-hb": "NIST Handbook",
179
- "itl-bulletin": "ITL Bulletin",
180
- "jpcrd": "Journal of Physical and Chemical Reference Data",
181
- "nist-jres": "NIST Journal of Research",
182
- "letter-circular": "NIST Letter Circular",
183
- "nist-monograph": "NIST Monograph",
184
- "nist-ncstar": "NIST National Construction Safety Team Act Reports",
185
- "nist-nsrds": "NIST National Standard Reference Data Series",
186
- "nistir": "NIST Interagency/Internal Report",
187
- "product-standards": "NIST Product Standards",
188
- "nist-sp": "NIST Special Publication",
189
- "nist-tn": "NIST Technical Note",
190
- "other": "NIST Other",
191
- "csrc-white-paper": "CSRC White Paper",
192
- "csrc-book": "CSRC Book",
193
- "csrc-use-case": "CSRC Use Case",
194
- "csrc-building-block": "CSRC Building Block",
195
- }.freeze
196
-
197
- SERIES_ABBR = {
198
- "nist-ams": "NIST AMS",
199
- "building-science": "NIST Building Science Series",
200
- "nist-fips": "NIST FIPS",
201
- "nist-gcr": "NISTGCR",
202
- "nist-hb": "NIST HB",
203
- "itl-bulletin": "ITL Bulletin",
204
- "jpcrd": "JPCRD",
205
- "nist-jres": "NIST JRES",
206
- "letter-circular": "NIST Letter Circular",
207
- "nist-monograph": "NIST MN",
208
- "nist-ncstar": "NIST NCSTAR",
209
- "nist-nsrds": "NIST NSRDS",
210
- "nistir": "NISTIR",
211
- "product-standards": "NIST Product Standards",
212
- "nist-sp": "NIST SP",
213
- "nist-tn": "NIST TN",
214
- "other": "NIST Other",
215
- "csrc-white-paper": "CSRC White Paper",
216
- "csrc-book": "CSRC Book",
217
- "csrc-use-case": "CSRC Use Case",
218
- "csrc-building-block": "CSRC Building Block",
219
- }.freeze
236
+ def metadata_superseding_dates(b, node)
237
+ cdate = node.attr("superseding-circulated-date") and
238
+ b.date **{ type: "circulated" } do |d|
239
+ d.on cdate
240
+ end
241
+ cdate = node.attr("superseding-published-date") and
242
+ b.date **{ type: "published" } do |d|
243
+ d.on cdate
244
+ end
245
+ end
246
+
247
+ def metadata_superseding_titles(b, node)
248
+ if node.attr("superseding-title")
249
+ b.title asciidoc_sub(node.attr("superseding-title")),
250
+ **{ type: "main" }
251
+ node.attr("superseding-subtitle") and
252
+ b.title asciidoc_sub(node.attr("superseding-subtitle")),
253
+ **{ type: "subtitle" }
254
+ else
255
+ b.title asciidoc_sub(node.attr("title-main") || node.title),
256
+ **{ type: "main" }
257
+ node.attr("title-sub") and
258
+ b.title asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
259
+ end
260
+ end
261
+
262
+ def metadata_superseding_authors(b, node)
263
+ node.attr("superseding-authors") and
264
+ node.attr("superseding-authors").split(/,\s*/).each do |a|
265
+ b.contributor do |c|
266
+ c.role nil, **{ type: "author" }
267
+ c.person do |p|
268
+ p.name do |f|
269
+ f.completename a
270
+ end
271
+ end
272
+ end
273
+ end
274
+ end
275
+
276
+ def metadata_note(node, xml)
277
+ note = node.attr("bib-additional-note") and
278
+ xml.note note, **{ type: "additional-note" }
279
+ note = node.attr("bib-withdrawal-note") and
280
+ xml.note note, **{ type: "withdrawal-note" }
281
+ note = node.attr("bib-withdrawal-announcement-link") and
282
+ xml.note note, **{ type: "withdrawal-announcement-link" }
283
+ end
220
284
 
221
285
  def metadata(node, xml)
222
286
  super
223
- %w(obsoletes obsoleted-by supersedes superseded-by).each do |t|
224
- metadata_getrelation(node, xml, t)
225
- end
226
287
  metadata_series(node, xml)
227
288
  metadata_keywords(node, xml)
228
289
  metadata_commentperiod(node, xml)
@@ -735,6 +735,20 @@
735
735
  <ref name="bookmark"/>
736
736
  </choice>
737
737
  </define>
738
+ <define name="PureTextElement">
739
+ <choice>
740
+ <text/>
741
+ <ref name="em"/>
742
+ <ref name="strong"/>
743
+ <ref name="sub"/>
744
+ <ref name="sup"/>
745
+ <ref name="tt"/>
746
+ <ref name="keyword"/>
747
+ <ref name="strike"/>
748
+ <ref name="smallcap"/>
749
+ <ref name="br"/>
750
+ </choice>
751
+ </define>
738
752
  <define name="source">
739
753
  <element name="source">
740
754
  <ref name="TypedUri"/>
@@ -742,42 +756,58 @@
742
756
  </define>
743
757
  <define name="em">
744
758
  <element name="em">
745
- <text/>
759
+ <zeroOrMore>
760
+ <ref name="PureTextElement"/>
761
+ </zeroOrMore>
746
762
  </element>
747
763
  </define>
748
764
  <define name="strong">
749
765
  <element name="strong">
750
- <text/>
766
+ <zeroOrMore>
767
+ <ref name="PureTextElement"/>
768
+ </zeroOrMore>
751
769
  </element>
752
770
  </define>
753
771
  <define name="tt">
754
772
  <element name="tt">
755
- <text/>
773
+ <zeroOrMore>
774
+ <ref name="PureTextElement"/>
775
+ </zeroOrMore>
756
776
  </element>
757
777
  </define>
758
778
  <define name="keyword">
759
779
  <element name="keyword">
760
- <text/>
780
+ <zeroOrMore>
781
+ <ref name="PureTextElement"/>
782
+ </zeroOrMore>
761
783
  </element>
762
784
  </define>
763
785
  <define name="sub">
764
786
  <element name="sub">
765
- <text/>
787
+ <zeroOrMore>
788
+ <ref name="PureTextElement"/>
789
+ </zeroOrMore>
766
790
  </element>
767
791
  </define>
768
792
  <define name="sup">
769
793
  <element name="sup">
770
- <text/>
794
+ <zeroOrMore>
795
+ <ref name="PureTextElement"/>
796
+ </zeroOrMore>
771
797
  </element>
772
798
  </define>
773
799
  <define name="strike">
774
800
  <element name="strike">
775
- <text/>
801
+ <zeroOrMore>
802
+ <ref name="PureTextElement"/>
803
+ </zeroOrMore>
776
804
  </element>
777
805
  </define>
778
806
  <define name="smallcap">
779
807
  <element name="smallcap">
780
- <text/>
808
+ <zeroOrMore>
809
+ <ref name="PureTextElement"/>
810
+ </zeroOrMore>
781
811
  </element>
782
812
  </define>
783
813
  <define name="br">
@@ -4,14 +4,6 @@
4
4
  <start>
5
5
  <ref name="iso-standard"/>
6
6
  </start>
7
- <define name="language">
8
- <element name="language">
9
- <choice>
10
- <value>en</value>
11
- <value>fr</value>
12
- </choice>
13
- </element>
14
- </define>
15
7
  <define name="script">
16
8
  <element name="script">
17
9
  <value>Latn</value>
@@ -9,9 +9,9 @@
9
9
  <start>
10
10
  <ref name="nist-standard"/>
11
11
  </start>
12
- <define name="language">
13
- <element name="language">
14
- <value>en</value>
12
+ <define name="btitle">
13
+ <element name="title">
14
+ <ref name="TypedTitleString"/>
15
15
  </element>
16
16
  </define>
17
17
  <define name="docidentifier">
@@ -65,6 +65,9 @@
65
65
  <define name="status">
66
66
  <element name="status">
67
67
  <ref name="stage"/>
68
+ <optional>
69
+ <ref name="substage"/>
70
+ </optional>
68
71
  <optional>
69
72
  <ref name="iteration"/>
70
73
  </optional>
@@ -73,18 +76,60 @@
73
76
  <define name="BibItemType" combine="choice">
74
77
  <value>standard</value>
75
78
  </define>
76
- <define name="DocRelationType" combine="choice">
79
+ <!-- DocRelationType |= "obsoletedBy" | "supersedes" | "supersededBy" -->
80
+ <define name="DocRelationType">
77
81
  <choice>
82
+ <value>obsoletes</value>
83
+ <value>updates</value>
84
+ <value>updatedBy</value>
85
+ <value>complements</value>
86
+ <value>derivedFrom</value>
87
+ <value>translatedFrom</value>
88
+ <value>adoptedFrom</value>
89
+ <value>equivalent</value>
90
+ <value>identical</value>
91
+ <value>nonequivalent</value>
92
+ <value>includedIn</value>
93
+ <value>includes</value>
94
+ <value>instance</value>
95
+ <value>partOf</value>
96
+ <value>hasDraft</value>
78
97
  <value>obsoletedBy</value>
79
98
  <value>supersedes</value>
80
99
  <value>supersededBy</value>
81
100
  </choice>
82
101
  </define>
83
- <define name="BibliographicDateType" combine="choice">
84
- <value>abandoned</value>
102
+ <!-- BibliographicDateType |= "abandoned" | "superseded" -->
103
+ <define name="BibliographicDateType">
104
+ <choice>
105
+ <value>published</value>
106
+ <value>accessed</value>
107
+ <value>created</value>
108
+ <value>implemented</value>
109
+ <value>obsoleted</value>
110
+ <value>confirmed</value>
111
+ <value>updated</value>
112
+ <value>issued</value>
113
+ <value>transmitted</value>
114
+ <value>copied</value>
115
+ <value>unchanged</value>
116
+ <value>circulated</value>
117
+ <value>abandoned</value>
118
+ <value>superseded</value>
119
+ </choice>
85
120
  </define>
86
- <define name="TitleType" combine="choice">
87
- <value>document-class</value>
121
+ <!-- TitleType |= "document-class" -->
122
+ <define name="TitleType">
123
+ <choice>
124
+ <value>alternative</value>
125
+ <value>original</value>
126
+ <value>unofficial</value>
127
+ <value>subtitle</value>
128
+ <value>main</value>
129
+ <value>document-class</value>
130
+ <value>short-title</value>
131
+ <value>short-subtitle</value>
132
+ </choice>
88
133
  </define>
89
134
  <define name="editorialgroup">
90
135
  <element name="editorialgroup">
@@ -100,11 +145,17 @@
100
145
  <value>draft-wip</value>
101
146
  <value>draft-prelim</value>
102
147
  <value>draft-public</value>
103
- <value>draft-retire</value>
104
- <value>draft-withdrawn</value>
105
148
  <value>final</value>
106
149
  <value>final-review</value>
107
- <value>final-withdrawn</value>
150
+ </choice>
151
+ </element>
152
+ </define>
153
+ <define name="substage">
154
+ <element name="substage">
155
+ <choice>
156
+ <value>active</value>
157
+ <value>retired</value>
158
+ <value>withdrawn</value>
108
159
  </choice>
109
160
  </element>
110
161
  </define>
@@ -138,6 +189,47 @@
138
189
  </optional>
139
190
  </element>
140
191
  </define>
192
+ <define name="annex">
193
+ <element name="annex">
194
+ <optional>
195
+ <attribute name="id">
196
+ <data type="ID"/>
197
+ </attribute>
198
+ </optional>
199
+ <optional>
200
+ <attribute name="inline-header">
201
+ <data type="boolean"/>
202
+ </attribute>
203
+ </optional>
204
+ <optional>
205
+ <attribute name="obligation">
206
+ <choice>
207
+ <value>normative</value>
208
+ <value>informative</value>
209
+ </choice>
210
+ </attribute>
211
+ </optional>
212
+ <optional>
213
+ <ref name="section-title"/>
214
+ </optional>
215
+ <zeroOrMore>
216
+ <!--
217
+ allow hanging paragraps in annexes: they introduce lists
218
+ ( paragraph-with-footnote | table | note | formula | admonition | ol | ul | dl | figure | quote | sourcecode | review | example )*,
219
+ -->
220
+ <ref name="BasicBlock"/>
221
+ </zeroOrMore>
222
+ <zeroOrMore>
223
+ <ref name="note"/>
224
+ </zeroOrMore>
225
+ <choice>
226
+ <zeroOrMore>
227
+ <ref name="clause-hanging-paragraph-with-footnote"/>
228
+ </zeroOrMore>
229
+ <ref name="terms"/>
230
+ </choice>
231
+ </element>
232
+ </define>
141
233
  <define name="BibData">
142
234
  <optional>
143
235
  <attribute name="type">
@@ -168,6 +260,9 @@
168
260
  <optional>
169
261
  <ref name="edition"/>
170
262
  </optional>
263
+ <optional>
264
+ <ref name="revision"/>
265
+ </optional>
171
266
  <optional>
172
267
  <ref name="version"/>
173
268
  </optional>
@@ -196,7 +291,9 @@
196
291
  <optional>
197
292
  <ref name="nistsubseries"/>
198
293
  </optional>
199
- <ref name="editorialgroup"/>
294
+ <optional>
295
+ <ref name="editorialgroup"/>
296
+ </optional>
200
297
  <zeroOrMore>
201
298
  <ref name="ics"/>
202
299
  </zeroOrMore>
@@ -228,7 +325,11 @@
228
325
  <define name="nistdocidentifier">
229
326
  <element name="docidentifier">
230
327
  <attribute name="type">
231
- <value>nist</value>
328
+ <choice>
329
+ <value>nist</value>
330
+ <value>nist-long</value>
331
+ <value>nist-mr</value>
332
+ </choice>
232
333
  </attribute>
233
334
  <text/>
234
335
  </element>
@@ -260,27 +361,27 @@
260
361
  <define name="nistseriestitle">
261
362
  <element name="title">
262
363
  <choice>
263
- <value>nist-ams</value>
264
- <value>building-science</value>
265
- <value>nist-fips</value>
266
- <value>nist-gcr</value>
267
- <value>nist-hb</value>
268
- <value>itl-bulletin</value>
269
- <value>jpcrd</value>
270
- <value>nist-jres</value>
271
- <value>letter-circular</value>
272
- <value>nist-monograph</value>
273
- <value>nist-ncstar</value>
274
- <value>nist-nsrds</value>
275
- <value>nistir</value>
276
- <value>product-stadnards</value>
277
- <value>nist-sp</value>
278
- <value>nist-tn</value>
279
- <value>other</value>
280
- <value>csrc-white-paper</value>
281
- <value>csrc-book</value>
282
- <value>csrc-use-case</value>
283
- <value>csrc-building-block</value>
364
+ <value>NIST Advanced Manufacturing Series</value>
365
+ <value>NIST Building Science Series</value>
366
+ <value>NIST Federal Information Processing Standards</value>
367
+ <value>NIST Grant/Contract Reports</value>
368
+ <value>NIST Handbook</value>
369
+ <value>ITL Bulletin</value>
370
+ <value>Journal of Physical and Chemical Reference Data</value>
371
+ <value>NIST Journal of Research</value>
372
+ <value>NIST Letter Circular</value>
373
+ <value>NIST Monograph</value>
374
+ <value>NIST National Construction Safety Team Act Reports</value>
375
+ <value>NIST National Standard Reference Data Series</value>
376
+ <value>NIST Interagency/Internal Report</value>
377
+ <value>NIST Product Standards</value>
378
+ <value>NIST Special Publication</value>
379
+ <value>NIST Technical Note</value>
380
+ <value>NIST Other</value>
381
+ <value>CSRC White Paper</value>
382
+ <value>CSRC Book</value>
383
+ <value>CSRC Use Case</value>
384
+ <value>CSRC Building Block</value>
284
385
  </choice>
285
386
  </element>
286
387
  </define>
@@ -321,6 +422,11 @@
321
422
  </define>
322
423
  <define name="authority">
323
424
  <element name="authority">
425
+ <optional>
426
+ <element name="title">
427
+ <text/>
428
+ </element>
429
+ </optional>
324
430
  <element name="authority1">
325
431
  <ref name="Basic-Section"/>
326
432
  </element>
@@ -340,6 +446,11 @@
340
446
  </element>
341
447
  </element>
342
448
  </define>
449
+ <define name="revision">
450
+ <element name="revision">
451
+ <text/>
452
+ </element>
453
+ </define>
343
454
  <define name="nist-standard">
344
455
  <element name="nist-standard">
345
456
  <ref name="bibdata"/>