rng 0.1.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +63 -0
  3. data/.github/workflows/release.yml +8 -3
  4. data/.gitignore +11 -0
  5. data/.rubocop.yml +10 -7
  6. data/.rubocop_todo.yml +229 -23
  7. data/CHANGELOG.md +317 -0
  8. data/CLAUDE.md +139 -0
  9. data/Gemfile +11 -12
  10. data/README.adoc +1538 -11
  11. data/Rakefile +11 -3
  12. data/docs/Gemfile +8 -0
  13. data/docs/_config.yml +23 -0
  14. data/docs/getting-started/index.adoc +75 -0
  15. data/docs/guides/error-handling.adoc +137 -0
  16. data/docs/guides/external-references.adoc +128 -0
  17. data/docs/guides/index.adoc +24 -0
  18. data/docs/guides/parsing-rnc.adoc +141 -0
  19. data/docs/guides/parsing-rng-xml.adoc +81 -0
  20. data/docs/guides/rng-to-rnc.adoc +101 -0
  21. data/docs/guides/validation.adoc +85 -0
  22. data/docs/index.adoc +52 -0
  23. data/docs/reference/api.adoc +126 -0
  24. data/docs/reference/cli.adoc +182 -0
  25. data/docs/understanding/architecture.adoc +58 -0
  26. data/docs/understanding/rng-vs-rnc.adoc +118 -0
  27. data/exe/rng +5 -0
  28. data/lib/rng/any_name.rb +10 -8
  29. data/lib/rng/attribute.rb +28 -26
  30. data/lib/rng/choice.rb +24 -24
  31. data/lib/rng/cli.rb +607 -0
  32. data/lib/rng/data.rb +10 -10
  33. data/lib/rng/datatype_declaration.rb +26 -0
  34. data/lib/rng/define.rb +44 -41
  35. data/lib/rng/div.rb +36 -0
  36. data/lib/rng/documentation.rb +9 -0
  37. data/lib/rng/element.rb +39 -37
  38. data/lib/rng/empty.rb +7 -7
  39. data/lib/rng/except.rb +25 -25
  40. data/lib/rng/external_ref.rb +8 -8
  41. data/lib/rng/external_ref_resolver.rb +602 -0
  42. data/lib/rng/foreign_attribute.rb +26 -0
  43. data/lib/rng/foreign_element.rb +33 -0
  44. data/lib/rng/grammar.rb +14 -12
  45. data/lib/rng/group.rb +26 -24
  46. data/lib/rng/include.rb +5 -6
  47. data/lib/rng/include_processor.rb +461 -0
  48. data/lib/rng/interleave.rb +23 -23
  49. data/lib/rng/list.rb +22 -22
  50. data/lib/rng/mixed.rb +23 -23
  51. data/lib/rng/name.rb +6 -7
  52. data/lib/rng/namespace_declaration.rb +47 -0
  53. data/lib/rng/namespaces.rb +15 -0
  54. data/lib/rng/not_allowed.rb +7 -7
  55. data/lib/rng/ns_name.rb +9 -9
  56. data/lib/rng/one_or_more.rb +23 -23
  57. data/lib/rng/optional.rb +23 -23
  58. data/lib/rng/param.rb +7 -8
  59. data/lib/rng/parent_ref.rb +8 -8
  60. data/lib/rng/parse_tree_processor.rb +695 -0
  61. data/lib/rng/pattern.rb +7 -7
  62. data/lib/rng/ref.rb +8 -8
  63. data/lib/rng/rnc_builder.rb +927 -0
  64. data/lib/rng/rnc_parser.rb +605 -305
  65. data/lib/rng/rnc_to_rng_converter.rb +1408 -0
  66. data/lib/rng/schema_preamble.rb +73 -0
  67. data/lib/rng/schema_validator.rb +1622 -0
  68. data/lib/rng/start.rb +27 -25
  69. data/lib/rng/test_suite_parser.rb +168 -0
  70. data/lib/rng/text.rb +11 -8
  71. data/lib/rng/to_rnc.rb +4 -35
  72. data/lib/rng/value.rb +6 -7
  73. data/lib/rng/version.rb +1 -1
  74. data/lib/rng/zero_or_more.rb +23 -23
  75. data/lib/rng.rb +68 -17
  76. data/rng.gemspec +18 -19
  77. data/scripts/extract_spectest_resources.rb +96 -0
  78. data/spec/fixtures/compacttest.xml +2511 -0
  79. data/spec/fixtures/external/circular_a.rng +7 -0
  80. data/spec/fixtures/external/circular_b.rng +7 -0
  81. data/spec/fixtures/external/circular_main.rng +7 -0
  82. data/spec/fixtures/external/external_ref_lib.rng +7 -0
  83. data/spec/fixtures/external/external_ref_main.rng +7 -0
  84. data/spec/fixtures/external/include_lib.rng +7 -0
  85. data/spec/fixtures/external/include_main.rng +3 -0
  86. data/spec/fixtures/external/nested_chain.rng +6 -0
  87. data/spec/fixtures/external/nested_leaf.rng +7 -0
  88. data/spec/fixtures/external/nested_mid.rng +8 -0
  89. data/spec/fixtures/metanorma/3gpp.rnc +35 -0
  90. data/spec/fixtures/metanorma/3gpp.rng +105 -0
  91. data/spec/fixtures/metanorma/basicdoc.rnc +11 -0
  92. data/spec/fixtures/metanorma/bipm.rnc +148 -0
  93. data/spec/fixtures/metanorma/bipm.rng +376 -0
  94. data/spec/fixtures/metanorma/bsi.rnc +104 -0
  95. data/spec/fixtures/metanorma/bsi.rng +332 -0
  96. data/spec/fixtures/metanorma/csa.rnc +45 -0
  97. data/spec/fixtures/metanorma/csa.rng +131 -0
  98. data/spec/fixtures/metanorma/csd.rnc +43 -0
  99. data/spec/fixtures/metanorma/csd.rng +132 -0
  100. data/spec/fixtures/metanorma/gbstandard.rnc +99 -0
  101. data/spec/fixtures/metanorma/gbstandard.rng +316 -0
  102. data/spec/fixtures/metanorma/iec.rnc +49 -0
  103. data/spec/fixtures/metanorma/iec.rng +193 -0
  104. data/spec/fixtures/metanorma/ietf.rnc +275 -0
  105. data/spec/fixtures/metanorma/ietf.rng +925 -0
  106. data/spec/fixtures/metanorma/iho.rnc +58 -0
  107. data/spec/fixtures/metanorma/iho.rng +179 -0
  108. data/spec/fixtures/metanorma/isodoc.rnc +873 -0
  109. data/spec/fixtures/metanorma/isodoc.rng +2704 -0
  110. data/spec/fixtures/metanorma/isostandard-amd.rnc +43 -0
  111. data/spec/fixtures/metanorma/isostandard-amd.rng +108 -0
  112. data/spec/fixtures/metanorma/isostandard.rnc +166 -0
  113. data/spec/fixtures/metanorma/isostandard.rng +494 -0
  114. data/spec/fixtures/metanorma/itu.rnc +122 -0
  115. data/spec/fixtures/metanorma/itu.rng +377 -0
  116. data/spec/fixtures/metanorma/m3d.rnc +41 -0
  117. data/spec/fixtures/metanorma/m3d.rng +122 -0
  118. data/spec/fixtures/metanorma/mpfd.rnc +36 -0
  119. data/spec/fixtures/metanorma/mpfd.rng +95 -0
  120. data/spec/fixtures/metanorma/nist.rnc +77 -0
  121. data/spec/fixtures/metanorma/nist.rng +216 -0
  122. data/spec/fixtures/metanorma/ogc.rnc +51 -0
  123. data/spec/fixtures/metanorma/ogc.rng +151 -0
  124. data/spec/fixtures/metanorma/reqt.rnc +6 -0
  125. data/spec/fixtures/metanorma/rsd.rnc +36 -0
  126. data/spec/fixtures/metanorma/rsd.rng +95 -0
  127. data/spec/fixtures/metanorma/un.rnc +103 -0
  128. data/spec/fixtures/metanorma/un.rng +367 -0
  129. data/spec/fixtures/rnc/base.rnc +4 -0
  130. data/spec/fixtures/rnc/grammar_with_trailing.rnc +8 -0
  131. data/spec/fixtures/rnc/main_include_trailing.rnc +3 -0
  132. data/spec/fixtures/rnc/main_with_include.rnc +5 -0
  133. data/spec/fixtures/rnc/test_augment.rnc +10 -0
  134. data/spec/fixtures/rnc/test_isodoc_simple.rnc +9 -0
  135. data/spec/fixtures/rnc/top_level_include.rnc +8 -0
  136. data/spec/fixtures/spectest_external/case_10_4.7/x +3 -0
  137. data/spec/fixtures/spectest_external/case_10_4.7/y +7 -0
  138. data/spec/fixtures/spectest_external/case_11_4.7/x +3 -0
  139. data/spec/fixtures/spectest_external/case_12_4.7/x +3 -0
  140. data/spec/fixtures/spectest_external/case_13_4.7/x +3 -0
  141. data/spec/fixtures/spectest_external/case_13_4.7/y +3 -0
  142. data/spec/fixtures/spectest_external/case_14_4.7/x +7 -0
  143. data/spec/fixtures/spectest_external/case_15_4.7/x +7 -0
  144. data/spec/fixtures/spectest_external/case_16_4.7/x +5 -0
  145. data/spec/fixtures/spectest_external/case_17_4.7/x +5 -0
  146. data/spec/fixtures/spectest_external/case_18_4.7/x +7 -0
  147. data/spec/fixtures/spectest_external/case_19_4.7/level1.rng +9 -0
  148. data/spec/fixtures/spectest_external/case_19_4.7/level2.rng +7 -0
  149. data/spec/fixtures/spectest_external/case_1_4.5/sub1/x +3 -0
  150. data/spec/fixtures/spectest_external/case_1_4.5/sub3/x +3 -0
  151. data/spec/fixtures/spectest_external/case_1_4.5/x +3 -0
  152. data/spec/fixtures/spectest_external/case_20_4.6/x +3 -0
  153. data/spec/fixtures/spectest_external/case_2_4.5/x +3 -0
  154. data/spec/fixtures/spectest_external/case_3_4.6/x +3 -0
  155. data/spec/fixtures/spectest_external/case_4_4.6/x +3 -0
  156. data/spec/fixtures/spectest_external/case_5_4.6/x +1 -0
  157. data/spec/fixtures/spectest_external/case_6_4.6/x +5 -0
  158. data/spec/fixtures/spectest_external/case_7_4.6/x +1 -0
  159. data/spec/fixtures/spectest_external/case_7_4.6/y +1 -0
  160. data/spec/fixtures/spectest_external/case_8_4.7/x +7 -0
  161. data/spec/fixtures/spectest_external/case_9_4.7/x +7 -0
  162. data/spec/fixtures/spectest_external/resources.json +149 -0
  163. data/spec/rng/advanced_rnc_spec.rb +101 -0
  164. data/spec/rng/compacttest_spec.rb +197 -0
  165. data/spec/rng/datatype_declaration_spec.rb +28 -0
  166. data/spec/rng/div_spec.rb +207 -0
  167. data/spec/rng/external_ref_resolver_spec.rb +122 -0
  168. data/spec/rng/metanorma_conversion_spec.rb +159 -0
  169. data/spec/rng/namespace_declaration_spec.rb +60 -0
  170. data/spec/rng/namespace_support_spec.rb +199 -0
  171. data/spec/rng/rnc_parser_spec.rb +498 -22
  172. data/spec/rng/rnc_roundtrip_spec.rb +96 -82
  173. data/spec/rng/rng_generation_spec.rb +288 -0
  174. data/spec/rng/roundtrip_spec.rb +342 -0
  175. data/spec/rng/schema_preamble_spec.rb +145 -0
  176. data/spec/rng/schema_spec.rb +68 -64
  177. data/spec/rng/spectest_spec.rb +168 -90
  178. data/spec/rng_spec.rb +2 -2
  179. data/spec/spec_helper.rb +7 -42
  180. metadata +141 -8
