metanorma-iso 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +4 -0
  3. data/.gitignore +11 -0
  4. data/.hound.yml +3 -0
  5. data/.oss-guides.rubocop.yml +1077 -0
  6. data/.rubocop.ribose.yml +66 -0
  7. data/.rubocop.tb.yml +650 -0
  8. data/.rubocop.yml +15 -0
  9. data/.travis.yml +21 -0
  10. data/CODE_OF_CONDUCT.md +46 -0
  11. data/Gemfile +7 -0
  12. data/LICENSE +25 -0
  13. data/Makefile +39 -0
  14. data/README.adoc +882 -0
  15. data/Rakefile +6 -0
  16. data/asciidoctor-iso.gemspec.old +50 -0
  17. data/bin/rspec +18 -0
  18. data/docs/customisation.adoc +186 -0
  19. data/docs/guidance.adoc +436 -0
  20. data/docs/htmloutput.adoc +115 -0
  21. data/docs/quickstart.adoc +375 -0
  22. data/lib/asciidoctor-iso.rb +11 -0
  23. data/lib/asciidoctor/iso/base.rb +48 -0
  24. data/lib/asciidoctor/iso/biblio.rng +836 -0
  25. data/lib/asciidoctor/iso/cleanup.rb +39 -0
  26. data/lib/asciidoctor/iso/converter.rb +19 -0
  27. data/lib/asciidoctor/iso/front.rb +131 -0
  28. data/lib/asciidoctor/iso/isodoc.rng +1059 -0
  29. data/lib/asciidoctor/iso/isostandard.rnc +176 -0
  30. data/lib/asciidoctor/iso/isostandard.rng +1001 -0
  31. data/lib/asciidoctor/iso/section.rb +72 -0
  32. data/lib/asciidoctor/iso/validate.rb +190 -0
  33. data/lib/asciidoctor/iso/validate_requirements.rb +105 -0
  34. data/lib/asciidoctor/iso/validate_section.rb +214 -0
  35. data/lib/asciidoctor/iso/validate_style.rb +134 -0
  36. data/lib/asciidoctor/iso/version.rb +5 -0
  37. data/lib/isodoc/iso/html/header.html +206 -0
  38. data/lib/isodoc/iso/html/html_iso_intro.html +34 -0
  39. data/lib/isodoc/iso/html/html_iso_titlepage.html +34 -0
  40. data/lib/isodoc/iso/html/htmlstyle.scss +46 -0
  41. data/lib/isodoc/iso/html/isodoc.scss +696 -0
  42. data/lib/isodoc/iso/html/scripts.html +174 -0
  43. data/lib/isodoc/iso/html/style-human.scss +1277 -0
  44. data/lib/isodoc/iso/html/style-iso.scss +1257 -0
  45. data/lib/isodoc/iso/html/word_iso_intro.html +72 -0
  46. data/lib/isodoc/iso/html/word_iso_titlepage.html +62 -0
  47. data/lib/isodoc/iso/html/wordstyle.scss +1175 -0
  48. data/lib/isodoc/iso/html_convert.rb +118 -0
  49. data/lib/isodoc/iso/metadata.rb +107 -0
  50. data/lib/isodoc/iso/word_convert.rb +141 -0
  51. data/lib/metanorma/iso.rb +7 -0
  52. data/lib/metanorma/iso/processor.rb +44 -0
  53. data/spec/asciidoctor-iso/base_spec.rb +350 -0
  54. data/spec/asciidoctor-iso/blocks_spec.rb +469 -0
  55. data/spec/asciidoctor-iso/cleanup_spec.rb +765 -0
  56. data/spec/asciidoctor-iso/inline_spec.rb +162 -0
  57. data/spec/asciidoctor-iso/isobib_cache_spec.rb +332 -0
  58. data/spec/asciidoctor-iso/lists_spec.rb +190 -0
  59. data/spec/asciidoctor-iso/macros_spec.rb +111 -0
  60. data/spec/asciidoctor-iso/refs_spec.rb +643 -0
  61. data/spec/asciidoctor-iso/section_spec.rb +334 -0
  62. data/spec/asciidoctor-iso/table_spec.rb +307 -0
  63. data/spec/asciidoctor-iso/validate_spec.rb +907 -0
  64. data/spec/assets/header.html +7 -0
  65. data/spec/assets/html.css +2 -0
  66. data/spec/assets/htmlcover.html +4 -0
  67. data/spec/assets/htmlintro.html +5 -0
  68. data/spec/assets/i18n.yaml +2 -0
  69. data/spec/assets/iso.doc +1093 -0
  70. data/spec/assets/iso.headless.html +33 -0
  71. data/spec/assets/iso.html +278 -0
  72. data/spec/assets/iso.xml +8 -0
  73. data/spec/assets/rice_image1.png +0 -0
  74. data/spec/assets/scripts.html +3 -0
  75. data/spec/assets/std.css +2 -0
  76. data/spec/assets/word.css +2 -0
  77. data/spec/assets/wordcover.html +3 -0
  78. data/spec/assets/wordintro.html +4 -0
  79. data/spec/examples/103_01_02.html +247 -0
  80. data/spec/examples/english.yaml +69 -0
  81. data/spec/examples/iso_123_.xml +45 -0
  82. data/spec/examples/iso_123_all_parts.xml +45 -0
  83. data/spec/examples/iso_123_no_year_note.xml +46 -0
  84. data/spec/examples/iso_124_.xml +41 -0
  85. data/spec/examples/iso_216_.xml +47 -0
  86. data/spec/examples/iso_iec_12382_.xml +48 -0
  87. data/spec/examples/rice.adoc +715 -0
  88. data/spec/examples/rice.preview.html +1877 -0
  89. data/spec/examples/rice.sh +4 -0
  90. data/spec/examples/rice_images/rice_image1.png +0 -0
  91. data/spec/examples/rice_images/rice_image2.png +0 -0
  92. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  93. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  94. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  95. data/spec/isodoc/i18n_spec.rb +642 -0
  96. data/spec/isodoc/iso_spec.rb +168 -0
  97. data/spec/isodoc/metadata_spec.rb +152 -0
  98. data/spec/isodoc/postproc_spec.rb +405 -0
  99. data/spec/isodoc/section_spec.rb +522 -0
  100. data/spec/isodoc/xref_spec.rb +1337 -0
  101. data/spec/metanorma/processor_spec.rb +70 -0
  102. data/spec/spec_helper.rb +227 -0
  103. metadata +402 -0
