metanorma-vsd 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,98 @@
1
+ require "asciidoctor/rsd/converter"
2
+ require "isodoc/vsd"
3
+
4
+ module Asciidoctor
5
+ module Vsd
6
+
7
+ # A {Converter} implementation that generates RSD output, and a document
8
+ # schema encapsulation of the document for validation
9
+ #
10
+ class Converter < Asciidoctor::Rsd::Converter
11
+
12
+ register_for "vsd"
13
+
14
+ def metadata_author(node, xml)
15
+ xml.contributor do |c|
16
+ c.role **{ type: "author" }
17
+ c.organization do |a|
18
+ a.name Metanorma::Vsd::ORGANIZATION_NAME
19
+ end
20
+ end
21
+ end
22
+
23
+ def metadata_publisher(node, xml)
24
+ xml.contributor do |c|
25
+ c.role **{ type: "publisher" }
26
+ c.organization do |a|
27
+ a.name Metanorma::Vsd::ORGANIZATION_NAME
28
+ end
29
+ end
30
+ end
31
+
32
+ def metadata_copyright(node, xml)
33
+ from = node.attr("copyright-year") || Date.today.year
34
+ xml.copyright do |c|
35
+ c.from from
36
+ c.owner do |owner|
37
+ owner.organization do |o|
38
+ o.name Metanorma::Vsd::ORGANIZATION_NAME
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def makexml(node)
45
+ result = ["<?xml version='1.0' encoding='UTF-8'?>\n<vsd-standard>"]
46
+ @draft = node.attributes.has_key?("draft")
47
+ result << noko { |ixml| front node, ixml }
48
+ result << noko { |ixml| middle node, ixml }
49
+ result << "</vsd-standard>"
50
+ result = textcleanup(result.flatten * "\n")
51
+ ret1 = cleanup(Nokogiri::XML(result))
52
+ validate(ret1)
53
+ ret1.root.add_namespace(nil, IsoDoc::Vsd::DOCUMENT_NAMESPACE)
54
+ ret1
55
+ end
56
+
57
+ def doctype(node)
58
+ d = node.attr("doctype")
59
+ unless %w{policy-and-procedures best-practices supporting-document report legal directives proposal standard}.include? d
60
+ warn "#{d} is not a legal document type: reverting to 'standard'"
61
+ d = "standard"
62
+ end
63
+ d
64
+ end
65
+
66
+ def validate(doc)
67
+ content_validate(doc)
68
+ schema_validate(formattedstr_strip(doc.dup),
69
+ File.join(File.dirname(__FILE__), "vsd.rng"))
70
+ end
71
+
72
+ def html_converter(node)
73
+ IsoDoc::Vsd::HtmlConvert.new(
74
+ script: node.attr("script"),
75
+ bodyfont: node.attr("body-font"),
76
+ headerfont: node.attr("header-font"),
77
+ monospacefont: node.attr("monospace-font"),
78
+ titlefont: node.attr("title-font"),
79
+ i18nyaml: node.attr("i18nyaml"),
80
+ scope: node.attr("scope"),
81
+ )
82
+ end
83
+
84
+ def word_converter(node)
85
+ IsoDoc::Vsd::WordConvert.new(
86
+ script: node.attr("script"),
87
+ bodyfont: node.attr("body-font"),
88
+ headerfont: node.attr("header-font"),
89
+ monospacefont: node.attr("monospace-font"),
90
+ titlefont: node.attr("title-font"),
91
+ i18nyaml: node.attr("i18nyaml"),
92
+ scope: node.attr("scope"),
93
+ )
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,1041 @@
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
+ <start>
23
+ <ref name="standard-document"/>
24
+ </start>
25
+ <define name="standard-document">
26
+ <element name="standard-document">
27
+ <ref name="bibdata"/>
28
+ <optional>
29
+ <ref name="version"/>
30
+ </optional>
31
+ <oneOrMore>
32
+ <ref name="sections"/>
33
+ </oneOrMore>
34
+ <zeroOrMore>
35
+ <ref name="annex"/>
36
+ </zeroOrMore>
37
+ <zeroOrMore>
38
+ <ref name="references"/>
39
+ </zeroOrMore>
40
+ </element>
41
+ </define>
42
+ <define name="bibdata">
43
+ <element name="bibdata">
44
+ <ref name="BibData"/>
45
+ </element>
46
+ </define>
47
+ <define name="status">
48
+ <element name="status">
49
+ <ref name="FormattedString"/>
50
+ </element>
51
+ </define>
52
+ <define name="version">
53
+ <element name="version">
54
+ <optional>
55
+ <ref name="vedition"/>
56
+ </optional>
57
+ <optional>
58
+ <ref name="revision-date"/>
59
+ </optional>
60
+ <zeroOrMore>
61
+ <ref name="draft"/>
62
+ </zeroOrMore>
63
+ </element>
64
+ </define>
65
+ <define name="vedition">
66
+ <element name="edition">
67
+ <data type="int"/>
68
+ </element>
69
+ </define>
70
+ <define name="revision-date">
71
+ <element name="revision-date">
72
+ <data type="date"/>
73
+ </element>
74
+ </define>
75
+ <define name="draft">
76
+ <element name="draft">
77
+ <text/>
78
+ </element>
79
+ </define>
80
+ <define name="sections">
81
+ <element name="sections">
82
+ <oneOrMore>
83
+ <choice>
84
+ <ref name="content"/>
85
+ <ref name="clause"/>
86
+ <ref name="terms"/>
87
+ <ref name="definitions"/>
88
+ </choice>
89
+ </oneOrMore>
90
+ </element>
91
+ </define>
92
+ <define name="definitions">
93
+ <element name="definitions">
94
+ <optional>
95
+ <attribute name="id">
96
+ <data type="ID"/>
97
+ </attribute>
98
+ </optional>
99
+ <optional>
100
+ <ref name="section-title"/>
101
+ </optional>
102
+ <ref name="dl"/>
103
+ </element>
104
+ </define>
105
+ <define name="section-title">
106
+ <element name="title">
107
+ <text/>
108
+ </element>
109
+ </define>
110
+ <define name="content">
111
+ <element name="content">
112
+ <ref name="Content-Section"/>
113
+ </element>
114
+ </define>
115
+ <define name="content-subsection">
116
+ <element name="clause">
117
+ <ref name="Content-Section"/>
118
+ </element>
119
+ </define>
120
+ <define name="Basic-Section">
121
+ <optional>
122
+ <attribute name="id">
123
+ <data type="ID"/>
124
+ </attribute>
125
+ </optional>
126
+ <optional>
127
+ <ref name="section-title"/>
128
+ </optional>
129
+ <oneOrMore>
130
+ <ref name="BasicBlock"/>
131
+ </oneOrMore>
132
+ <zeroOrMore>
133
+ <ref name="note"/>
134
+ </zeroOrMore>
135
+ </define>
136
+ <define name="Content-Section">
137
+ <optional>
138
+ <attribute name="id">
139
+ <data type="ID"/>
140
+ </attribute>
141
+ </optional>
142
+ <optional>
143
+ <ref name="section-title"/>
144
+ </optional>
145
+ <choice>
146
+ <group>
147
+ <oneOrMore>
148
+ <ref name="BasicBlock"/>
149
+ </oneOrMore>
150
+ <zeroOrMore>
151
+ <ref name="note"/>
152
+ </zeroOrMore>
153
+ </group>
154
+ <oneOrMore>
155
+ <ref name="content-subsection"/>
156
+ </oneOrMore>
157
+ </choice>
158
+ </define>
159
+ <define name="clause">
160
+ <element name="clause">
161
+ <ref name="Clause-Section"/>
162
+ </element>
163
+ </define>
164
+ <define name="Clause-Section">
165
+ <optional>
166
+ <attribute name="id">
167
+ <data type="ID"/>
168
+ </attribute>
169
+ </optional>
170
+ <optional>
171
+ <ref name="section-title"/>
172
+ </optional>
173
+ <choice>
174
+ <group>
175
+ <oneOrMore>
176
+ <ref name="BasicBlock"/>
177
+ </oneOrMore>
178
+ <zeroOrMore>
179
+ <ref name="note"/>
180
+ </zeroOrMore>
181
+ </group>
182
+ <oneOrMore>
183
+ <ref name="clause-subsection"/>
184
+ </oneOrMore>
185
+ </choice>
186
+ </define>
187
+ <define name="clause-subsection">
188
+ <element name="clause">
189
+ <ref name="Clause-Section"/>
190
+ </element>
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
+ <attribute name="obligation">
200
+ <choice>
201
+ <value>normative</value>
202
+ <value>informative</value>
203
+ </choice>
204
+ </attribute>
205
+ <optional>
206
+ <ref name="section-title"/>
207
+ </optional>
208
+ <choice>
209
+ <group>
210
+ <oneOrMore>
211
+ <ref name="BasicBlock"/>
212
+ </oneOrMore>
213
+ <zeroOrMore>
214
+ <ref name="note"/>
215
+ </zeroOrMore>
216
+ </group>
217
+ <oneOrMore>
218
+ <ref name="clause-subsection"/>
219
+ </oneOrMore>
220
+ </choice>
221
+ </element>
222
+ </define>
223
+ <define name="references">
224
+ <element name="references">
225
+ <optional>
226
+ <attribute name="id">
227
+ <data type="ID"/>
228
+ </attribute>
229
+ </optional>
230
+ <optional>
231
+ <ref name="section-title"/>
232
+ </optional>
233
+ <zeroOrMore>
234
+ <ref name="bibitem"/>
235
+ </zeroOrMore>
236
+ </element>
237
+ </define>
238
+ <define name="terms">
239
+ <element name="terms">
240
+ <optional>
241
+ <attribute name="id">
242
+ <data type="ID"/>
243
+ </attribute>
244
+ </optional>
245
+ <oneOrMore>
246
+ <ref name="term"/>
247
+ </oneOrMore>
248
+ </element>
249
+ </define>
250
+ <define name="term">
251
+ <element name="term">
252
+ <optional>
253
+ <attribute name="id">
254
+ <data type="ID"/>
255
+ </attribute>
256
+ </optional>
257
+ <oneOrMore>
258
+ <ref name="preferred"/>
259
+ </oneOrMore>
260
+ <zeroOrMore>
261
+ <ref name="admitted"/>
262
+ </zeroOrMore>
263
+ <zeroOrMore>
264
+ <ref name="deprecates"/>
265
+ </zeroOrMore>
266
+ <optional>
267
+ <ref name="termdomain"/>
268
+ </optional>
269
+ <ref name="definition"/>
270
+ <zeroOrMore>
271
+ <ref name="termnote"/>
272
+ </zeroOrMore>
273
+ <zeroOrMore>
274
+ <ref name="termexample"/>
275
+ </zeroOrMore>
276
+ <zeroOrMore>
277
+ <ref name="termsource"/>
278
+ </zeroOrMore>
279
+ </element>
280
+ </define>
281
+ <define name="preferred">
282
+ <element name="preferred">
283
+ <oneOrMore>
284
+ <ref name="TextElement"/>
285
+ </oneOrMore>
286
+ </element>
287
+ </define>
288
+ <define name="admitted">
289
+ <element name="admitted">
290
+ <oneOrMore>
291
+ <ref name="TextElement"/>
292
+ </oneOrMore>
293
+ </element>
294
+ </define>
295
+ <define name="deprecates">
296
+ <element name="deprecates">
297
+ <oneOrMore>
298
+ <ref name="TextElement"/>
299
+ </oneOrMore>
300
+ </element>
301
+ </define>
302
+ <define name="termdomain">
303
+ <element name="domain">
304
+ <oneOrMore>
305
+ <ref name="TextElement"/>
306
+ </oneOrMore>
307
+ </element>
308
+ </define>
309
+ <define name="definition">
310
+ <element name="definition">
311
+ <ref name="paragraph"/>
312
+ </element>
313
+ </define>
314
+ <define name="termnote">
315
+ <element name="termnote">
316
+ <attribute name="id">
317
+ <data type="ID"/>
318
+ </attribute>
319
+ <ref name="paragraph"/>
320
+ </element>
321
+ </define>
322
+ <define name="termexample">
323
+ <element name="termexample">
324
+ <attribute name="id">
325
+ <data type="ID"/>
326
+ </attribute>
327
+ <ref name="BasicBlock"/>
328
+ </element>
329
+ </define>
330
+ <define name="termsource">
331
+ <element name="termsource">
332
+ <attribute name="status">
333
+ <choice>
334
+ <value>identical</value>
335
+ <value>modified</value>
336
+ </choice>
337
+ </attribute>
338
+ <ref name="origin"/>
339
+ <optional>
340
+ <ref name="modification"/>
341
+ </optional>
342
+ </element>
343
+ </define>
344
+ <define name="origin">
345
+ <element name="origin">
346
+ <ref name="erefType"/>
347
+ </element>
348
+ </define>
349
+ <define name="modification">
350
+ <element name="modification">
351
+ <ref name="paragraph"/>
352
+ </element>
353
+ </define>
354
+ <define name="BasicBlock">
355
+ <choice>
356
+ <ref name="paragraph-with-footnote"/>
357
+ <ref name="table"/>
358
+ <ref name="formula"/>
359
+ <ref name="admonition"/>
360
+ <ref name="ol"/>
361
+ <ref name="ul"/>
362
+ <ref name="dl"/>
363
+ <ref name="figure"/>
364
+ <ref name="quote"/>
365
+ <ref name="sourcecode"/>
366
+ <ref name="example"/>
367
+ <ref name="review"/>
368
+ </choice>
369
+ </define>
370
+ <define name="paragraph">
371
+ <element name="p">
372
+ <ref name="ParagraphType"/>
373
+ </element>
374
+ </define>
375
+ <define name="Alignments">
376
+ <choice>
377
+ <value>left</value>
378
+ <value>right</value>
379
+ <value>center</value>
380
+ <value>justified</value>
381
+ </choice>
382
+ </define>
383
+ <define name="ParagraphType">
384
+ <attribute name="id">
385
+ <data type="ID"/>
386
+ </attribute>
387
+ <optional>
388
+ <attribute name="align">
389
+ <ref name="Alignments"/>
390
+ </attribute>
391
+ </optional>
392
+ <zeroOrMore>
393
+ <ref name="TextElement"/>
394
+ </zeroOrMore>
395
+ <zeroOrMore>
396
+ <ref name="note"/>
397
+ </zeroOrMore>
398
+ </define>
399
+ <define name="paragraph-with-footnote">
400
+ <element name="p">
401
+ <attribute name="id">
402
+ <data type="ID"/>
403
+ </attribute>
404
+ <optional>
405
+ <attribute name="align">
406
+ <ref name="Alignments"/>
407
+ </attribute>
408
+ </optional>
409
+ <zeroOrMore>
410
+ <choice>
411
+ <ref name="TextElement"/>
412
+ <ref name="fn"/>
413
+ </choice>
414
+ </zeroOrMore>
415
+ <zeroOrMore>
416
+ <ref name="note"/>
417
+ </zeroOrMore>
418
+ </element>
419
+ </define>
420
+ <define name="note">
421
+ <element name="note">
422
+ <attribute name="id">
423
+ <data type="ID"/>
424
+ </attribute>
425
+ <oneOrMore>
426
+ <ref name="paragraph-with-footnote"/>
427
+ </oneOrMore>
428
+ </element>
429
+ </define>
430
+ <define name="review">
431
+ <element name="review">
432
+ <attribute name="id">
433
+ <data type="ID"/>
434
+ </attribute>
435
+ <attribute name="reviewer"/>
436
+ <optional>
437
+ <attribute name="date">
438
+ <data type="dateTime"/>
439
+ </attribute>
440
+ </optional>
441
+ <attribute name="from">
442
+ <data type="IDREF"/>
443
+ </attribute>
444
+ <optional>
445
+ <attribute name="to">
446
+ <data type="IDREF"/>
447
+ </attribute>
448
+ </optional>
449
+ <oneOrMore>
450
+ <ref name="paragraph"/>
451
+ </oneOrMore>
452
+ </element>
453
+ </define>
454
+ <define name="formula">
455
+ <element name="formula">
456
+ <attribute name="id">
457
+ <data type="ID"/>
458
+ </attribute>
459
+ <ref name="stem"/>
460
+ <optional>
461
+ <ref name="dl"/>
462
+ </optional>
463
+ <zeroOrMore>
464
+ <ref name="note"/>
465
+ </zeroOrMore>
466
+ </element>
467
+ </define>
468
+ <define name="quote">
469
+ <element name="quote">
470
+ <attribute name="id">
471
+ <data type="ID"/>
472
+ </attribute>
473
+ <optional>
474
+ <attribute name="alignment">
475
+ <ref name="Alignments"/>
476
+ </attribute>
477
+ </optional>
478
+ <optional>
479
+ <ref name="quote-source"/>
480
+ </optional>
481
+ <optional>
482
+ <ref name="quote-author"/>
483
+ </optional>
484
+ <oneOrMore>
485
+ <ref name="paragraph-with-footnote"/>
486
+ </oneOrMore>
487
+ <zeroOrMore>
488
+ <ref name="note"/>
489
+ </zeroOrMore>
490
+ </element>
491
+ </define>
492
+ <define name="quote-source">
493
+ <element name="source">
494
+ <ref name="erefType"/>
495
+ </element>
496
+ </define>
497
+ <define name="quote-author">
498
+ <element name="author">
499
+ <text/>
500
+ </element>
501
+ </define>
502
+ <define name="sourcecode">
503
+ <element name="sourcecode">
504
+ <attribute name="id">
505
+ <data type="ID"/>
506
+ </attribute>
507
+ <optional>
508
+ <ref name="tname"/>
509
+ </optional>
510
+ <oneOrMore>
511
+ <choice>
512
+ <text/>
513
+ <ref name="callout"/>
514
+ </choice>
515
+ </oneOrMore>
516
+ <zeroOrMore>
517
+ <ref name="annotation"/>
518
+ </zeroOrMore>
519
+ <zeroOrMore>
520
+ <ref name="note"/>
521
+ </zeroOrMore>
522
+ </element>
523
+ </define>
524
+ <define name="table">
525
+ <element name="table">
526
+ <attribute name="id">
527
+ <data type="ID"/>
528
+ </attribute>
529
+ <optional>
530
+ <ref name="tname"/>
531
+ </optional>
532
+ <optional>
533
+ <ref name="thead"/>
534
+ </optional>
535
+ <ref name="tbody"/>
536
+ <optional>
537
+ <ref name="tfoot"/>
538
+ </optional>
539
+ <zeroOrMore>
540
+ <ref name="table-note"/>
541
+ </zeroOrMore>
542
+ <optional>
543
+ <ref name="dl"/>
544
+ </optional>
545
+ </element>
546
+ </define>
547
+ <define name="tname">
548
+ <element name="name">
549
+ <text/>
550
+ </element>
551
+ </define>
552
+ <define name="thead">
553
+ <element name="thead">
554
+ <ref name="tr"/>
555
+ </element>
556
+ </define>
557
+ <define name="tfoot">
558
+ <element name="tfoot">
559
+ <ref name="tr"/>
560
+ </element>
561
+ </define>
562
+ <define name="tbody">
563
+ <element name="tbody">
564
+ <oneOrMore>
565
+ <ref name="tr"/>
566
+ </oneOrMore>
567
+ </element>
568
+ </define>
569
+ <define name="table-note">
570
+ <element name="note">
571
+ <ref name="paragraph"/>
572
+ </element>
573
+ </define>
574
+ <define name="tr">
575
+ <element name="tr">
576
+ <oneOrMore>
577
+ <choice>
578
+ <ref name="td"/>
579
+ <ref name="th"/>
580
+ </choice>
581
+ </oneOrMore>
582
+ </element>
583
+ </define>
584
+ <define name="td">
585
+ <element name="td">
586
+ <optional>
587
+ <attribute name="colspan"/>
588
+ </optional>
589
+ <optional>
590
+ <attribute name="rowspan"/>
591
+ </optional>
592
+ <optional>
593
+ <attribute name="align">
594
+ <choice>
595
+ <value>left</value>
596
+ <value>right</value>
597
+ <value>center</value>
598
+ </choice>
599
+ </attribute>
600
+ </optional>
601
+ <choice>
602
+ <zeroOrMore>
603
+ <ref name="TextElement"/>
604
+ </zeroOrMore>
605
+ <oneOrMore>
606
+ <ref name="paragraph-with-footnote"/>
607
+ </oneOrMore>
608
+ </choice>
609
+ </element>
610
+ </define>
611
+ <define name="th">
612
+ <element name="th">
613
+ <optional>
614
+ <attribute name="colspan"/>
615
+ </optional>
616
+ <optional>
617
+ <attribute name="rowspan"/>
618
+ </optional>
619
+ <optional>
620
+ <attribute name="align">
621
+ <choice>
622
+ <value>left</value>
623
+ <value>right</value>
624
+ <value>center</value>
625
+ </choice>
626
+ </attribute>
627
+ </optional>
628
+ <choice>
629
+ <zeroOrMore>
630
+ <ref name="TextElement"/>
631
+ </zeroOrMore>
632
+ <oneOrMore>
633
+ <ref name="paragraph-with-footnote"/>
634
+ </oneOrMore>
635
+ </choice>
636
+ </element>
637
+ </define>
638
+ <define name="example">
639
+ <element name="example">
640
+ <attribute name="id">
641
+ <data type="ID"/>
642
+ </attribute>
643
+ <oneOrMore>
644
+ <choice>
645
+ <ref name="formula"/>
646
+ <ref name="ul"/>
647
+ <ref name="ol"/>
648
+ <ref name="dl"/>
649
+ <ref name="quote"/>
650
+ <ref name="sourcecode"/>
651
+ <ref name="paragraph-with-footnote"/>
652
+ </choice>
653
+ </oneOrMore>
654
+ <zeroOrMore>
655
+ <ref name="note"/>
656
+ </zeroOrMore>
657
+ </element>
658
+ </define>
659
+ <define name="admonition">
660
+ <element name="admonition">
661
+ <attribute name="type">
662
+ <choice>
663
+ <value>warning</value>
664
+ <value>note</value>
665
+ <value>tip</value>
666
+ <value>important</value>
667
+ <value>caution</value>
668
+ </choice>
669
+ </attribute>
670
+ <attribute name="id">
671
+ <data type="ID"/>
672
+ </attribute>
673
+ <zeroOrMore>
674
+ <ref name="paragraph-with-footnote"/>
675
+ </zeroOrMore>
676
+ <zeroOrMore>
677
+ <ref name="note"/>
678
+ </zeroOrMore>
679
+ </element>
680
+ </define>
681
+ <define name="figure">
682
+ <element name="figure">
683
+ <attribute name="id">
684
+ <data type="ID"/>
685
+ </attribute>
686
+ <optional>
687
+ <ref name="source"/>
688
+ </optional>
689
+ <optional>
690
+ <ref name="tname"/>
691
+ </optional>
692
+ <choice>
693
+ <oneOrMore>
694
+ <ref name="figure"/>
695
+ </oneOrMore>
696
+ <group>
697
+ <zeroOrMore>
698
+ <ref name="TextElement"/>
699
+ </zeroOrMore>
700
+ <zeroOrMore>
701
+ <ref name="note"/>
702
+ </zeroOrMore>
703
+ <optional>
704
+ <ref name="dl"/>
705
+ </optional>
706
+ </group>
707
+ </choice>
708
+ </element>
709
+ </define>
710
+ <define name="TextElement">
711
+ <choice>
712
+ <text/>
713
+ <ref name="em"/>
714
+ <ref name="eref"/>
715
+ <ref name="strong"/>
716
+ <ref name="stem"/>
717
+ <ref name="sub"/>
718
+ <ref name="sup"/>
719
+ <ref name="tt"/>
720
+ <ref name="strike"/>
721
+ <ref name="smallcap"/>
722
+ <ref name="xref"/>
723
+ <ref name="br"/>
724
+ <ref name="hyperlink"/>
725
+ <ref name="hr"/>
726
+ <ref name="pagebreak"/>
727
+ <ref name="bookmark"/>
728
+ </choice>
729
+ </define>
730
+ <define name="source">
731
+ <element name="source">
732
+ <ref name="TypedUri"/>
733
+ </element>
734
+ </define>
735
+ <define name="em">
736
+ <element name="em">
737
+ <text/>
738
+ </element>
739
+ </define>
740
+ <define name="strong">
741
+ <element name="strong">
742
+ <text/>
743
+ </element>
744
+ </define>
745
+ <define name="tt">
746
+ <element name="tt">
747
+ <text/>
748
+ </element>
749
+ </define>
750
+ <define name="sub">
751
+ <element name="sub">
752
+ <text/>
753
+ </element>
754
+ </define>
755
+ <define name="sup">
756
+ <element name="sup">
757
+ <text/>
758
+ </element>
759
+ </define>
760
+ <define name="strike">
761
+ <element name="strike">
762
+ <text/>
763
+ </element>
764
+ </define>
765
+ <define name="smallcap">
766
+ <element name="smallcap">
767
+ <text/>
768
+ </element>
769
+ </define>
770
+ <define name="br">
771
+ <element name="br">
772
+ <empty/>
773
+ </element>
774
+ </define>
775
+ <define name="hr">
776
+ <element name="hr">
777
+ <empty/>
778
+ </element>
779
+ </define>
780
+ <define name="pagebreak">
781
+ <element name="pagebreak">
782
+ <empty/>
783
+ </element>
784
+ </define>
785
+ <!-- bare ID element, used for referencing arbitrary spans of text -->
786
+ <define name="bookmark">
787
+ <element name="bookmark">
788
+ <attribute name="id">
789
+ <data type="ID"/>
790
+ </attribute>
791
+ <empty/>
792
+ </element>
793
+ </define>
794
+ <define name="ReferenceFormat">
795
+ <choice>
796
+ <value>external</value>
797
+ <value>inline</value>
798
+ <value>footnote</value>
799
+ <value>callout</value>
800
+ </choice>
801
+ </define>
802
+ <define name="eref">
803
+ <element name="eref">
804
+ <ref name="erefType"/>
805
+ </element>
806
+ </define>
807
+ <define name="erefType">
808
+ <optional>
809
+ <attribute name="normative">
810
+ <data type="boolean"/>
811
+ </attribute>
812
+ </optional>
813
+ <attribute name="citeas"/>
814
+ <attribute name="type">
815
+ <ref name="ReferenceFormat"/>
816
+ </attribute>
817
+ <ref name="CitationType"/>
818
+ <text/>
819
+ </define>
820
+ <define name="hyperlink">
821
+ <element name="link">
822
+ <attribute name="target">
823
+ <data type="anyURI"/>
824
+ </attribute>
825
+ <attribute name="type">
826
+ <ref name="ReferenceFormat"/>
827
+ </attribute>
828
+ <text/>
829
+ </element>
830
+ </define>
831
+ <define name="xref">
832
+ <element name="xref">
833
+ <attribute name="target">
834
+ <data type="IDREF"/>
835
+ </attribute>
836
+ <attribute name="type">
837
+ <ref name="ReferenceFormat"/>
838
+ </attribute>
839
+ <text/>
840
+ </element>
841
+ </define>
842
+ <define name="fn">
843
+ <element name="fn">
844
+ <attribute name="reference"/>
845
+ <oneOrMore>
846
+ <ref name="paragraph"/>
847
+ </oneOrMore>
848
+ </element>
849
+ </define>
850
+ <!--
851
+ This is xref with fixed @type="footnote", and @target built in as paragraph+
852
+ @reference replaces ReferenceElement/text
853
+ so <fn reference="2"><p>This is a footnote</p></fn>
854
+ corresponds to
855
+ <eref type="footnote" target="fn2">2</xref> <p id="fn2">This is a footnote</p>
856
+ -->
857
+ <define name="callout">
858
+ <element name="callout">
859
+ <attribute name="target">
860
+ <data type="IDREF"/>
861
+ </attribute>
862
+ <text/>
863
+ </element>
864
+ </define>
865
+ <!--
866
+ This is xref with fixed @type="callout"; the target by convention is in an annotation in the same source code snippet
867
+ so <callout target="xyz">1</callout>
868
+ corresponds to <xref type="callout" target="xyz">1</xref>
869
+ -->
870
+ <define name="image">
871
+ <element name="image">
872
+ <attribute name="id">
873
+ <data type="ID"/>
874
+ </attribute>
875
+ <optional>
876
+ <attribute name="src">
877
+ <data type="anyURI"/>
878
+ </attribute>
879
+ </optional>
880
+ <attribute name="imagetype">
881
+ <choice>
882
+ <value>SVG</value>
883
+ <value>JPEG</value>
884
+ <value>GIF</value>
885
+ <value>PNG</value>
886
+ <value>PDF</value>
887
+ </choice>
888
+ </attribute>
889
+ <optional>
890
+ <attribute name="width">
891
+ <choice>
892
+ <data type="int"/>
893
+ <value>auto</value>
894
+ </choice>
895
+ </attribute>
896
+ </optional>
897
+ <optional>
898
+ <attribute name="height">
899
+ <choice>
900
+ <data type="int"/>
901
+ <value>auto</value>
902
+ </choice>
903
+ </attribute>
904
+ </optional>
905
+ </element>
906
+ </define>
907
+ <define name="stem">
908
+ <element name="stem">
909
+ <attribute name="type">
910
+ <choice>
911
+ <value>MathML</value>
912
+ <value>AsciiMath</value>
913
+ </choice>
914
+ </attribute>
915
+ <text/>
916
+ </element>
917
+ </define>
918
+ <define name="annotation">
919
+ <element name="annotation">
920
+ <attribute name="id">
921
+ <data type="ID"/>
922
+ </attribute>
923
+ <ref name="paragraph"/>
924
+ </element>
925
+ </define>
926
+ <define name="ul">
927
+ <element name="ul">
928
+ <attribute name="id">
929
+ <data type="ID"/>
930
+ </attribute>
931
+ <oneOrMore>
932
+ <ref name="li"/>
933
+ </oneOrMore>
934
+ <zeroOrMore>
935
+ <ref name="note"/>
936
+ </zeroOrMore>
937
+ </element>
938
+ </define>
939
+ <define name="li">
940
+ <element name="li">
941
+ <oneOrMore>
942
+ <ref name="paragraph-with-footnote"/>
943
+ </oneOrMore>
944
+ </element>
945
+ </define>
946
+ <define name="ol">
947
+ <element name="ol">
948
+ <attribute name="id">
949
+ <data type="ID"/>
950
+ </attribute>
951
+ <attribute name="type">
952
+ <choice>
953
+ <value>roman</value>
954
+ <value>alphabet</value>
955
+ <value>arabic</value>
956
+ <value>roman_upper</value>
957
+ <value>alphabet_upper</value>
958
+ </choice>
959
+ </attribute>
960
+ <oneOrMore>
961
+ <ref name="li"/>
962
+ </oneOrMore>
963
+ <zeroOrMore>
964
+ <ref name="note"/>
965
+ </zeroOrMore>
966
+ </element>
967
+ </define>
968
+ <define name="dl">
969
+ <element name="dl">
970
+ <attribute name="id">
971
+ <data type="ID"/>
972
+ </attribute>
973
+ <oneOrMore>
974
+ <ref name="dt"/>
975
+ <ref name="dd"/>
976
+ </oneOrMore>
977
+ <zeroOrMore>
978
+ <ref name="note"/>
979
+ </zeroOrMore>
980
+ </element>
981
+ </define>
982
+ <define name="dt">
983
+ <element name="dt">
984
+ <ref name="TextElement"/>
985
+ </element>
986
+ </define>
987
+ <define name="dd">
988
+ <element name="dd">
989
+ <zeroOrMore>
990
+ <ref name="paragraph-with-footnote"/>
991
+ </zeroOrMore>
992
+ </element>
993
+ </define>
994
+ <define name="BibData">
995
+ <optional>
996
+ <attribute name="type">
997
+ <ref name="BibItemType"/>
998
+ </attribute>
999
+ </optional>
1000
+ <oneOrMore>
1001
+ <ref name="btitle"/>
1002
+ </oneOrMore>
1003
+ <optional>
1004
+ <ref name="formattedref"/>
1005
+ </optional>
1006
+ <zeroOrMore>
1007
+ <ref name="bsource"/>
1008
+ </zeroOrMore>
1009
+ <zeroOrMore>
1010
+ <ref name="docidentifier"/>
1011
+ </zeroOrMore>
1012
+ <zeroOrMore>
1013
+ <ref name="bdate"/>
1014
+ </zeroOrMore>
1015
+ <zeroOrMore>
1016
+ <ref name="contributor"/>
1017
+ </zeroOrMore>
1018
+ <optional>
1019
+ <ref name="edition"/>
1020
+ </optional>
1021
+ <zeroOrMore>
1022
+ <ref name="biblionote"/>
1023
+ </zeroOrMore>
1024
+ <zeroOrMore>
1025
+ <ref name="language"/>
1026
+ </zeroOrMore>
1027
+ <zeroOrMore>
1028
+ <ref name="script"/>
1029
+ </zeroOrMore>
1030
+ <optional>
1031
+ <ref name="abstract"/>
1032
+ </optional>
1033
+ <optional>
1034
+ <ref name="status"/>
1035
+ </optional>
1036
+ <ref name="copyright"/>
1037
+ <zeroOrMore>
1038
+ <ref name="docrelation"/>
1039
+ </zeroOrMore>
1040
+ </define>
1041
+ </grammar>