@@ -0,0 +1,275 @@
1
+ # Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
2
+ # we cannot have a new default namespace: we will end up with a grammar with two different
3
+ # namespaces, one for isostandard and one for ietf additions. And we do not want that.
4
+
5
+ include "isodoc.rnc" {
6
+
7
+ start = ietf-standard
8
+
9
+ DocumentType = "rfc" | "internet-draft"
10
+
11
+ BibDataExtensionType =
12
+ doctype?, docsubtype?, editorialgroup*, ics*, area*, ipr?, consensus?, index-include?, ipr-extract?, sort-refs?, sym-refs?, toc-include?, toc-depth?, show-on-front-page?, processing-instructions?
13
+
14
+ ParagraphType =
15
+ attribute id { xsd:ID },
16
+ attribute align { Alignments }?,
17
+ attribute keep-with-next { xsd:boolean }?,
18
+ attribute keep-with-previous { xsd:boolean }?,
19
+ ( TextElement )*, note*
20
+
21
+ paragraph-with-footnote =
22
+ element p {
23
+ attribute id { xsd:ID },
24
+ attribute align { Alignments }?,
25
+ ( TextElement | fn )*, note*
26
+ }
27
+ ul =
28
+ element ul {
29
+ attribute id { xsd:ID },
30
+ attribute nobullet { text }?,
31
+ attribute spacing { text }?,
32
+ li+, note*
33
+ }
34
+
35
+ ol =
36
+ element ol {
37
+ attribute id { xsd:ID },
38
+ attribute type { ( "roman" | "alphabet" | "arabic" |
39
+ "roman_upper" | "alphabet_upper" | "text" ) },
40
+ attribute group { text }?,
41
+ attribute spacing { text }?,
42
+ attribute start { text }?,
43
+ li+, note*
44
+ }
45
+
46
+ dl =
47
+ element dl {
48
+ attribute id { xsd:ID },
49
+ attribute newline { text }?,
50
+ attribute indent { text }?,
51
+ attribute spacing { text }?,
52
+ (dt, dd)+, note*
53
+ }
54
+
55
+ review =
56
+ element review {
57
+ attribute id { xsd:ID },
58
+ attribute reviewer { text },
59
+ attribute date { xsd:dateTime }?,
60
+ attribute from { xsd:IDREF },
61
+ attribute to { xsd:IDREF }?,
62
+ attribute display { text }?,
63
+ paragraph+
64
+ }
65
+
66
+ note =
67
+ element note {
68
+ attribute id { xsd:ID },
69
+ attribute removeInRFC { text }?,
70
+ tname?, paragraph+
71
+ }
72
+
73
+ pre =
74
+ element pre {
75
+ attribute id { xsd:ID },
76
+ attribute alt { text }?,
77
+ attribute align { text }?,
78
+ tname?, text, note*
79
+ }
80
+
81
+ image =
82
+ element image {
83
+ attribute id { xsd:ID },
84
+ attribute src { xsd:anyURI },
85
+ attribute mimetype { text },
86
+ attribute filename { text }?,
87
+ attribute width { xsd:int | "auto" }?,
88
+ attribute height { xsd:int | "auto" }?,
89
+ attribute alt { text }?,
90
+ attribute title { text }?,
91
+ attribute longdesc { xsd:anyURI }?,
92
+ attribute align { text }?
93
+ }
94
+
95
+ sourcecode =
96
+ element sourcecode {
97
+ attribute id { xsd:ID },
98
+ attribute unnumbered { xsd:boolean }?,
99
+ attribute number { text }?,
100
+ attribute subsequence { text }?,
101
+ attribute lang { text }?,
102
+ attribute markers { text }?,
103
+ tname?, ( text | callout )+, annotation*, note*
104
+ }
105
+
106
+ xref =
107
+ element xref {
108
+ attribute target { xsd:IDREF },
109
+ attribute type { ReferenceFormat }?,
110
+ attribute alt { text }?,
111
+ attribute format { text }?,
112
+ XrefBody
113
+ }
114
+
115
+ erefType =
116
+ attribute normative { xsd:boolean }?,
117
+ attribute citeas { text },
118
+ attribute type { ReferenceFormat },
119
+ attribute alt { text }?,
120
+ attribute displayFormat { text }?,
121
+ attribute relative { text }?,
122
+ CitationType,
123
+ text
124
+
125
+ quote-source =
126
+ element source { erefTypeURI }
127
+
128
+ table =
129
+ element table {
130
+ attribute id { xsd:ID },
131
+ attribute unnumbered { xsd:boolean }?,
132
+ attribute number { text }?,
133
+ attribute subsequence { text }?,
134
+ attribute alt { text }?,
135
+ attribute summary { text }?,
136
+ attribute uri { xsd:anyURI }?,
137
+ attribute align { text }?,
138
+ tname?, thead?, tbody, tfoot?, table-note*, dl?
139
+ }
140
+
141
+ Clause-Section =
142
+ attribute id { xsd:ID }?,
143
+ attribute language { text }?,
144
+ attribute script { text }?,
145
+ attribute numbered { text }?,
146
+ attribute removeInRFC { text }?,
147
+ attribute toc { text }?,
148
+ attribute inline-header { xsd:boolean }?,
149
+ attribute obligation { ( "normative" | "informative" ) },
150
+ section-title?,
151
+ (
152
+ ( BasicBlock* ),
153
+ (clause-subsection | terms | definitions)*
154
+ )
155
+
156
+ annex =
157
+ element annex {
158
+ attribute id { xsd:ID }?,
159
+ attribute language { text }?,
160
+ attribute script { text }?,
161
+ attribute obligation { ( "normative" | "informative" ) },
162
+ attribute numbered { text }?,
163
+ attribute removeInRFC { text }?,
164
+ attribute toc { text }?,
165
+ section-title?,
166
+ ( ( BasicBlock* ), clause-subsection* )
167
+ }
168
+
169
+ Content-Section =
170
+ attribute id { xsd:ID }?,
171
+ attribute language { text }?,
172
+ attribute script { text }?,
173
+ attribute numbered { text }?,
174
+ attribute removeInRFC { text }?,
175
+ attribute toc { text }?,
176
+ section-title?,
177
+ ( (BasicBlock*),
178
+ content-subsection* )
179
+
180
+
181
+ editorialgroup = element editorialgroup {
182
+ committee*
183
+ }
184
+
185
+ index = element index {
186
+ attribute to { xsd:IDREF }?,
187
+ attribute primary { xsd:boolean }?,
188
+ element primary { PureTextElement+ },
189
+ element secondary { PureTextElement+ }?,
190
+ element tertiary { PureTextElement+ }?
191
+ }
192
+
193
+ }
194
+
195
+
196
+ TextElement |= bcp14 | review
197
+
198
+ bcp14 = element bcp14 { text }
199
+
200
+ committee = element committee { IsoWorkgroup }
201
+
202
+ area = element area { "art" | "gen" | "int" | "ops" | "rtg" | "sec" | "tsv" |
203
+ "Applications and Real-Time" | "General" | "Internet" | "Operations and Management" |
204
+ "Routing" | "Security" | "Transport" }
205
+
206
+ comment = element comment { text }
207
+
208
+ ipr = element ipr { text }
209
+ consensus = element consensus { text }
210
+ index-include = element indexInclude { text }
211
+ ipr-extract = element iprExtract { text }
212
+ sort-refs = element sortRefs { text }
213
+ sym-refs = element symRefs { text }
214
+ toc-include = element tocInclude { text }
215
+ toc-depth = element tocDepth { text }
216
+ show-on-front-page = element showOnFrontPage { text }
217
+
218
+ processing-instructions = element pi {
219
+ element artworkdelimiter { text }?,
220
+ element artworklines { text }?,
221
+ element authorship { text }?,
222
+ element autobreaks { text }?,
223
+ element background { text }?,
224
+ element colonspace { text }?,
225
+ element comments { text }?,
226
+ element docmapping { text }?,
227
+ element editing { text }?,
228
+ element emoticonic { text }?,
229
+ element footer { text }?,
230
+ element header { text }?,
231
+ element inline { text }?,
232
+ element iprnotified { text }?,
233
+ element linkmailto { text }?,
234
+ element linefile { text }?,
235
+ element notedraftinprogress { text }?,
236
+ element private { text }?,
237
+ element refparent { text }?,
238
+ element rfcedstyle { text }?,
239
+ element slides { text }?,
240
+ element text-list-symbols { text }?,
241
+ element tocappendix { text }?,
242
+ element tocindent { text }?,
243
+ element tocnarrow { text }?,
244
+ element tocompact { text }?,
245
+ element topblock { text }?,
246
+ element useobject { text }?,
247
+ element strict { text }?,
248
+ element compact { text }?,
249
+ element subcompact { text }?,
250
+ element tocinclude { text }?,
251
+ element tocdepth { text }?,
252
+ element symrefs { text }?,
253
+ element sortrefs { text }?
254
+ }
255
+
256
+ erefTypeURI =
257
+ attribute normative { xsd:boolean }?,
258
+ attribute citeas { text }?,
259
+ attribute type { ReferenceFormat },
260
+ attribute alt { text }?,
261
+ attribute displayFormat { text }?,
262
+ attribute relative { text }?,
263
+ attribute bibitemid { xsd:IDREF }?,
264
+ attribute uri { xsd:anyURI }?,
265
+ locality*, date?,
266
+ text
267
+
268
+
269
+ ietf-standard =
270
+ element ietf-standard {
271
+ attribute version { text },
272
+ attribute type { "semantic" | "presentation" },
273
+ bibdata, termdocsource*, misccontainer?, boilerplate?, preface, sections+, annex*, bibliography, indexsect*
274
+ }
275
+