@@ -0,0 +1,39 @@
1
+ require "date"
2
+ require "nokogiri"
3
+ require "htmlentities"
4
+ require "json"
5
+ require "pathname"
6
+ require "open-uri"
7
+ require "pp"
8
+
9
+ module Asciidoctor
10
+ module ISO
11
+ class Converter < Standoc::Converter
12
+ PRE_NORMREF_FOOTNOTES = "//foreword//fn | //introduction//fn |"\
13
+ "//clause[title = 'Scope']//fn" .freeze
14
+
15
+ NORMREF_FOOTNOTES =
16
+ "//references[title = 'Normative References']//fn |"\
17
+ "//references[title = 'Normative References']//bibitem/note".freeze
18
+
19
+ POST_NORMREF_FOOTNOTES =
20
+ "//clause[not(title = 'Scope')]//fn | "\
21
+ "//references[title = 'Bibliography']//fn | "\
22
+ "//references[title = 'Bibliography']//bibitem/note".freeze
23
+
24
+ def other_footnote_renumber(xmldoc)
25
+ seen = {}
26
+ i = 0
27
+ xmldoc.xpath(PRE_NORMREF_FOOTNOTES).each do |fn|
28
+ i, seen = other_footnote_renumber1(fn, i, seen)
29
+ end
30
+ xmldoc.xpath(NORMREF_FOOTNOTES).each do |fn|
31
+ i, seen = other_footnote_renumber1(fn, i, seen)
32
+ end
33
+ xmldoc.xpath(POST_NORMREF_FOOTNOTES).each do |fn|
34
+ i, seen = other_footnote_renumber1(fn, i, seen)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ require "asciidoctor"
2
+ require "metanorma-standoc"
3
+ require "asciidoctor/iso/version"
4
+ require "asciidoctor/iso/base"
5
+ require "asciidoctor/iso/front"
6
+ require "asciidoctor/iso/section"
7
+ require "asciidoctor/iso/validate"
8
+ require "asciidoctor/iso/cleanup"
9
+
10
+ module Asciidoctor
11
+ module ISO
12
+ # A {Converter} implementation that generates ISO output, and a document
13
+ # schema encapsulation of the document for validation
14
+ class Converter < ::Asciidoctor::Standoc::Converter
15
+ register_for "iso"
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,131 @@
1
+ require "date"
2
+ require "nokogiri"
3
+ require "htmlentities"
4
+ require "json"
5
+ require "pathname"
6
+ require "open-uri"
7
+ require "pp"
8
+
9
+ module Asciidoctor
10
+ module ISO
11
+ class Converter < Standoc::Converter
12
+ def metadata_id(node, xml)
13
+ part, subpart = node&.attr("partnumber")&.split(/-/)
14
+ xml.docidentifier do |i|
15
+ i.project_number node.attr("docnumber"),
16
+ **attr_code(part: part, subpart: subpart)
17
+ if node.attr("tc-docnumber")
18
+ i.tc_document_number node.attr("tc-docnumber")
19
+ end
20
+ end
21
+ end
22
+
23
+ def organization(org, orgname)
24
+ if ["ISO",
25
+ "International Organization for Standardization"].include? orgname
26
+ org.name "International Organization for Standardization"
27
+ org.abbreviation "ISO"
28
+ elsif ["IEC",
29
+ "International Electrotechnical Commission"].include? orgname
30
+ org.name "International Electrotechnical Commission"
31
+ org.abbreviation "IEC"
32
+ else
33
+ org.name orgname
34
+ end
35
+ end
36
+
37
+ def metadata_author(node, xml)
38
+ publishers = node.attr("publisher") || "ISO"
39
+ publishers.split(/,[ ]?/).each do |p|
40
+ xml.contributor do |c|
41
+ c.role **{ type: "author" }
42
+ c.organization { |a| organization(a, p) }
43
+ end
44
+ end
45
+ end
46
+
47
+ def metadata_publisher(node, xml)
48
+ publishers = node.attr("publisher") || "ISO"
49
+ publishers.split(/,[ ]?/).each do |p|
50
+ xml.contributor do |c|
51
+ c.role **{ type: "publisher" }
52
+ c.organization { |a| organization(a, p) }
53
+ end
54
+ end
55
+ end
56
+
57
+ def metadata_copyright(node, xml)
58
+ publishers = node.attr("publisher") || "ISO"
59
+ publishers.split(/,[ ]?/).each do |p|
60
+ xml.copyright do |c|
61
+ c.from (node.attr("copyright-year") || Date.today.year)
62
+ c.owner do |owner|
63
+ owner.organization { |o| organization(o, p) }
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ def metadata_status(node, xml)
70
+ xml.status do |s|
71
+ s.stage (node.attr("docstage") || "60")
72
+ s.substage (node.attr("docsubstage") || "60")
73
+ node.attr("iteration") && (s.iteration node.attr("iteration"))
74
+ end
75
+ end
76
+
77
+ def metadata_committee(node, xml)
78
+ xml.editorialgroup do |a|
79
+ committee_component("technical-committee", node, a)
80
+ committee_component("subcommittee", node, a)
81
+ committee_component("workgroup", node, a)
82
+ node.attr("secretariat") && a.secretariat(node.attr("secretariat"))
83
+ end
84
+ end
85
+
86
+ def metadata(node, xml)
87
+ title node, xml
88
+ metadata_id(node, xml)
89
+ metadata_author(node, xml)
90
+ metadata_publisher(node, xml)
91
+ xml.language (node.attr("language") || "en")
92
+ xml.script (node.attr("script") || "Latn")
93
+ metadata_status(node, xml)
94
+ metadata_copyright(node, xml)
95
+ metadata_committee(node, xml)
96
+ metadata_ics(node, xml)
97
+ end
98
+
99
+ def title_intro(node, t, lang, at)
100
+ return unless node.attr("title-intro-#{lang}")
101
+ t.title_intro(**attr_code(at)) do |t1|
102
+ t1 << asciidoc_sub(node.attr("title-intro-#{lang}"))
103
+ end
104
+ end
105
+
106
+ def title_main(node, t, lang, at)
107
+ t.title_main **attr_code(at) do |t1|
108
+ t1 << asciidoc_sub(node.attr("title-main-#{lang}"))
109
+ end
110
+ end
111
+
112
+ def title_part(node, t, lang, at)
113
+ return unless node.attr("title-part-#{lang}")
114
+ t.title_part(**attr_code(at)) do |t1|
115
+ t1 << asciidoc_sub(node.attr("title-part-#{lang}"))
116
+ end
117
+ end
118
+
119
+ def title(node, xml)
120
+ ["en", "fr"].each do |lang|
121
+ xml.title do |t|
122
+ at = { language: lang, format: "text/plain" }
123
+ title_intro(node, t, lang, at)
124
+ title_main(node, t, lang, at)
125
+ title_part(node, t, lang, at)
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,1059 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ instantiations of this grammar may replace leaf strings
4
+ with more elaborated types; e.g. title (text) replaced with
5
+ title-main, title-intro, title-part; type replaced with
6
+ enum.
7
+
8
+ some renaming at leaf nodes is permissible
9
+
10
+ obligations can change both from optional to mandatory,
11
+ and from mandatory to optional; optional elements may
12
+ be omitted; freely positioned alternatives may be replaced
13
+ with strict ordering
14
+
15
+ DO NOT introduce a namespace here. We do not want a distinct namespace
16
+ for these elements, and a distinct namespace for any grammar inheriting
17
+ these elements; we just want one namespace for any child grammars
18
+ of this.
19
+ -->
20
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
21
+ <include href="biblio.rng">
22
+ <define name="status">
23
+ <element name="status">
24
+ <choice>
25
+ <value>proposal</value>
26
+ <value>working_draft</value>
27
+ <value>committee_draft</value>
28
+ <value>draft_standard</value>
29
+ <value>final_draft</value>
30
+ <value>published</value>
31
+ <value>withdrawn</value>
32
+ </choice>
33
+ </element>
34
+ </define>
35
+ </include>
36
+ <start>
37
+ <ref name="standard-document"/>
38
+ </start>
39
+ <define name="standard-document">
40
+ <element name="standard-document">
41
+ <ref name="bibdata"/>
42
+ <optional>
43
+ <ref name="version"/>
44
+ </optional>
45
+ <optional>
46
+ <ref name="preface"/>
47
+ </optional>
48
+ <ref name="sections"/>
49
+ <zeroOrMore>
50
+ <ref name="annex"/>
51
+ </zeroOrMore>
52
+ <zeroOrMore>
53
+ <ref name="references"/>
54
+ </zeroOrMore>
55
+ </element>
56
+ </define>
57
+ <define name="bibdata">
58
+ <element name="bibdata">
59
+ <ref name="BibData"/>
60
+ </element>
61
+ </define>
62
+ <define name="version">
63
+ <element name="version">
64
+ <optional>
65
+ <ref name="vedition"/>
66
+ </optional>
67
+ <optional>
68
+ <ref name="revision-date"/>
69
+ </optional>
70
+ <zeroOrMore>
71
+ <ref name="draft"/>
72
+ </zeroOrMore>
73
+ </element>
74
+ </define>
75
+ <define name="vedition">
76
+ <element name="edition">
77
+ <data type="int"/>
78
+ </element>
79
+ </define>
80
+ <define name="revision-date">
81
+ <element name="revision-date">
82
+ <data type="date"/>
83
+ </element>
84
+ </define>
85
+ <define name="draft">
86
+ <element name="draft">
87
+ <text/>
88
+ </element>
89
+ </define>
90
+ <define name="preface">
91
+ <element name="preface">
92
+ <oneOrMore>
93
+ <ref name="content"/>
94
+ </oneOrMore>
95
+ </element>
96
+ </define>
97
+ <define name="sections">
98
+ <element name="sections">
99
+ <oneOrMore>
100
+ <choice>
101
+ <ref name="content"/>
102
+ <ref name="clause"/>
103
+ <ref name="terms"/>
104
+ <ref name="definitions"/>
105
+ </choice>
106
+ </oneOrMore>
107
+ </element>
108
+ </define>
109
+ <define name="definitions">
110
+ <element name="definitions">
111
+ <optional>
112
+ <attribute name="id">
113
+ <data type="ID"/>
114
+ </attribute>
115
+ </optional>
116
+ <optional>
117
+ <ref name="section-title"/>
118
+ </optional>
119
+ <ref name="dl"/>
120
+ </element>
121
+ </define>
122
+ <define name="section-title">
123
+ <element name="title">
124
+ <zeroOrMore>
125
+ <ref name="TextElement"/>
126
+ </zeroOrMore>
127
+ </element>
128
+ </define>
129
+ <define name="content">
130
+ <element name="content">
131
+ <ref name="Content-Section"/>
132
+ </element>
133
+ </define>
134
+ <define name="content-subsection">
135
+ <element name="clause">
136
+ <ref name="Content-Section"/>
137
+ </element>
138
+ </define>
139
+ <define name="Basic-Section">
140
+ <optional>
141
+ <attribute name="id">
142
+ <data type="ID"/>
143
+ </attribute>
144
+ </optional>
145
+ <optional>
146
+ <ref name="section-title"/>
147
+ </optional>
148
+ <oneOrMore>
149
+ <ref name="BasicBlock"/>
150
+ </oneOrMore>
151
+ <zeroOrMore>
152
+ <ref name="note"/>
153
+ </zeroOrMore>
154
+ </define>
155
+ <define name="Content-Section">
156
+ <optional>
157
+ <attribute name="id">
158
+ <data type="ID"/>
159
+ </attribute>
160
+ </optional>
161
+ <optional>
162
+ <ref name="section-title"/>
163
+ </optional>
164
+ <choice>
165
+ <group>
166
+ <oneOrMore>
167
+ <ref name="BasicBlock"/>
168
+ </oneOrMore>
169
+ <zeroOrMore>
170
+ <ref name="note"/>
171
+ </zeroOrMore>
172
+ </group>
173
+ <oneOrMore>
174
+ <ref name="content-subsection"/>
175
+ </oneOrMore>
176
+ </choice>
177
+ </define>
178
+ <define name="clause">
179
+ <element name="clause">
180
+ <ref name="Clause-Section"/>
181
+ </element>
182
+ </define>
183
+ <define name="Clause-Section">
184
+ <optional>
185
+ <attribute name="id">
186
+ <data type="ID"/>
187
+ </attribute>
188
+ </optional>
189
+ <optional>
190
+ <ref name="section-title"/>
191
+ </optional>
192
+ <choice>
193
+ <group>
194
+ <oneOrMore>
195
+ <ref name="BasicBlock"/>
196
+ </oneOrMore>
197
+ <zeroOrMore>
198
+ <ref name="note"/>
199
+ </zeroOrMore>
200
+ </group>
201
+ <oneOrMore>
202
+ <ref name="clause-subsection"/>
203
+ </oneOrMore>
204
+ </choice>
205
+ </define>
206
+ <define name="clause-subsection">
207
+ <element name="clause">
208
+ <ref name="Clause-Section"/>
209
+ </element>
210
+ </define>
211
+ <define name="annex">
212
+ <element name="annex">
213
+ <optional>
214
+ <attribute name="id">
215
+ <data type="ID"/>
216
+ </attribute>
217
+ </optional>
218
+ <attribute name="obligation">
219
+ <choice>
220
+ <value>normative</value>
221
+ <value>informative</value>
222
+ </choice>
223
+ </attribute>
224
+ <optional>
225
+ <ref name="section-title"/>
226
+ </optional>
227
+ <choice>
228
+ <group>
229
+ <oneOrMore>
230
+ <ref name="BasicBlock"/>
231
+ </oneOrMore>
232
+ <zeroOrMore>
233
+ <ref name="note"/>
234
+ </zeroOrMore>
235
+ </group>
236
+ <oneOrMore>
237
+ <ref name="clause-subsection"/>
238
+ </oneOrMore>
239
+ </choice>
240
+ </element>
241
+ </define>
242
+ <define name="references">
243
+ <element name="references">
244
+ <optional>
245
+ <attribute name="id">
246
+ <data type="ID"/>
247
+ </attribute>
248
+ </optional>
249
+ <optional>
250
+ <ref name="section-title"/>
251
+ </optional>
252
+ <zeroOrMore>
253
+ <ref name="bibitem"/>
254
+ </zeroOrMore>
255
+ </element>
256
+ </define>
257
+ <define name="terms">
258
+ <element name="terms">
259
+ <optional>
260
+ <attribute name="id">
261
+ <data type="ID"/>
262
+ </attribute>
263
+ </optional>
264
+ <oneOrMore>
265
+ <ref name="term"/>
266
+ </oneOrMore>
267
+ </element>
268
+ </define>
269
+ <define name="term">
270
+ <element name="term">
271
+ <optional>
272
+ <attribute name="id">
273
+ <data type="ID"/>
274
+ </attribute>
275
+ </optional>
276
+ <oneOrMore>
277
+ <ref name="preferred"/>
278
+ </oneOrMore>
279
+ <zeroOrMore>
280
+ <ref name="admitted"/>
281
+ </zeroOrMore>
282
+ <zeroOrMore>
283
+ <ref name="deprecates"/>
284
+ </zeroOrMore>
285
+ <optional>
286
+ <ref name="termdomain"/>
287
+ </optional>
288
+ <ref name="definition"/>
289
+ <zeroOrMore>
290
+ <ref name="termnote"/>
291
+ </zeroOrMore>
292
+ <zeroOrMore>
293
+ <ref name="termexample"/>
294
+ </zeroOrMore>
295
+ <zeroOrMore>
296
+ <ref name="termsource"/>
297
+ </zeroOrMore>
298
+ </element>
299
+ </define>
300
+ <define name="preferred">
301
+ <element name="preferred">
302
+ <oneOrMore>
303
+ <ref name="TextElement"/>
304
+ </oneOrMore>
305
+ </element>
306
+ </define>
307
+ <define name="admitted">
308
+ <element name="admitted">
309
+ <oneOrMore>
310
+ <ref name="TextElement"/>
311
+ </oneOrMore>
312
+ </element>
313
+ </define>
314
+ <define name="deprecates">
315
+ <element name="deprecates">
316
+ <oneOrMore>
317
+ <ref name="TextElement"/>
318
+ </oneOrMore>
319
+ </element>
320
+ </define>
321
+ <define name="termdomain">
322
+ <element name="domain">
323
+ <oneOrMore>
324
+ <ref name="TextElement"/>
325
+ </oneOrMore>
326
+ </element>
327
+ </define>
328
+ <define name="definition">
329
+ <element name="definition">
330
+ <ref name="paragraph"/>
331
+ </element>
332
+ </define>
333
+ <define name="termnote">
334
+ <element name="termnote">
335
+ <attribute name="id">
336
+ <data type="ID"/>
337
+ </attribute>
338
+ <ref name="paragraph"/>
339
+ </element>
340
+ </define>
341
+ <define name="termexample">
342
+ <element name="termexample">
343
+ <attribute name="id">
344
+ <data type="ID"/>
345
+ </attribute>
346
+ <ref name="paragraph"/>
347
+ </element>
348
+ </define>
349
+ <define name="termsource">
350
+ <element name="termsource">
351
+ <attribute name="status">
352
+ <choice>
353
+ <value>identical</value>
354
+ <value>modified</value>
355
+ </choice>
356
+ </attribute>
357
+ <ref name="origin"/>
358
+ <optional>
359
+ <ref name="modification"/>
360
+ </optional>
361
+ </element>
362
+ </define>
363
+ <define name="origin">
364
+ <element name="origin">
365
+ <ref name="erefType"/>
366
+ </element>
367
+ </define>
368
+ <define name="modification">
369
+ <element name="modification">
370
+ <ref name="paragraph"/>
371
+ </element>
372
+ </define>
373
+ <define name="BasicBlock">
374
+ <choice>
375
+ <ref name="paragraph-with-footnote"/>
376
+ <ref name="table"/>
377
+ <ref name="formula"/>
378
+ <ref name="admonition"/>
379
+ <ref name="ol"/>
380
+ <ref name="ul"/>
381
+ <ref name="dl"/>
382
+ <ref name="figure"/>
383
+ <ref name="quote"/>
384
+ <ref name="sourcecode"/>
385
+ <ref name="example"/>
386
+ <ref name="review"/>
387
+ </choice>
388
+ </define>
389
+ <define name="paragraph">
390
+ <element name="p">
391
+ <ref name="ParagraphType"/>
392
+ </element>
393
+ </define>
394
+ <define name="Alignments">
395
+ <choice>
396
+ <value>left</value>
397
+ <value>right</value>
398
+ <value>center</value>
399
+ <value>justified</value>
400
+ </choice>
401
+ </define>
402
+ <define name="ParagraphType">
403
+ <attribute name="id">
404
+ <data type="ID"/>
405
+ </attribute>
406
+ <optional>
407
+ <attribute name="align">
408
+ <ref name="Alignments"/>
409
+ </attribute>
410
+ </optional>
411
+ <zeroOrMore>
412
+ <ref name="TextElement"/>
413
+ </zeroOrMore>
414
+ <zeroOrMore>
415
+ <ref name="note"/>
416
+ </zeroOrMore>
417
+ </define>
418
+ <define name="paragraph-with-footnote">
419
+ <element name="p">
420
+ <attribute name="id">
421
+ <data type="ID"/>
422
+ </attribute>
423
+ <optional>
424
+ <attribute name="align">
425
+ <ref name="Alignments"/>
426
+ </attribute>
427
+ </optional>
428
+ <zeroOrMore>
429
+ <choice>
430
+ <ref name="TextElement"/>
431
+ <ref name="fn"/>
432
+ </choice>
433
+ </zeroOrMore>
434
+ <zeroOrMore>
435
+ <ref name="note"/>
436
+ </zeroOrMore>
437
+ </element>
438
+ </define>
439
+ <define name="note">
440
+ <element name="note">
441
+ <attribute name="id">
442
+ <data type="ID"/>
443
+ </attribute>
444
+ <oneOrMore>
445
+ <ref name="paragraph"/>
446
+ </oneOrMore>
447
+ </element>
448
+ </define>
449
+ <define name="review">
450
+ <element name="review">
451
+ <attribute name="id">
452
+ <data type="ID"/>
453
+ </attribute>
454
+ <attribute name="reviewer"/>
455
+ <optional>
456
+ <attribute name="date">
457
+ <data type="dateTime"/>
458
+ </attribute>
459
+ </optional>
460
+ <attribute name="from">
461
+ <data type="IDREF"/>
462
+ </attribute>
463
+ <optional>
464
+ <attribute name="to">
465
+ <data type="IDREF"/>
466
+ </attribute>
467
+ </optional>
468
+ <oneOrMore>
469
+ <ref name="paragraph"/>
470
+ </oneOrMore>
471
+ </element>
472
+ </define>
473
+ <define name="formula">
474
+ <element name="formula">
475
+ <attribute name="id">
476
+ <data type="ID"/>
477
+ </attribute>
478
+ <ref name="stem"/>
479
+ <optional>
480
+ <ref name="dl"/>
481
+ </optional>
482
+ <zeroOrMore>
483
+ <ref name="note"/>
484
+ </zeroOrMore>
485
+ </element>
486
+ </define>
487
+ <define name="quote">
488
+ <element name="quote">
489
+ <attribute name="id">
490
+ <data type="ID"/>
491
+ </attribute>
492
+ <optional>
493
+ <attribute name="alignment">
494
+ <ref name="Alignments"/>
495
+ </attribute>
496
+ </optional>
497
+ <optional>
498
+ <ref name="quote-source"/>
499
+ </optional>
500
+ <optional>
501
+ <ref name="quote-author"/>
502
+ </optional>
503
+ <oneOrMore>
504
+ <ref name="paragraph-with-footnote"/>
505
+ </oneOrMore>
506
+ <zeroOrMore>
507
+ <ref name="note"/>
508
+ </zeroOrMore>
509
+ </element>
510
+ </define>
511
+ <define name="quote-source">
512
+ <element name="source">
513
+ <ref name="erefType"/>
514
+ </element>
515
+ </define>
516
+ <define name="quote-author">
517
+ <element name="author">
518
+ <text/>
519
+ </element>
520
+ </define>
521
+ <define name="sourcecode">
522
+ <element name="sourcecode">
523
+ <attribute name="id">
524
+ <data type="ID"/>
525
+ </attribute>
526
+ <optional>
527
+ <ref name="tname"/>
528
+ </optional>
529
+ <oneOrMore>
530
+ <choice>
531
+ <text/>
532
+ <ref name="callout"/>
533
+ </choice>
534
+ </oneOrMore>
535
+ <zeroOrMore>
536
+ <ref name="annotation"/>
537
+ </zeroOrMore>
538
+ <zeroOrMore>
539
+ <ref name="note"/>
540
+ </zeroOrMore>
541
+ </element>
542
+ </define>
543
+ <define name="table">
544
+ <element name="table">
545
+ <attribute name="id">
546
+ <data type="ID"/>
547
+ </attribute>
548
+ <optional>
549
+ <ref name="tname"/>
550
+ </optional>
551
+ <optional>
552
+ <ref name="thead"/>
553
+ </optional>
554
+ <ref name="tbody"/>
555
+ <optional>
556
+ <ref name="tfoot"/>
557
+ </optional>
558
+ <zeroOrMore>
559
+ <ref name="table-note"/>
560
+ </zeroOrMore>
561
+ <optional>
562
+ <ref name="dl"/>
563
+ </optional>
564
+ </element>
565
+ </define>
566
+ <define name="tname">
567
+ <element name="name">
568
+ <text/>
569
+ </element>
570
+ </define>
571
+ <define name="thead">
572
+ <element name="thead">
573
+ <ref name="tr"/>
574
+ </element>
575
+ </define>
576
+ <define name="tfoot">
577
+ <element name="tfoot">
578
+ <ref name="tr"/>
579
+ </element>
580
+ </define>
581
+ <define name="tbody">
582
+ <element name="tbody">
583
+ <oneOrMore>
584
+ <ref name="tr"/>
585
+ </oneOrMore>
586
+ </element>
587
+ </define>
588
+ <define name="table-note">
589
+ <element name="note">
590
+ <ref name="paragraph"/>
591
+ </element>
592
+ </define>
593
+ <define name="tr">
594
+ <element name="tr">
595
+ <oneOrMore>
596
+ <choice>
597
+ <ref name="td"/>
598
+ <ref name="th"/>
599
+ </choice>
600
+ </oneOrMore>
601
+ </element>
602
+ </define>
603
+ <define name="td">
604
+ <element name="td">
605
+ <optional>
606
+ <attribute name="colspan"/>
607
+ </optional>
608
+ <optional>
609
+ <attribute name="rowspan"/>
610
+ </optional>
611
+ <optional>
612
+ <attribute name="align">
613
+ <choice>
614
+ <value>left</value>
615
+ <value>right</value>
616
+ <value>center</value>
617
+ </choice>
618
+ </attribute>
619
+ </optional>
620
+ <choice>
621
+ <zeroOrMore>
622
+ <ref name="TextElement"/>
623
+ </zeroOrMore>
624
+ <oneOrMore>
625
+ <ref name="paragraph-with-footnote"/>
626
+ </oneOrMore>
627
+ </choice>
628
+ </element>
629
+ </define>
630
+ <define name="th">
631
+ <element name="th">
632
+ <optional>
633
+ <attribute name="colspan"/>
634
+ </optional>
635
+ <optional>
636
+ <attribute name="rowspan"/>
637
+ </optional>
638
+ <optional>
639
+ <attribute name="align">
640
+ <choice>
641
+ <value>left</value>
642
+ <value>right</value>
643
+ <value>center</value>
644
+ </choice>
645
+ </attribute>
646
+ </optional>
647
+ <choice>
648
+ <zeroOrMore>
649
+ <ref name="TextElement"/>
650
+ </zeroOrMore>
651
+ <oneOrMore>
652
+ <ref name="paragraph-with-footnote"/>
653
+ </oneOrMore>
654
+ </choice>
655
+ </element>
656
+ </define>
657
+ <define name="example">
658
+ <element name="example">
659
+ <attribute name="id">
660
+ <data type="ID"/>
661
+ </attribute>
662
+ <oneOrMore>
663
+ <choice>
664
+ <ref name="formula"/>
665
+ <ref name="ul"/>
666
+ <ref name="ol"/>
667
+ <ref name="dl"/>
668
+ <ref name="quote"/>
669
+ <ref name="sourcecode"/>
670
+ <ref name="paragraph-with-footnote"/>
671
+ </choice>
672
+ </oneOrMore>
673
+ <zeroOrMore>
674
+ <ref name="note"/>
675
+ </zeroOrMore>
676
+ </element>
677
+ </define>
678
+ <define name="admonition">
679
+ <element name="admonition">
680
+ <attribute name="type">
681
+ <choice>
682
+ <value>warning</value>
683
+ <value>note</value>
684
+ <value>tip</value>
685
+ <value>important</value>
686
+ <value>caution</value>
687
+ </choice>
688
+ </attribute>
689
+ <attribute name="id">
690
+ <data type="ID"/>
691
+ </attribute>
692
+ <zeroOrMore>
693
+ <ref name="paragraph-with-footnote"/>
694
+ </zeroOrMore>
695
+ <zeroOrMore>
696
+ <ref name="note"/>
697
+ </zeroOrMore>
698
+ </element>
699
+ </define>
700
+ <define name="figure">
701
+ <element name="figure">
702
+ <attribute name="id">
703
+ <data type="ID"/>
704
+ </attribute>
705
+ <optional>
706
+ <ref name="source"/>
707
+ </optional>
708
+ <optional>
709
+ <ref name="tname"/>
710
+ </optional>
711
+ <choice>
712
+ <ref name="image"/>
713
+ <zeroOrMore>
714
+ <ref name="figure"/>
715
+ </zeroOrMore>
716
+ </choice>
717
+ <zeroOrMore>
718
+ <ref name="fn"/>
719
+ </zeroOrMore>
720
+ <optional>
721
+ <ref name="dl"/>
722
+ </optional>
723
+ <zeroOrMore>
724
+ <ref name="note"/>
725
+ </zeroOrMore>
726
+ </element>
727
+ </define>
728
+ <define name="TextElement">
729
+ <choice>
730
+ <text/>
731
+ <ref name="em"/>
732
+ <ref name="eref"/>
733
+ <ref name="strong"/>
734
+ <ref name="stem"/>
735
+ <ref name="sub"/>
736
+ <ref name="sup"/>
737
+ <ref name="tt"/>
738
+ <ref name="strike"/>
739
+ <ref name="smallcap"/>
740
+ <ref name="xref"/>
741
+ <ref name="br"/>
742
+ <ref name="hyperlink"/>
743
+ <ref name="hr"/>
744
+ <ref name="pagebreak"/>
745
+ <ref name="bookmark"/>
746
+ </choice>
747
+ </define>
748
+ <define name="source">
749
+ <element name="source">
750
+ <ref name="TypedUri"/>
751
+ </element>
752
+ </define>
753
+ <define name="em">
754
+ <element name="em">
755
+ <text/>
756
+ </element>
757
+ </define>
758
+ <define name="strong">
759
+ <element name="strong">
760
+ <text/>
761
+ </element>
762
+ </define>
763
+ <define name="tt">
764
+ <element name="tt">
765
+ <text/>
766
+ </element>
767
+ </define>
768
+ <define name="sub">
769
+ <element name="sub">
770
+ <text/>
771
+ </element>
772
+ </define>
773
+ <define name="sup">
774
+ <element name="sup">
775
+ <text/>
776
+ </element>
777
+ </define>
778
+ <define name="strike">
779
+ <element name="strike">
780
+ <text/>
781
+ </element>
782
+ </define>
783
+ <define name="smallcap">
784
+ <element name="smallcap">
785
+ <text/>
786
+ </element>
787
+ </define>
788
+ <define name="br">
789
+ <element name="br">
790
+ <empty/>
791
+ </element>
792
+ </define>
793
+ <define name="hr">
794
+ <element name="hr">
795
+ <empty/>
796
+ </element>
797
+ </define>
798
+ <define name="pagebreak">
799
+ <element name="pagebreak">
800
+ <empty/>
801
+ </element>
802
+ </define>
803
+ <!-- bare ID element, used for referencing arbitrary spans of text -->
804
+ <define name="bookmark">
805
+ <element name="bookmark">
806
+ <attribute name="id">
807
+ <data type="ID"/>
808
+ </attribute>
809
+ <empty/>
810
+ </element>
811
+ </define>
812
+ <define name="ReferenceFormat">
813
+ <choice>
814
+ <value>external</value>
815
+ <value>inline</value>
816
+ <value>footnote</value>
817
+ <value>callout</value>
818
+ </choice>
819
+ </define>
820
+ <define name="eref">
821
+ <element name="eref">
822
+ <ref name="erefType"/>
823
+ </element>
824
+ </define>
825
+ <define name="erefType">
826
+ <optional>
827
+ <attribute name="normative">
828
+ <data type="boolean"/>
829
+ </attribute>
830
+ </optional>
831
+ <attribute name="citeas"/>
832
+ <attribute name="type">
833
+ <ref name="ReferenceFormat"/>
834
+ </attribute>
835
+ <ref name="CitationType"/>
836
+ <text/>
837
+ </define>
838
+ <define name="hyperlink">
839
+ <element name="link">
840
+ <attribute name="target">
841
+ <data type="anyURI"/>
842
+ </attribute>
843
+ <attribute name="type">
844
+ <ref name="ReferenceFormat"/>
845
+ </attribute>
846
+ <text/>
847
+ </element>
848
+ </define>
849
+ <define name="xref">
850
+ <element name="xref">
851
+ <attribute name="target">
852
+ <data type="IDREF"/>
853
+ </attribute>
854
+ <attribute name="type">
855
+ <ref name="ReferenceFormat"/>
856
+ </attribute>
857
+ <text/>
858
+ </element>
859
+ </define>
860
+ <define name="fn">
861
+ <element name="fn">
862
+ <attribute name="reference"/>
863
+ <oneOrMore>
864
+ <ref name="paragraph"/>
865
+ </oneOrMore>
866
+ </element>
867
+ </define>
868
+ <!--
869
+ This is xref with fixed @type="footnote", and @target built in as paragraph+
870
+ @reference replaces ReferenceElement/text
871
+ so <fn reference="2"><p>This is a footnote</p></fn>
872
+ corresponds to
873
+ <eref type="footnote" target="fn2">2</xref> <p id="fn2">This is a footnote</p>
874
+ -->
875
+ <define name="callout">
876
+ <element name="callout">
877
+ <attribute name="target">
878
+ <data type="IDREF"/>
879
+ </attribute>
880
+ <text/>
881
+ </element>
882
+ </define>
883
+ <!--
884
+ This is xref with fixed @type="callout"; the target by convention is in an annotation in the same source code snippet
885
+ so <callout target="xyz">1</callout>
886
+ corresponds to <xref type="callout" target="xyz">1</xref>
887
+ -->
888
+ <define name="image">
889
+ <element name="image">
890
+ <attribute name="id">
891
+ <data type="ID"/>
892
+ </attribute>
893
+ <optional>
894
+ <attribute name="src">
895
+ <data type="anyURI"/>
896
+ </attribute>
897
+ </optional>
898
+ <attribute name="imagetype">
899
+ <choice>
900
+ <value>SVG</value>
901
+ <value>JPEG</value>
902
+ <value>GIF</value>
903
+ <value>PNG</value>
904
+ <value>PDF</value>
905
+ </choice>
906
+ </attribute>
907
+ <optional>
908
+ <attribute name="width">
909
+ <choice>
910
+ <data type="int"/>
911
+ <value>auto</value>
912
+ </choice>
913
+ </attribute>
914
+ </optional>
915
+ <optional>
916
+ <attribute name="height">
917
+ <choice>
918
+ <data type="int"/>
919
+ <value>auto</value>
920
+ </choice>
921
+ </attribute>
922
+ </optional>
923
+ </element>
924
+ </define>
925
+ <define name="stem">
926
+ <element name="stem">
927
+ <attribute name="type">
928
+ <choice>
929
+ <value>MathML</value>
930
+ <value>AsciiMath</value>
931
+ </choice>
932
+ </attribute>
933
+ <text/>
934
+ </element>
935
+ </define>
936
+ <define name="annotation">
937
+ <element name="annotation">
938
+ <attribute name="id">
939
+ <data type="ID"/>
940
+ </attribute>
941
+ <ref name="paragraph"/>
942
+ </element>
943
+ </define>
944
+ <define name="ul">
945
+ <element name="ul">
946
+ <attribute name="id">
947
+ <data type="ID"/>
948
+ </attribute>
949
+ <oneOrMore>
950
+ <ref name="li"/>
951
+ </oneOrMore>
952
+ <zeroOrMore>
953
+ <ref name="note"/>
954
+ </zeroOrMore>
955
+ </element>
956
+ </define>
957
+ <define name="li">
958
+ <element name="li">
959
+ <oneOrMore>
960
+ <ref name="paragraph-with-footnote"/>
961
+ </oneOrMore>
962
+ </element>
963
+ </define>
964
+ <define name="ol">
965
+ <element name="ol">
966
+ <attribute name="id">
967
+ <data type="ID"/>
968
+ </attribute>
969
+ <attribute name="type">
970
+ <choice>
971
+ <value>roman</value>
972
+ <value>alphabet</value>
973
+ <value>arabic</value>
974
+ <value>roman_upper</value>
975
+ <value>alphabet_upper</value>
976
+ </choice>
977
+ </attribute>
978
+ <oneOrMore>
979
+ <ref name="li"/>
980
+ </oneOrMore>
981
+ <zeroOrMore>
982
+ <ref name="note"/>
983
+ </zeroOrMore>
984
+ </element>
985
+ </define>
986
+ <define name="dl">
987
+ <element name="dl">
988
+ <attribute name="id">
989
+ <data type="ID"/>
990
+ </attribute>
991
+ <oneOrMore>
992
+ <ref name="dt"/>
993
+ <ref name="dd"/>
994
+ </oneOrMore>
995
+ <zeroOrMore>
996
+ <ref name="note"/>
997
+ </zeroOrMore>
998
+ </element>
999
+ </define>
1000
+ <define name="dt">
1001
+ <element name="dt">
1002
+ <ref name="TextElement"/>
1003
+ </element>
1004
+ </define>
1005
+ <define name="dd">
1006
+ <element name="dd">
1007
+ <zeroOrMore>
1008
+ <ref name="paragraph-with-footnote"/>
1009
+ </zeroOrMore>
1010
+ </element>
1011
+ </define>
1012
+ <define name="BibData">
1013
+ <optional>
1014
+ <attribute name="type">
1015
+ <ref name="BibItemType"/>
1016
+ </attribute>
1017
+ </optional>
1018
+ <oneOrMore>
1019
+ <ref name="btitle"/>
1020
+ </oneOrMore>
1021
+ <optional>
1022
+ <ref name="formattedref"/>
1023
+ </optional>
1024
+ <zeroOrMore>
1025
+ <ref name="bsource"/>
1026
+ </zeroOrMore>
1027
+ <zeroOrMore>
1028
+ <ref name="docidentifier"/>
1029
+ </zeroOrMore>
1030
+ <zeroOrMore>
1031
+ <ref name="bdate"/>
1032
+ </zeroOrMore>
1033
+ <zeroOrMore>
1034
+ <ref name="contributor"/>
1035
+ </zeroOrMore>
1036
+ <optional>
1037
+ <ref name="edition"/>
1038
+ </optional>
1039
+ <zeroOrMore>
1040
+ <ref name="biblionote"/>
1041
+ </zeroOrMore>
1042
+ <zeroOrMore>
1043
+ <ref name="language"/>
1044
+ </zeroOrMore>
1045
+ <zeroOrMore>
1046
+ <ref name="script"/>
1047
+ </zeroOrMore>
1048
+ <optional>
1049
+ <ref name="abstract"/>
1050
+ </optional>
1051
+ <optional>
1052
+ <ref name="status"/>
1053
+ </optional>
1054
+ <ref name="copyright"/>
1055
+ <zeroOrMore>
1056
+ <ref name="docrelation"/>
1057
+ </zeroOrMore>
1058
+ </define>
1059
+ </grammar>