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,2511 @@
1
+ <testSuite>
2
+ <testCase>
3
+ <compact>
4
+ <correct>
5
+ element foo { empty }
6
+ </correct>
7
+ </compact>
8
+ <xml>
9
+ <correct>
10
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
11
+ <empty/>
12
+ </element>
13
+ </correct>
14
+ </xml>
15
+ </testCase>
16
+ <testCase>
17
+ <compact>
18
+ <correct>
19
+ element foo { text }
20
+ </correct>
21
+ </compact>
22
+ <xml>
23
+ <correct>
24
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
25
+ <text/>
26
+ </element>
27
+ </correct>
28
+ </xml>
29
+ </testCase>
30
+ <testCase>
31
+ <compact>
32
+ <correct><![CDATA[
33
+ # RELAX NG syntax expressed in compact syntax.
34
+
35
+ default namespace rng = "http://relaxng.org/ns/structure/1.0"
36
+ namespace local = ""
37
+ datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
38
+
39
+ start = pattern
40
+
41
+ pattern =
42
+ element element { (nameQName | nameClass), (common & pattern+) }
43
+ | element attribute { (nameQName | nameClass), (common & pattern?) }
44
+ | element group|interleave|choice|optional
45
+ |zeroOrMore|oneOrMore|list|mixed { common & pattern+ }
46
+ | element ref|parentRef { nameNCName, common }
47
+ | element empty|notAllowed|text { common }
48
+ | element data { type, param*, (common & exceptPattern?) }
49
+ | element value { commonAttributes, type?, xsd:string }
50
+ | element externalRef { href, common }
51
+ | element grammar { common & grammarContent* }
52
+
53
+ param = element param { commonAttributes, nameNCName, xsd:string }
54
+
55
+ exceptPattern = element except { common & pattern+ }
56
+
57
+ grammarContent =
58
+ definition
59
+ | element div { common & grammarContent* }
60
+ | element include { href, (common & includeContent*) }
61
+
62
+ includeContent =
63
+ definition
64
+ | element div { common & includeContent* }
65
+
66
+ definition =
67
+ element start { combine?, (common & pattern+) }
68
+ | element define { nameNCName, combine?, (common & pattern+) }
69
+
70
+ combine = attribute combine { "choice" | "interleave" }
71
+
72
+ nameClass =
73
+ element name { commonAttributes, xsd:QName }
74
+ | element anyName { common & exceptNameClass? }
75
+ | element nsName { common & exceptNameClass? }
76
+ | element choice { common & nameClass+ }
77
+
78
+ exceptNameClass = element except { common & nameClass+ }
79
+
80
+ nameQName = attribute name { xsd:QName }
81
+ nameNCName = attribute name { xsd:NCName }
82
+ href = attribute href { xsd:anyURI }
83
+ type = attribute type { xsd:NCName }
84
+
85
+ common = commonAttributes, foreignElement*
86
+
87
+ commonAttributes =
88
+ attribute ns { xsd:string }?,
89
+ attribute datatypeLibrary { xsd:anyURI }?,
90
+ foreignAttribute*
91
+
92
+ foreignElement = element * - rng:* { (anyAttribute | text | anyElement)* }
93
+ foreignAttribute = attribute * - (rng:*|local:*) { text }
94
+ anyElement = element * { (anyAttribute | text | anyElement)* }
95
+ anyAttribute = attribute * { text }
96
+
97
+ ]]></correct>
98
+ </compact>
99
+ <xml>
100
+ <correct>
101
+ <!-- RELAX NG syntax expressed in compact syntax. -->
102
+ <grammar ns="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
103
+ <start>
104
+ <ref name="pattern"/>
105
+ </start>
106
+ <define name="pattern">
107
+ <choice>
108
+ <element name="element">
109
+ <choice>
110
+ <ref name="nameQName"/>
111
+ <ref name="nameClass"/>
112
+ </choice>
113
+ <interleave>
114
+ <ref name="common"/>
115
+ <oneOrMore>
116
+ <ref name="pattern"/>
117
+ </oneOrMore>
118
+ </interleave>
119
+ </element>
120
+ <element name="attribute">
121
+ <choice>
122
+ <ref name="nameQName"/>
123
+ <ref name="nameClass"/>
124
+ </choice>
125
+ <interleave>
126
+ <ref name="common"/>
127
+ <optional>
128
+ <ref name="pattern"/>
129
+ </optional>
130
+ </interleave>
131
+ </element>
132
+ <element>
133
+ <choice>
134
+ <name>group</name>
135
+ <name>interleave</name>
136
+ <name>choice</name>
137
+ <name>optional</name>
138
+ <name>zeroOrMore</name>
139
+ <name>oneOrMore</name>
140
+ <name>list</name>
141
+ <name>mixed</name>
142
+ </choice>
143
+ <interleave>
144
+ <ref name="common"/>
145
+ <oneOrMore>
146
+ <ref name="pattern"/>
147
+ </oneOrMore>
148
+ </interleave>
149
+ </element>
150
+ <element>
151
+ <choice>
152
+ <name>ref</name>
153
+ <name>parentRef</name>
154
+ </choice>
155
+ <ref name="nameNCName"/>
156
+ <ref name="common"/>
157
+ </element>
158
+ <element>
159
+ <choice>
160
+ <name>empty</name>
161
+ <name>notAllowed</name>
162
+ <name>text</name>
163
+ </choice>
164
+ <ref name="common"/>
165
+ </element>
166
+ <element name="data">
167
+ <ref name="type"/>
168
+ <zeroOrMore>
169
+ <ref name="param"/>
170
+ </zeroOrMore>
171
+ <interleave>
172
+ <ref name="common"/>
173
+ <optional>
174
+ <ref name="exceptPattern"/>
175
+ </optional>
176
+ </interleave>
177
+ </element>
178
+ <element name="value">
179
+ <ref name="commonAttributes"/>
180
+ <optional>
181
+ <ref name="type"/>
182
+ </optional>
183
+ <data type="string"/>
184
+ </element>
185
+ <element name="externalRef">
186
+ <ref name="href"/>
187
+ <ref name="common"/>
188
+ </element>
189
+ <element name="grammar">
190
+ <interleave>
191
+ <ref name="common"/>
192
+ <zeroOrMore>
193
+ <ref name="grammarContent"/>
194
+ </zeroOrMore>
195
+ </interleave>
196
+ </element>
197
+ </choice>
198
+ </define>
199
+ <define name="param">
200
+ <element name="param">
201
+ <ref name="commonAttributes"/>
202
+ <ref name="nameNCName"/>
203
+ <data type="string"/>
204
+ </element>
205
+ </define>
206
+ <define name="exceptPattern">
207
+ <element name="except">
208
+ <interleave>
209
+ <ref name="common"/>
210
+ <oneOrMore>
211
+ <ref name="pattern"/>
212
+ </oneOrMore>
213
+ </interleave>
214
+ </element>
215
+ </define>
216
+ <define name="grammarContent">
217
+ <choice>
218
+ <ref name="definition"/>
219
+ <element name="div">
220
+ <interleave>
221
+ <ref name="common"/>
222
+ <zeroOrMore>
223
+ <ref name="grammarContent"/>
224
+ </zeroOrMore>
225
+ </interleave>
226
+ </element>
227
+ <element name="include">
228
+ <ref name="href"/>
229
+ <interleave>
230
+ <ref name="common"/>
231
+ <zeroOrMore>
232
+ <ref name="includeContent"/>
233
+ </zeroOrMore>
234
+ </interleave>
235
+ </element>
236
+ </choice>
237
+ </define>
238
+ <define name="includeContent">
239
+ <choice>
240
+ <ref name="definition"/>
241
+ <element name="div">
242
+ <interleave>
243
+ <ref name="common"/>
244
+ <zeroOrMore>
245
+ <ref name="includeContent"/>
246
+ </zeroOrMore>
247
+ </interleave>
248
+ </element>
249
+ </choice>
250
+ </define>
251
+ <define name="definition">
252
+ <choice>
253
+ <element name="start">
254
+ <optional>
255
+ <ref name="combine"/>
256
+ </optional>
257
+ <interleave>
258
+ <ref name="common"/>
259
+ <oneOrMore>
260
+ <ref name="pattern"/>
261
+ </oneOrMore>
262
+ </interleave>
263
+ </element>
264
+ <element name="define">
265
+ <ref name="nameNCName"/>
266
+ <optional>
267
+ <ref name="combine"/>
268
+ </optional>
269
+ <interleave>
270
+ <ref name="common"/>
271
+ <oneOrMore>
272
+ <ref name="pattern"/>
273
+ </oneOrMore>
274
+ </interleave>
275
+ </element>
276
+ </choice>
277
+ </define>
278
+ <define name="combine">
279
+ <attribute name="combine">
280
+ <choice>
281
+ <value>choice</value>
282
+ <value>interleave</value>
283
+ </choice>
284
+ </attribute>
285
+ </define>
286
+ <define name="nameClass">
287
+ <choice>
288
+ <element name="name">
289
+ <ref name="commonAttributes"/>
290
+ <data type="QName"/>
291
+ </element>
292
+ <element name="anyName">
293
+ <interleave>
294
+ <ref name="common"/>
295
+ <optional>
296
+ <ref name="exceptNameClass"/>
297
+ </optional>
298
+ </interleave>
299
+ </element>
300
+ <element name="nsName">
301
+ <interleave>
302
+ <ref name="common"/>
303
+ <optional>
304
+ <ref name="exceptNameClass"/>
305
+ </optional>
306
+ </interleave>
307
+ </element>
308
+ <element name="choice">
309
+ <interleave>
310
+ <ref name="common"/>
311
+ <oneOrMore>
312
+ <ref name="nameClass"/>
313
+ </oneOrMore>
314
+ </interleave>
315
+ </element>
316
+ </choice>
317
+ </define>
318
+ <define name="exceptNameClass">
319
+ <element name="except">
320
+ <interleave>
321
+ <ref name="common"/>
322
+ <oneOrMore>
323
+ <ref name="nameClass"/>
324
+ </oneOrMore>
325
+ </interleave>
326
+ </element>
327
+ </define>
328
+ <define name="nameQName">
329
+ <attribute name="name">
330
+ <data type="QName"/>
331
+ </attribute>
332
+ </define>
333
+ <define name="nameNCName">
334
+ <attribute name="name">
335
+ <data type="NCName"/>
336
+ </attribute>
337
+ </define>
338
+ <define name="href">
339
+ <attribute name="href">
340
+ <data type="anyURI"/>
341
+ </attribute>
342
+ </define>
343
+ <define name="type">
344
+ <attribute name="type">
345
+ <data type="NCName"/>
346
+ </attribute>
347
+ </define>
348
+ <define name="common">
349
+ <ref name="commonAttributes"/>
350
+ <zeroOrMore>
351
+ <ref name="foreignElement"/>
352
+ </zeroOrMore>
353
+ </define>
354
+ <define name="commonAttributes">
355
+ <optional>
356
+ <attribute name="ns">
357
+ <data type="string"/>
358
+ </attribute>
359
+ </optional>
360
+ <optional>
361
+ <attribute name="datatypeLibrary">
362
+ <data type="anyURI"/>
363
+ </attribute>
364
+ </optional>
365
+ <zeroOrMore>
366
+ <ref name="foreignAttribute"/>
367
+ </zeroOrMore>
368
+ </define>
369
+ <define name="foreignElement">
370
+ <element>
371
+ <anyName>
372
+ <except>
373
+ <nsName/>
374
+ </except>
375
+ </anyName>
376
+ <zeroOrMore>
377
+ <choice>
378
+ <ref name="anyAttribute"/>
379
+ <text/>
380
+ <ref name="anyElement"/>
381
+ </choice>
382
+ </zeroOrMore>
383
+ </element>
384
+ </define>
385
+ <define name="foreignAttribute">
386
+ <attribute>
387
+ <anyName>
388
+ <except>
389
+ <nsName/>
390
+ <nsName ns=""/>
391
+ </except>
392
+ </anyName>
393
+ </attribute>
394
+ </define>
395
+ <define name="anyElement">
396
+ <element>
397
+ <anyName/>
398
+ <zeroOrMore>
399
+ <choice>
400
+ <ref name="anyAttribute"/>
401
+ <text/>
402
+ <ref name="anyElement"/>
403
+ </choice>
404
+ </zeroOrMore>
405
+ </element>
406
+ </define>
407
+ <define name="anyAttribute">
408
+ <attribute>
409
+ <anyName/>
410
+ </attribute>
411
+ </define>
412
+ </grammar>
413
+ </correct>
414
+ </xml>
415
+ </testCase>
416
+ <testCase>
417
+ <compact>
418
+ <correct><![CDATA[
419
+ # Based on http://www.w3.org/TR/2001/WD-rdf-syntax-grammar-20010906/
420
+
421
+ namespace local = ""
422
+ namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
423
+ datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
424
+
425
+ start = RDF
426
+ RDF = element rdf:RDF { attribute xml:base { URI-reference }?, node* } | node
427
+ node = description | typedNode
428
+ description = element rdf:Description {
429
+ idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
430
+ }
431
+ typedNode = element * - (local:*
432
+ |rdf:Description|rdf:RDF
433
+ |rdf:ID|rdf:about|rdf:aboutEach
434
+ |rdf:bagID|rdf:parseType|rdf:resource) {
435
+ idAboutAttr?, bagIdAttr?, propertyAttr*, propertyElt*
436
+ }
437
+ propertyElt = element * - (local:*
438
+ |rdf:Description|rdf:RDF
439
+ |rdf:ID|rdf:about|rdf:aboutEach
440
+ |rdf:bagID|rdf:parseType|rdf:resource) {
441
+ (idAttr?, (node
442
+ | string
443
+ | (parseLiteral, literal)
444
+ | (parseResource, propertyElt*)
445
+ | (parseOther, any)
446
+ | (bagIdAttr?, propertyAttr*)))
447
+ | (resourceAttr, bagIdAttr?, propertyAttr*)
448
+ }
449
+ idAboutAttr = idAttr | aboutAttr | aboutEachAttr
450
+ idAttr = attribute rdf:ID { IDsymbol }
451
+ aboutAttr = attribute rdf:about { URI-reference }
452
+ aboutEachAttr = attribute rdf:aboutEach { URI-reference }
453
+ bagIdAttr = attribute rdf:bagID { IDsymbol }
454
+ propertyAttr = typeAttr | propAttr
455
+ propAttr = attribute * - (local:*|rdf:type|rdf:li
456
+ |rdf:Description|rdf:RDF
457
+ |rdf:ID|rdf:about|rdf:aboutEach
458
+ |rdf:bagID|rdf:parseType|rdf:resource) {
459
+ string
460
+ }
461
+ typeAttr = attribute rdf:type { URI-reference }
462
+ resourceAttr = attribute rdf:resource { URI-reference }
463
+ parseLiteral = attribute rdf:parseType { "Literal" }
464
+ parseResource = attribute rdf:parseType { "Resource" }
465
+ parseOther = attribute rdf:parseType { token - ("Literal"|"Resource") }
466
+ URI-reference = string
467
+ IDsymbol = xsd:NMTOKEN
468
+ literal = any
469
+ any = mixed { element * { attribute * { text }*, any }* }
470
+ ]]></correct>
471
+ </compact>
472
+ <xml>
473
+ <correct>
474
+ <!-- Based on http://www.w3.org/TR/2001/WD-rdf-syntax-grammar-20010906/ -->
475
+ <grammar xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
476
+ <start>
477
+ <ref name="RDF"/>
478
+ </start>
479
+ <define name="RDF">
480
+ <choice>
481
+ <element name="rdf:RDF">
482
+ <optional>
483
+ <attribute name="xml:base">
484
+ <ref name="URI-reference"/>
485
+ </attribute>
486
+ </optional>
487
+ <zeroOrMore>
488
+ <ref name="node"/>
489
+ </zeroOrMore>
490
+ </element>
491
+ <ref name="node"/>
492
+ </choice>
493
+ </define>
494
+ <define name="node">
495
+ <choice>
496
+ <ref name="description"/>
497
+ <ref name="typedNode"/>
498
+ </choice>
499
+ </define>
500
+ <define name="description">
501
+ <element name="rdf:Description">
502
+ <optional>
503
+ <ref name="idAboutAttr"/>
504
+ </optional>
505
+ <optional>
506
+ <ref name="bagIdAttr"/>
507
+ </optional>
508
+ <zeroOrMore>
509
+ <ref name="propertyAttr"/>
510
+ </zeroOrMore>
511
+ <zeroOrMore>
512
+ <ref name="propertyElt"/>
513
+ </zeroOrMore>
514
+ </element>
515
+ </define>
516
+ <define name="typedNode">
517
+ <element>
518
+ <anyName>
519
+ <except>
520
+ <nsName/>
521
+ <name>rdf:Description</name>
522
+ <name>rdf:RDF</name>
523
+ <name>rdf:ID</name>
524
+ <name>rdf:about</name>
525
+ <name>rdf:aboutEach</name>
526
+ <name>rdf:bagID</name>
527
+ <name>rdf:parseType</name>
528
+ <name>rdf:resource</name>
529
+ </except>
530
+ </anyName>
531
+ <optional>
532
+ <ref name="idAboutAttr"/>
533
+ </optional>
534
+ <optional>
535
+ <ref name="bagIdAttr"/>
536
+ </optional>
537
+ <zeroOrMore>
538
+ <ref name="propertyAttr"/>
539
+ </zeroOrMore>
540
+ <zeroOrMore>
541
+ <ref name="propertyElt"/>
542
+ </zeroOrMore>
543
+ </element>
544
+ </define>
545
+ <define name="propertyElt">
546
+ <element>
547
+ <anyName>
548
+ <except>
549
+ <nsName/>
550
+ <name>rdf:Description</name>
551
+ <name>rdf:RDF</name>
552
+ <name>rdf:ID</name>
553
+ <name>rdf:about</name>
554
+ <name>rdf:aboutEach</name>
555
+ <name>rdf:bagID</name>
556
+ <name>rdf:parseType</name>
557
+ <name>rdf:resource</name>
558
+ </except>
559
+ </anyName>
560
+ <choice>
561
+ <group>
562
+ <optional>
563
+ <ref name="idAttr"/>
564
+ </optional>
565
+ <choice>
566
+ <ref name="node"/>
567
+ <data type="string" datatypeLibrary=""/>
568
+ <group>
569
+ <ref name="parseLiteral"/>
570
+ <ref name="literal"/>
571
+ </group>
572
+ <group>
573
+ <ref name="parseResource"/>
574
+ <zeroOrMore>
575
+ <ref name="propertyElt"/>
576
+ </zeroOrMore>
577
+ </group>
578
+ <group>
579
+ <ref name="parseOther"/>
580
+ <ref name="any"/>
581
+ </group>
582
+ <group>
583
+ <optional>
584
+ <ref name="bagIdAttr"/>
585
+ </optional>
586
+ <zeroOrMore>
587
+ <ref name="propertyAttr"/>
588
+ </zeroOrMore>
589
+ </group>
590
+ </choice>
591
+ </group>
592
+ <group>
593
+ <ref name="resourceAttr"/>
594
+ <optional>
595
+ <ref name="bagIdAttr"/>
596
+ </optional>
597
+ <zeroOrMore>
598
+ <ref name="propertyAttr"/>
599
+ </zeroOrMore>
600
+ </group>
601
+ </choice>
602
+ </element>
603
+ </define>
604
+ <define name="idAboutAttr">
605
+ <choice>
606
+ <ref name="idAttr"/>
607
+ <ref name="aboutAttr"/>
608
+ <ref name="aboutEachAttr"/>
609
+ </choice>
610
+ </define>
611
+ <define name="idAttr">
612
+ <attribute name="rdf:ID">
613
+ <ref name="IDsymbol"/>
614
+ </attribute>
615
+ </define>
616
+ <define name="aboutAttr">
617
+ <attribute name="rdf:about">
618
+ <ref name="URI-reference"/>
619
+ </attribute>
620
+ </define>
621
+ <define name="aboutEachAttr">
622
+ <attribute name="rdf:aboutEach">
623
+ <ref name="URI-reference"/>
624
+ </attribute>
625
+ </define>
626
+ <define name="bagIdAttr">
627
+ <attribute name="rdf:bagID">
628
+ <ref name="IDsymbol"/>
629
+ </attribute>
630
+ </define>
631
+ <define name="propertyAttr">
632
+ <choice>
633
+ <ref name="typeAttr"/>
634
+ <ref name="propAttr"/>
635
+ </choice>
636
+ </define>
637
+ <define name="propAttr">
638
+ <attribute>
639
+ <anyName>
640
+ <except>
641
+ <nsName/>
642
+ <name>rdf:type</name>
643
+ <name>rdf:li</name>
644
+ <name>rdf:Description</name>
645
+ <name>rdf:RDF</name>
646
+ <name>rdf:ID</name>
647
+ <name>rdf:about</name>
648
+ <name>rdf:aboutEach</name>
649
+ <name>rdf:bagID</name>
650
+ <name>rdf:parseType</name>
651
+ <name>rdf:resource</name>
652
+ </except>
653
+ </anyName>
654
+ <data type="string" datatypeLibrary=""/>
655
+ </attribute>
656
+ </define>
657
+ <define name="typeAttr">
658
+ <attribute name="rdf:type">
659
+ <ref name="URI-reference"/>
660
+ </attribute>
661
+ </define>
662
+ <define name="resourceAttr">
663
+ <attribute name="rdf:resource">
664
+ <ref name="URI-reference"/>
665
+ </attribute>
666
+ </define>
667
+ <define name="parseLiteral">
668
+ <attribute name="rdf:parseType">
669
+ <value>Literal</value>
670
+ </attribute>
671
+ </define>
672
+ <define name="parseResource">
673
+ <attribute name="rdf:parseType">
674
+ <value>Resource</value>
675
+ </attribute>
676
+ </define>
677
+ <define name="parseOther">
678
+ <attribute name="rdf:parseType">
679
+ <data type="token" datatypeLibrary="">
680
+ <except>
681
+ <value>Literal</value>
682
+ <value>Resource</value>
683
+ </except>
684
+ </data>
685
+ </attribute>
686
+ </define>
687
+ <define name="URI-reference">
688
+ <data type="string" datatypeLibrary=""/>
689
+ </define>
690
+ <define name="IDsymbol">
691
+ <data type="NMTOKEN"/>
692
+ </define>
693
+ <define name="literal">
694
+ <ref name="any"/>
695
+ </define>
696
+ <define name="any">
697
+ <mixed>
698
+ <zeroOrMore>
699
+ <element>
700
+ <anyName/>
701
+ <zeroOrMore>
702
+ <attribute>
703
+ <anyName/>
704
+ </attribute>
705
+ </zeroOrMore>
706
+ <ref name="any"/>
707
+ </element>
708
+ </zeroOrMore>
709
+ </mixed>
710
+ </define>
711
+ </grammar>
712
+ </correct>
713
+ </xml>
714
+ </testCase>
715
+ <testCase>
716
+ <compact>
717
+ <correct><![CDATA[
718
+ # ibtwsh.dtd
719
+ # This is the Itsy Bitsy Teeny Weeny Simple Hypertext DTD.
720
+ # Its public identifier is -//XML-DEV List//DTD IBTWSH 6.0//EN
721
+ # The contents are dedicated to the public domain by
722
+ # the author, John Cowan <cowan@ccil.org>, except that
723
+ # John Cowan retains the moral right to be known as the author.
724
+ # This is draft 6.2
725
+ # Diff from 6.1: rel|rel now rel|rev, th|td@headers now IDREFS,
726
+ # table width no longer an integer, non-basic table attrs gone,
727
+ # rowspan and colspan must be non-negative
728
+ # Diff from 6.0: added attributes to ul, comment about img, new meta
729
+
730
+ # This is a RELAX NG schema which describes a subset of XHTML Basic for
731
+ # use within other schemas. It is by intention equivalent
732
+ # (within its scope) to -//W3C//DTD XHTML 1.1//EN, but is
733
+ # not a derived work in the copyright sense.
734
+
735
+ # It is often convenient for XML documents to have a bit of
736
+ # documentation somewhere in them. In the absence of a schema like
737
+ # this one, that documentation winds up being <text/> only, which is
738
+ # a pity, because rich text adds measurably to the readability of
739
+ # documents. By incorporating this schema by reference (as an
740
+ # external parameter entity) into another schema, that schema inherits
741
+ # the capabilities of this one. Using HTML-compatible elements
742
+ # and attributes allows the documentation to be passed straight
743
+ # through to HTML renderers.
744
+
745
+ # Current HTML renderers can cope with most XML tags, but empty
746
+ # tags require special treatment. Inserting a space before the
747
+ # terminating "/>" usually makes the "/" (which is not HTML)
748
+ # invisible. Using "<tag></tag>" is not as effective, as the
749
+ # latter is often misinterpreted as a second "<tag>".
750
+
751
+ # Note that since the elements of this schema are intended to be
752
+ # used within domain-specific elements of the surrounding DTD,
753
+ # it is not necessary that every fragment begin with an "html"
754
+ # element, as in HTML. Recommended <define>s for elements
755
+ # containing documentation are "horiz.model" for simple
756
+ # text fragments and "struct.model" for documents in extenso.
757
+
758
+ # Common attributes
759
+
760
+ # All elements (except full-document elements) can have these attributes
761
+
762
+ all = attribute id {xsd:ID}?,
763
+ attribute class {token}?,
764
+ attribute title {text}?
765
+
766
+ # All non-empty elements can have these attributes
767
+
768
+ i18n = attribute xml:lang {text}?,
769
+ attribute dir {"ltr" | "rtl"}?
770
+
771
+ basic = all, i18n
772
+
773
+
774
+ # Models
775
+
776
+ t = text
777
+ horiz.model = basic & t & horiz*
778
+ vert.model = vert* & horiz.model
779
+ struct.model = basic & vert*
780
+
781
+
782
+ # Horizontal formatting elements
783
+
784
+ horiz = a | br | horiz.other
785
+
786
+ a = element a {
787
+ attribute href {xsd:anyURI}?,
788
+ attribute name {text}?,
789
+ attribute rel | rev {xsd:anyURI}?,
790
+ horiz.model
791
+ }
792
+
793
+ br = element br {all, empty}
794
+
795
+ horiz.other = element abbr | acronym | cite | code |
796
+ dfn | em | img | kbd | q | samp | span |
797
+ strong | var {horiz.model}
798
+
799
+
800
+ # Vertical formatting elements
801
+
802
+ vert = header | List | table | vert.other
803
+
804
+ header = element h1 | h2 | h3 {horiz.model}
805
+
806
+
807
+ List = element dl {basic, element dt | dd {horiz.model}+ } |
808
+ element ol|ul {basic, element li {horiz.model}+ }
809
+
810
+ aligns = attribute align {"left" | "center" | "right" | "justified"}?,
811
+ attribute valign {"top" | "middle" | "bottom" | "baseline"}?
812
+
813
+ table = element table {
814
+ basic,
815
+ attribute summary {text}?,
816
+ element caption {horiz.model}?,
817
+ element tr {
818
+ basic,
819
+ aligns,
820
+ tabledata+}+
821
+ }
822
+
823
+ tabledata = element th | td {
824
+ aligns,
825
+ attribute abbr {text}?,
826
+ attribute axis {text}?,
827
+ attribute colspan {xsd:nonNegativeInteger}?,
828
+ attribute headers {xsd:IDREFS}?,
829
+ attribute rowspan {xsd:nonNegativeInteger}?,
830
+ attribute scope {"row" | "col" | "rowgroup" | "colgroup"}?,
831
+ vert.model
832
+ }
833
+
834
+ vert.other = element address {horiz.model} |
835
+ element blockquote {attribute cite {xsd:anyURI}?, struct.model} |
836
+ element div {struct.model} |
837
+ element p {horiz.model} |
838
+ element pre {horiz.model}
839
+
840
+
841
+ # Support for complete HTML documents
842
+
843
+ start = element html {
844
+ i18n,
845
+ attribute xml:base {xsd:anyURI}?,
846
+ attribute xml:space {"preserve" | "default"}?,
847
+ head,
848
+ element body {basic, vert*}
849
+ }
850
+
851
+ head = element head {
852
+ i18n,
853
+ element title {i18n, text},
854
+ element meta {
855
+ attribute name|http-equiv {token}?,
856
+ attribute content {text},
857
+ empty
858
+ }*
859
+ }
860
+
861
+ # END OF ibtwsh.rnc
862
+
863
+
864
+ ]]></correct>
865
+ </compact>
866
+ <xml>
867
+ <correct>
868
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
869
+ <!--
870
+ ibtwsh.dtd
871
+ This is the Itsy Bitsy Teeny Weeny Simple Hypertext DTD.
872
+ Its public identifier is -//XML-DEV List//DTD IBTWSH 6.0//EN
873
+ The contents are dedicated to the public domain by
874
+ the author, John Cowan <cowan@ccil.org>, except that
875
+ John Cowan retains the moral right to be known as the author.
876
+ This is draft 6.2
877
+ Diff from 6.1: rel|rel now rel|rev, th|td@headers now IDREFS,
878
+ table width no longer an integer, non-basic table attrs gone,
879
+ rowspan and colspan must be non-negative
880
+ Diff from 6.0: added attributes to ul, comment about img, new meta
881
+ -->
882
+ <!--
883
+ This is a RELAX NG schema which describes a subset of XHTML Basic for
884
+ use within other schemas. It is by intention equivalent
885
+ (within its scope) to -//W3C//DTD XHTML 1.1//EN, but is
886
+ not a derived work in the copyright sense.
887
+ -->
888
+ <!--
889
+ It is often convenient for XML documents to have a bit of
890
+ documentation somewhere in them. In the absence of a schema like
891
+ this one, that documentation winds up being <text/> only, which is
892
+ a pity, because rich text adds measurably to the readability of
893
+ documents. By incorporating this schema by reference (as an
894
+ external parameter entity) into another schema, that schema inherits
895
+ the capabilities of this one. Using HTML-compatible elements
896
+ and attributes allows the documentation to be passed straight
897
+ through to HTML renderers.
898
+ -->
899
+ <!--
900
+ Current HTML renderers can cope with most XML tags, but empty
901
+ tags require special treatment. Inserting a space before the
902
+ terminating "/>" usually makes the "/" (which is not HTML)
903
+ invisible. Using "<tag></tag>" is not as effective, as the
904
+ latter is often misinterpreted as a second "<tag>".
905
+ -->
906
+ <!--
907
+ Note that since the elements of this schema are intended to be
908
+ used within domain-specific elements of the surrounding DTD,
909
+ it is not necessary that every fragment begin with an "html"
910
+ element, as in HTML. Recommended <define>s for elements
911
+ containing documentation are "horiz.model" for simple
912
+ text fragments and "struct.model" for documents in extenso.
913
+ -->
914
+ <!-- Common attributes -->
915
+ <!-- All elements (except full-document elements) can have these attributes -->
916
+ <define name="all">
917
+ <optional>
918
+ <attribute name="id">
919
+ <data type="ID"/>
920
+ </attribute>
921
+ </optional>
922
+ <optional>
923
+ <attribute name="class">
924
+ <data type="token" datatypeLibrary=""/>
925
+ </attribute>
926
+ </optional>
927
+ <optional>
928
+ <attribute name="title"/>
929
+ </optional>
930
+ </define>
931
+ <!-- All non-empty elements can have these attributes -->
932
+ <define name="i18n">
933
+ <optional>
934
+ <attribute name="xml:lang"/>
935
+ </optional>
936
+ <optional>
937
+ <attribute name="dir">
938
+ <choice>
939
+ <value>ltr</value>
940
+ <value>rtl</value>
941
+ </choice>
942
+ </attribute>
943
+ </optional>
944
+ </define>
945
+ <define name="basic">
946
+ <ref name="all"/>
947
+ <ref name="i18n"/>
948
+ </define>
949
+ <!-- Models -->
950
+ <define name="t">
951
+ <text/>
952
+ </define>
953
+ <define name="horiz.model">
954
+ <interleave>
955
+ <ref name="basic"/>
956
+ <ref name="t"/>
957
+ <zeroOrMore>
958
+ <ref name="horiz"/>
959
+ </zeroOrMore>
960
+ </interleave>
961
+ </define>
962
+ <define name="vert.model">
963
+ <interleave>
964
+ <zeroOrMore>
965
+ <ref name="vert"/>
966
+ </zeroOrMore>
967
+ <ref name="horiz.model"/>
968
+ </interleave>
969
+ </define>
970
+ <define name="struct.model">
971
+ <interleave>
972
+ <ref name="basic"/>
973
+ <zeroOrMore>
974
+ <ref name="vert"/>
975
+ </zeroOrMore>
976
+ </interleave>
977
+ </define>
978
+ <!-- Horizontal formatting elements -->
979
+ <define name="horiz">
980
+ <choice>
981
+ <ref name="a"/>
982
+ <ref name="br"/>
983
+ <ref name="horiz.other"/>
984
+ </choice>
985
+ </define>
986
+ <define name="a">
987
+ <element name="a">
988
+ <optional>
989
+ <attribute name="href">
990
+ <data type="anyURI"/>
991
+ </attribute>
992
+ </optional>
993
+ <optional>
994
+ <attribute name="name"/>
995
+ </optional>
996
+ <optional>
997
+ <attribute>
998
+ <choice>
999
+ <name ns="">rel</name>
1000
+ <name ns="">rev</name>
1001
+ </choice>
1002
+ <data type="anyURI"/>
1003
+ </attribute>
1004
+ </optional>
1005
+ <ref name="horiz.model"/>
1006
+ </element>
1007
+ </define>
1008
+ <define name="br">
1009
+ <element name="br">
1010
+ <ref name="all"/>
1011
+ <empty/>
1012
+ </element>
1013
+ </define>
1014
+ <define name="horiz.other">
1015
+ <element>
1016
+ <choice>
1017
+ <name>abbr</name>
1018
+ <name>acronym</name>
1019
+ <name>cite</name>
1020
+ <name>code</name>
1021
+ <name>dfn</name>
1022
+ <name>em</name>
1023
+ <name>img</name>
1024
+ <name>kbd</name>
1025
+ <name>q</name>
1026
+ <name>samp</name>
1027
+ <name>span</name>
1028
+ <name>strong</name>
1029
+ <name>var</name>
1030
+ </choice>
1031
+ <ref name="horiz.model"/>
1032
+ </element>
1033
+ </define>
1034
+ <!-- Vertical formatting elements -->
1035
+ <define name="vert">
1036
+ <choice>
1037
+ <ref name="header"/>
1038
+ <ref name="List"/>
1039
+ <ref name="table"/>
1040
+ <ref name="vert.other"/>
1041
+ </choice>
1042
+ </define>
1043
+ <define name="header">
1044
+ <element>
1045
+ <choice>
1046
+ <name>h1</name>
1047
+ <name>h2</name>
1048
+ <name>h3</name>
1049
+ </choice>
1050
+ <ref name="horiz.model"/>
1051
+ </element>
1052
+ </define>
1053
+ <define name="List">
1054
+ <choice>
1055
+ <element name="dl">
1056
+ <ref name="basic"/>
1057
+ <oneOrMore>
1058
+ <element>
1059
+ <choice>
1060
+ <name>dt</name>
1061
+ <name>dd</name>
1062
+ </choice>
1063
+ <ref name="horiz.model"/>
1064
+ </element>
1065
+ </oneOrMore>
1066
+ </element>
1067
+ <element>
1068
+ <choice>
1069
+ <name>ol</name>
1070
+ <name>ul</name>
1071
+ </choice>
1072
+ <ref name="basic"/>
1073
+ <oneOrMore>
1074
+ <element name="li">
1075
+ <ref name="horiz.model"/>
1076
+ </element>
1077
+ </oneOrMore>
1078
+ </element>
1079
+ </choice>
1080
+ </define>
1081
+ <define name="aligns">
1082
+ <optional>
1083
+ <attribute name="align">
1084
+ <choice>
1085
+ <value>left</value>
1086
+ <value>center</value>
1087
+ <value>right</value>
1088
+ <value>justified</value>
1089
+ </choice>
1090
+ </attribute>
1091
+ </optional>
1092
+ <optional>
1093
+ <attribute name="valign">
1094
+ <choice>
1095
+ <value>top</value>
1096
+ <value>middle</value>
1097
+ <value>bottom</value>
1098
+ <value>baseline</value>
1099
+ </choice>
1100
+ </attribute>
1101
+ </optional>
1102
+ </define>
1103
+ <define name="table">
1104
+ <element name="table">
1105
+ <ref name="basic"/>
1106
+ <optional>
1107
+ <attribute name="summary"/>
1108
+ </optional>
1109
+ <optional>
1110
+ <element name="caption">
1111
+ <ref name="horiz.model"/>
1112
+ </element>
1113
+ </optional>
1114
+ <oneOrMore>
1115
+ <element name="tr">
1116
+ <ref name="basic"/>
1117
+ <ref name="aligns"/>
1118
+ <oneOrMore>
1119
+ <ref name="tabledata"/>
1120
+ </oneOrMore>
1121
+ </element>
1122
+ </oneOrMore>
1123
+ </element>
1124
+ </define>
1125
+ <define name="tabledata">
1126
+ <element>
1127
+ <choice>
1128
+ <name>th</name>
1129
+ <name>td</name>
1130
+ </choice>
1131
+ <ref name="aligns"/>
1132
+ <optional>
1133
+ <attribute name="abbr"/>
1134
+ </optional>
1135
+ <optional>
1136
+ <attribute name="axis"/>
1137
+ </optional>
1138
+ <optional>
1139
+ <attribute name="colspan">
1140
+ <data type="nonNegativeInteger"/>
1141
+ </attribute>
1142
+ </optional>
1143
+ <optional>
1144
+ <attribute name="headers">
1145
+ <data type="IDREFS"/>
1146
+ </attribute>
1147
+ </optional>
1148
+ <optional>
1149
+ <attribute name="rowspan">
1150
+ <data type="nonNegativeInteger"/>
1151
+ </attribute>
1152
+ </optional>
1153
+ <optional>
1154
+ <attribute name="scope">
1155
+ <choice>
1156
+ <value>row</value>
1157
+ <value>col</value>
1158
+ <value>rowgroup</value>
1159
+ <value>colgroup</value>
1160
+ </choice>
1161
+ </attribute>
1162
+ </optional>
1163
+ <ref name="vert.model"/>
1164
+ </element>
1165
+ </define>
1166
+ <define name="vert.other">
1167
+ <choice>
1168
+ <element name="address">
1169
+ <ref name="horiz.model"/>
1170
+ </element>
1171
+ <element name="blockquote">
1172
+ <optional>
1173
+ <attribute name="cite">
1174
+ <data type="anyURI"/>
1175
+ </attribute>
1176
+ </optional>
1177
+ <ref name="struct.model"/>
1178
+ </element>
1179
+ <element name="div">
1180
+ <ref name="struct.model"/>
1181
+ </element>
1182
+ <element name="p">
1183
+ <ref name="horiz.model"/>
1184
+ </element>
1185
+ <element name="pre">
1186
+ <ref name="horiz.model"/>
1187
+ </element>
1188
+ </choice>
1189
+ </define>
1190
+ <!-- Support for complete HTML documents -->
1191
+ <start>
1192
+ <element name="html">
1193
+ <ref name="i18n"/>
1194
+ <optional>
1195
+ <attribute name="xml:base">
1196
+ <data type="anyURI"/>
1197
+ </attribute>
1198
+ </optional>
1199
+ <optional>
1200
+ <attribute name="xml:space">
1201
+ <choice>
1202
+ <value>preserve</value>
1203
+ <value>default</value>
1204
+ </choice>
1205
+ </attribute>
1206
+ </optional>
1207
+ <ref name="head"/>
1208
+ <element name="body">
1209
+ <ref name="basic"/>
1210
+ <zeroOrMore>
1211
+ <ref name="vert"/>
1212
+ </zeroOrMore>
1213
+ </element>
1214
+ </element>
1215
+ </start>
1216
+ <define name="head">
1217
+ <element name="head">
1218
+ <ref name="i18n"/>
1219
+ <element name="title">
1220
+ <ref name="i18n"/>
1221
+ <text/>
1222
+ </element>
1223
+ <zeroOrMore>
1224
+ <element name="meta">
1225
+ <optional>
1226
+ <attribute>
1227
+ <choice>
1228
+ <name ns="">name</name>
1229
+ <name ns="">http-equiv</name>
1230
+ </choice>
1231
+ <data type="token" datatypeLibrary=""/>
1232
+ </attribute>
1233
+ </optional>
1234
+ <attribute name="content"/>
1235
+ <empty/>
1236
+ </element>
1237
+ </zeroOrMore>
1238
+ </element>
1239
+ </define>
1240
+ </grammar>
1241
+ <!-- END OF ibtwsh.rnc -->
1242
+ </correct>
1243
+ </xml>
1244
+ </testCase>
1245
+ <testCase>
1246
+ <compact>
1247
+ <resource name="x.rnc">
1248
+ foo
1249
+ </resource>
1250
+ <correct><![CDATA[
1251
+ start = external "x.rnc"
1252
+ foo = element foo { empty }
1253
+ ]]></correct>
1254
+ </compact>
1255
+ <xml>
1256
+ <resource name="x.rng">
1257
+ <ref name="foo" xmlns="http://relaxng.org/ns/structure/1.0"/>
1258
+ </resource>
1259
+ <correct>
1260
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
1261
+ <start>
1262
+ <externalRef href="x.rng"/>
1263
+ </start>
1264
+ <define name="foo">
1265
+ <element name="foo">
1266
+ <empty/>
1267
+ </element>
1268
+ </define>
1269
+ </grammar>
1270
+ </correct>
1271
+ </xml>
1272
+ </testCase>
1273
+ <testCase>
1274
+ <compact>
1275
+ <incorrect><![CDATA[
1276
+ element * - foo - bar { empty }
1277
+ ]]></incorrect>
1278
+ </compact>
1279
+ </testCase>
1280
+ <testCase>
1281
+ <compact>
1282
+ <incorrect><![CDATA[
1283
+ string - "foo"*
1284
+ ]]></incorrect>
1285
+ </compact>
1286
+ </testCase>
1287
+ <testCase>
1288
+ <compact>
1289
+ <incorrect><![CDATA[
1290
+ string - "foo" | string - "bar"
1291
+ ]]></incorrect>
1292
+ </compact>
1293
+ </testCase>
1294
+ <testCase>
1295
+ <compact>
1296
+ <incorrect><![CDATA[
1297
+ string - string - "foo"
1298
+ ]]></incorrect>
1299
+ </compact>
1300
+ </testCase>
1301
+ <testCase>
1302
+ <compact>
1303
+ <incorrect><![CDATA[
1304
+ namespace eg = "http://www.example.com"
1305
+ [ eg:x = "foo" eg:x = "foo" ]
1306
+ element foo { empty }
1307
+ ]]></incorrect>
1308
+ </compact>
1309
+ </testCase>
1310
+ <testCase>
1311
+ <compact>
1312
+ <incorrect><![CDATA[
1313
+ namespace eg1 = "http://www.example.com"
1314
+ namespace eg2 = "http://www.example.com"
1315
+ [ eg1:x = "foo" eg2:x = "foo" ]
1316
+ element foo { empty }
1317
+ ]]></incorrect>
1318
+ </compact>
1319
+ </testCase>
1320
+ <testCase>
1321
+ <compact>
1322
+ <incorrect><![CDATA[
1323
+ namespace xmlns = "http://www.example.com"
1324
+ [ xmlns:x = "foo" ]
1325
+ element foo { empty }
1326
+ ]]></incorrect>
1327
+ </compact>
1328
+ </testCase>
1329
+ <testCase>
1330
+ <compact>
1331
+ <incorrect><![CDATA[
1332
+ namespace xns = "http://www.w3.org/2000/xmlns"
1333
+ [ xns:x = "foo" ]
1334
+ element foo { empty }
1335
+ ]]></incorrect>
1336
+ </compact>
1337
+ </testCase>
1338
+ <testCase>
1339
+ <compact>
1340
+ <incorrect><![CDATA[
1341
+ namespace xml = "http://www.example.com"
1342
+ [ xml:space = "default" ]
1343
+ element foo { empty }
1344
+ ]]></incorrect>
1345
+ </compact>
1346
+ </testCase>
1347
+ <testCase>
1348
+ <compact>
1349
+ <incorrect><![CDATA[
1350
+ namespace xm = "http://www.w3.org/XML/1998/namespace"
1351
+ [ xm:space = "default" ]
1352
+ element foo { empty }
1353
+ ]]></incorrect>
1354
+ </compact>
1355
+ </testCase>
1356
+ <testCase>
1357
+ <compact>
1358
+ <correct><![CDATA[
1359
+ namespace xml = "http://www.w3.org/XML/1998/namespace"
1360
+ [ xml:space = "default" ]
1361
+ element foo { empty }
1362
+ ]]></correct>
1363
+ </compact>
1364
+ <xml>
1365
+ <correct>
1366
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0" xml:space="default">
1367
+ <empty/>
1368
+ </element>
1369
+ </correct>
1370
+ </xml>
1371
+ </testCase>
1372
+ <testCase>
1373
+ <compact>
1374
+ <incorrect><![CDATA[
1375
+ foo [ xmlns = "bar" ]
1376
+ start = element foo { empty }
1377
+ ]]></incorrect>
1378
+ </compact>
1379
+ </testCase>
1380
+ <testCase>
1381
+ <compact>
1382
+ <correct><![CDATA[
1383
+ element foo { empty }
1384
+ # comment
1385
+ | element bar { empty }
1386
+ ]]></correct>
1387
+ </compact>
1388
+ <xml>
1389
+ <correct>
1390
+ <choice xmlns="http://relaxng.org/ns/structure/1.0">
1391
+ <element name="foo">
1392
+ <empty/>
1393
+ </element>
1394
+ <!-- comment -->
1395
+ <element name="bar">
1396
+ <empty/>
1397
+ </element>
1398
+ </choice>
1399
+ </correct>
1400
+ </xml>
1401
+ </testCase>
1402
+ <testCase>
1403
+ <compact>
1404
+ <correct><![CDATA[
1405
+ element foo { empty }
1406
+ # comment
1407
+ *
1408
+ ]]></correct>
1409
+ </compact>
1410
+ <xml>
1411
+ <correct>
1412
+ <zeroOrMore xmlns="http://relaxng.org/ns/structure/1.0">
1413
+ <element name="foo">
1414
+ <empty/>
1415
+ </element>
1416
+ <!-- comment -->
1417
+ </zeroOrMore>
1418
+ </correct>
1419
+ </xml>
1420
+ </testCase>
1421
+ <testCase>
1422
+ <compact>
1423
+ <correct><![CDATA[
1424
+ # comment
1425
+ namespace eg = ""
1426
+ element foo { empty }
1427
+ ]]></correct>
1428
+ </compact>
1429
+ <xml>
1430
+ <correct>
1431
+ <!-- comment -->
1432
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1433
+ <empty/>
1434
+ </element>
1435
+ </correct>
1436
+ </xml>
1437
+ </testCase>
1438
+ <testCase>
1439
+ <compact>
1440
+ <correct><![CDATA[
1441
+ namespace eg =
1442
+ # comment
1443
+ ""
1444
+ element foo { empty }
1445
+ ]]></correct>
1446
+ </compact>
1447
+ <xml>
1448
+ <correct>
1449
+ <!-- comment -->
1450
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1451
+ <empty/>
1452
+ </element>
1453
+ </correct>
1454
+ </xml>
1455
+ </testCase>
1456
+ <testCase>
1457
+ <compact>
1458
+ <correct><![CDATA[
1459
+ namespace # comment
1460
+ eg = ""
1461
+ element foo { empty }
1462
+ ]]></correct>
1463
+ </compact>
1464
+ <xml>
1465
+ <correct>
1466
+ <!-- comment -->
1467
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1468
+ <empty/>
1469
+ </element>
1470
+ </correct>
1471
+ </xml>
1472
+ </testCase>
1473
+ <testCase>
1474
+ <compact>
1475
+ <correct><![CDATA[
1476
+ [
1477
+ # comment
1478
+ ]
1479
+ element foo { empty }
1480
+ ]]></correct>
1481
+ </compact>
1482
+ <xml>
1483
+ <correct>
1484
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1485
+ <!-- comment -->
1486
+ <empty/>
1487
+ </element>
1488
+ </correct>
1489
+ </xml>
1490
+ </testCase>
1491
+ <testCase>
1492
+ <compact>
1493
+ <correct><![CDATA[
1494
+ namespace eg = "http://www.example.com"
1495
+ [
1496
+ # comment
1497
+ eg:foo = "stuff"
1498
+ ]
1499
+ element foo { empty }
1500
+ ]]></correct>
1501
+ </compact>
1502
+ <xml>
1503
+ <correct>
1504
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0"
1505
+ xmlns:eg="http://www.example.com" eg:foo="stuff">
1506
+ <!-- comment -->
1507
+ <empty/>
1508
+ </element>
1509
+ </correct>
1510
+ </xml>
1511
+ </testCase>
1512
+ <testCase>
1513
+ <compact>
1514
+ <correct><![CDATA[
1515
+ element foo # comment
1516
+ { empty }
1517
+ ]]></correct>
1518
+ </compact>
1519
+ <xml>
1520
+ <correct>
1521
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1522
+ <!-- comment -->
1523
+ <empty/>
1524
+ </element>
1525
+ </correct>
1526
+ </xml>
1527
+ </testCase>
1528
+ <testCase>
1529
+ <compact>
1530
+ <correct><![CDATA[
1531
+ start = grammar { start = parent # comment
1532
+ foo }
1533
+ foo = element foo { empty }
1534
+ ]]></correct>
1535
+ </compact>
1536
+ <xml>
1537
+ <correct>
1538
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
1539
+ <start>
1540
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
1541
+ <start>
1542
+ <parentRef name="foo">
1543
+ <!-- comment -->
1544
+ </parentRef>
1545
+ </start>
1546
+ </grammar>
1547
+ </start>
1548
+ <define name="foo">
1549
+ <element name="foo">
1550
+ <empty/>
1551
+ </element>
1552
+ </define>
1553
+ </grammar>
1554
+ </correct>
1555
+ </xml>
1556
+ </testCase>
1557
+ <testCase>
1558
+ <compact>
1559
+ <correct><![CDATA[
1560
+ # :--:---:-
1561
+ element foo { empty }
1562
+ ]]></correct>
1563
+ </compact>
1564
+ <xml>
1565
+ <correct>
1566
+ <!-- :- -:- - -:- -->
1567
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1568
+ <empty/>
1569
+ </element>
1570
+ </correct>
1571
+ </xml>
1572
+ </testCase>
1573
+ <bug>
1574
+ <compact>
1575
+ <incorrect><![CDATA[
1576
+ namespace x = ""
1577
+ namespace y = inherit
1578
+
1579
+ element x:* - y:z { empty }
1580
+ ]]></incorrect>
1581
+ </compact>
1582
+ </bug>
1583
+ <testCase>
1584
+ <compact>
1585
+ <correct><![CDATA[
1586
+ \xxxxx = element foo { empty }
1587
+ start = \xxxxx]]></correct>
1588
+ </compact>
1589
+ <xml>
1590
+ <correct>
1591
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
1592
+ <define name="xxxxx">
1593
+ <element name="foo">
1594
+ <empty/>
1595
+ </element>
1596
+ </define>
1597
+ <start>
1598
+ <ref name="xxxxx"/>
1599
+ </start>
1600
+ </grammar>
1601
+ </correct>
1602
+ </xml>
1603
+ </testCase>
1604
+ <testCase>
1605
+ <compact>
1606
+ <incorrect><![CDATA[
1607
+ element foo { "\x{D800}" }
1608
+ ]]></incorrect>
1609
+ </compact>
1610
+ </testCase>
1611
+ <testCase>
1612
+ <compact>
1613
+ <incorrect><![CDATA[
1614
+ element foo { "\x{110000}" }
1615
+ ]]></incorrect>
1616
+ </compact>
1617
+ </testCase>
1618
+ <testCase>
1619
+ <compact>
1620
+ <incorrect><![CDATA[
1621
+ element foo { empty \x{7d]]></incorrect>
1622
+ </compact>
1623
+ </testCase>
1624
+ <testCase>
1625
+ <compact>
1626
+ <incorrect><![CDATA[
1627
+ element foo { empty \x{7d }
1628
+ ]]></incorrect>
1629
+ </compact>
1630
+ </testCase>
1631
+ <testCase>
1632
+ <compact>
1633
+ <incorrect><![CDATA[
1634
+ element foo { "\x{}" }
1635
+ ]]></incorrect>
1636
+ </compact>
1637
+ </testCase>
1638
+ <testCase>
1639
+ <compact>
1640
+ <correct>
1641
+ \x{65}l\x{00065}ment\x{20}foo { empty \x{7d}
1642
+ </correct>
1643
+ </compact>
1644
+ <xml>
1645
+ <correct>
1646
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1647
+ <empty/>
1648
+ </element>
1649
+ </correct>
1650
+ </xml>
1651
+ </testCase>
1652
+ <testCase>
1653
+ <compact>
1654
+ <correct><![CDATA[
1655
+ element \x{66}oo { empty }
1656
+ ]]></correct>
1657
+ </compact>
1658
+ <xml>
1659
+ <correct>
1660
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1661
+ <empty/>
1662
+ </element>
1663
+ </correct>
1664
+ </xml>
1665
+ </testCase>
1666
+ <testCase>
1667
+ <compact>
1668
+ <correct><![CDATA[
1669
+ element \xx\x{66}oo { empty }
1670
+ ]]></correct>
1671
+ </compact>
1672
+ <xml>
1673
+ <correct>
1674
+ <element name="xxfoo" xmlns="http://relaxng.org/ns/structure/1.0">
1675
+ <empty/>
1676
+ </element>
1677
+ </correct>
1678
+ </xml>
1679
+ </testCase>
1680
+ <testCase>
1681
+ <compact>
1682
+ <correct>
1683
+ element foo { "\x{10300}" }
1684
+ </correct>
1685
+ </compact>
1686
+ <xml>
1687
+ <correct>
1688
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1689
+ <value>&#x10300;</value>
1690
+ </element>
1691
+ </correct>
1692
+ </xml>
1693
+ </testCase>
1694
+ <testCase>
1695
+ <compact>
1696
+ <correct>
1697
+ element foo { "&#x0e00;" }
1698
+ </correct>
1699
+ </compact>
1700
+ <xml>
1701
+ <correct>
1702
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1703
+ <value>&#x0e00;</value>
1704
+ </element>
1705
+ </correct>
1706
+ </xml>
1707
+ </testCase>
1708
+ <testCase>
1709
+ <compact>
1710
+ <correct>
1711
+ element foo { """z
1712
+ """ }
1713
+ </correct>
1714
+ </compact>
1715
+ <xml>
1716
+ <correct>
1717
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1718
+ <value>z&#xA;</value>
1719
+ </element>
1720
+ </correct>
1721
+ </xml>
1722
+ </testCase>
1723
+ <testCase>
1724
+ <compact>
1725
+ <correct>
1726
+ element foo { "z\x{A}" }
1727
+ </correct>
1728
+ </compact>
1729
+ <xml>
1730
+ <correct>
1731
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1732
+ <value>z&#xA;</value>
1733
+ </element>
1734
+ </correct>
1735
+ </xml>
1736
+ </testCase>
1737
+ <testCase>
1738
+ <compact>
1739
+ <correct>
1740
+ element foo { "z\x{D}" }
1741
+ </correct>
1742
+ </compact>
1743
+ <xml>
1744
+ <correct>
1745
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1746
+ <value>z&#xD;</value>
1747
+ </element>
1748
+ </correct>
1749
+ </xml>
1750
+ </testCase>
1751
+ <testCase>
1752
+ <compact>
1753
+ <correct>
1754
+ element foo { "z\x{D}\x{A}" }
1755
+ </correct>
1756
+ </compact>
1757
+ <xml>
1758
+ <correct>
1759
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1760
+ <value>z&#xD;&#xA;</value>
1761
+ </element>
1762
+ </correct>
1763
+ </xml>
1764
+ </testCase>
1765
+ <testCase>
1766
+ <compact>
1767
+ <correct><![CDATA[
1768
+ "'"~'"'
1769
+ ]]></correct>
1770
+ </compact>
1771
+ <xml>
1772
+ <correct>
1773
+ <value xmlns="http://relaxng.org/ns/structure/1.0">'"</value>
1774
+ </correct>
1775
+ </xml>
1776
+ </testCase>
1777
+ <testCase>
1778
+ <compact>
1779
+ <correct><![CDATA[
1780
+ namespace eg = "http://" ~ "www.example.com"
1781
+ token "xyzzy"
1782
+ ]]></correct>
1783
+ </compact>
1784
+ <xml>
1785
+ <correct>
1786
+ <value xmlns="http://relaxng.org/ns/structure/1.0">xyzzy</value>
1787
+ </correct>
1788
+ </xml>
1789
+ </testCase>
1790
+ <testCase>
1791
+ <compact>
1792
+ <correct><![CDATA[
1793
+ datatypes xsd = "http://www.w3.org/"~"2001"~"/"~""~"XMLSchema-datatypes"~""
1794
+ xsd:string { pattern = "foo"~"|"~"bar" }
1795
+ ]]></correct>
1796
+ </compact>
1797
+ <xml>
1798
+ <correct>
1799
+ <data type="string" xmlns="http://relaxng.org/ns/structure/1.0"
1800
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
1801
+ <param name="pattern">foo|bar</param>
1802
+ </data>
1803
+ </correct>
1804
+ </xml>
1805
+ </testCase>
1806
+ <testCase>
1807
+ <compact>
1808
+ <correct><![CDATA[
1809
+ ## This is a comment
1810
+ ## about a foo.
1811
+ element foo { empty }
1812
+ ]]></correct>
1813
+ </compact>
1814
+ <xml>
1815
+ <correct>
1816
+ <element name="foo" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
1817
+ <a:documentation>This is a comment
1818
+ about a foo.</a:documentation>
1819
+ <empty/>
1820
+ </element>
1821
+ </correct>
1822
+ </xml>
1823
+ </testCase>
1824
+ <testCase>
1825
+ <compact>
1826
+ <correct><![CDATA[
1827
+ #### This is a comment
1828
+ ######## about a foo.
1829
+ element foo { empty }
1830
+ ]]></correct>
1831
+ </compact>
1832
+ <xml>
1833
+ <correct>
1834
+ <element name="foo" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
1835
+ <a:documentation>This is a comment
1836
+ about a foo.</a:documentation>
1837
+ <empty/>
1838
+ </element>
1839
+ </correct>
1840
+ </xml>
1841
+ </testCase>
1842
+ <testCase>
1843
+ <compact>
1844
+ <correct><![CDATA[
1845
+ ## This is a formal comment
1846
+ ## about a foo.
1847
+ # Regular comment.
1848
+ element foo { empty }
1849
+ ]]></correct>
1850
+ </compact>
1851
+ <xml>
1852
+ <correct>
1853
+ <!-- Regular comment. -->
1854
+ <element name="foo" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
1855
+ <a:documentation>This is a formal comment
1856
+ about a foo.</a:documentation>
1857
+ <empty/>
1858
+ </element>
1859
+ </correct>
1860
+ </xml>
1861
+ </testCase>
1862
+ <testCase>
1863
+ <compact>
1864
+ <correct><![CDATA[
1865
+ ## This is a formal comment
1866
+ ## about a foo.
1867
+ start = element foo { empty }
1868
+ ]]></correct>
1869
+ </compact>
1870
+ <xml>
1871
+ <correct>
1872
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
1873
+ <start>
1874
+ <a:documentation>This is a formal comment
1875
+ about a foo.</a:documentation>
1876
+ <element name="foo">
1877
+ <empty/>
1878
+ </element>
1879
+ </start>
1880
+ </grammar>
1881
+ </correct>
1882
+ </xml>
1883
+ </testCase>
1884
+ <testCase>
1885
+ <compact>
1886
+ <correct><![CDATA[
1887
+ # This is a regular comment
1888
+ ## This is a formal comment
1889
+ element foo { empty }
1890
+ ]]></correct>
1891
+ </compact>
1892
+ <xml>
1893
+ <correct>
1894
+ <!-- This is a regular comment -->
1895
+ <element name="foo" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
1896
+ <a:documentation>This is a formal comment</a:documentation>
1897
+ <empty/>
1898
+ </element>
1899
+ </correct>
1900
+ </xml>
1901
+ </testCase>
1902
+ <testCase>
1903
+ <compact>
1904
+ <correct><![CDATA[element foo { empty }
1905
+ #]]></correct>
1906
+ </compact>
1907
+ <xml>
1908
+ <correct>
1909
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
1910
+ <empty/>
1911
+ </element>
1912
+ <!---->
1913
+ </correct>
1914
+ </xml>
1915
+ </testCase>
1916
+ <testCase>
1917
+ <compact>
1918
+ <incorrect><![CDATA[
1919
+ element * - * { empty }
1920
+ ]]></incorrect>
1921
+ </compact>
1922
+ </testCase>
1923
+ <testCase>
1924
+ <compact>
1925
+ <incorrect><![CDATA[
1926
+ element * - (*) { empty }
1927
+ ]]></incorrect>
1928
+ </compact>
1929
+ </testCase>
1930
+ <testCase>
1931
+ <compact>
1932
+ <incorrect><![CDATA[
1933
+ namespace eg = "http://www.example.com"
1934
+ element eg:* - * { empty }
1935
+ ]]></incorrect>
1936
+ </compact>
1937
+ </testCase>
1938
+ <testCase>
1939
+ <compact>
1940
+ <incorrect><![CDATA[
1941
+ namespace eg = "http://www.example.com"
1942
+ element eg:* - (*) { empty }
1943
+ ]]></incorrect>
1944
+ </compact>
1945
+ </testCase>
1946
+ <testCase>
1947
+ <compact>
1948
+ <incorrect><![CDATA[
1949
+ namespace eg = "http://www.example.com"
1950
+ element eg:* - eg:* { empty }
1951
+ ]]></incorrect>
1952
+ </compact>
1953
+ </testCase>
1954
+ <testCase>
1955
+ <compact>
1956
+ <incorrect><![CDATA[
1957
+ namespace eg = "http://www.example.com"
1958
+ element eg:* - (eg:*) { empty }
1959
+ ]]></incorrect>
1960
+ </compact>
1961
+ </testCase>
1962
+ <testCase>
1963
+ <compact>
1964
+ <incorrect><![CDATA[
1965
+ namespace eg1 = "http://www.example.com/1"
1966
+ namespace eg2 = "http://www.example.com/2"
1967
+ element eg1:* - eg2:* { empty }
1968
+ ]]></incorrect>
1969
+ </compact>
1970
+ </testCase>
1971
+ <testCase>
1972
+ <compact>
1973
+ <correct>foo</correct>
1974
+ </compact>
1975
+ <xml>
1976
+ <correct>
1977
+ <ref name="foo" xmlns="http://relaxng.org/ns/structure/1.0"/>
1978
+ </correct>
1979
+ </xml>
1980
+ </testCase>
1981
+ <testCase>
1982
+ <compact>
1983
+ <resource name="x.rnc">
1984
+ start = element foo { empty }
1985
+ </resource>
1986
+ <correct><![CDATA[
1987
+ include "x.rnc"
1988
+ ]]></correct>
1989
+ </compact>
1990
+ <xml>
1991
+ <resource name="x.rng">
1992
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
1993
+ <start>
1994
+ <element name="foo"><empty/></element>
1995
+ </start>
1996
+ </grammar>
1997
+ </resource>
1998
+ <correct>
1999
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2000
+ <include href="x.rng"/>
2001
+ </grammar>
2002
+ </correct>
2003
+ </xml>
2004
+ </testCase>
2005
+ <testCase>
2006
+ <compact>
2007
+ <correct><![CDATA[
2008
+ div { start = element foo { empty } }
2009
+ ]]></correct>
2010
+ </compact>
2011
+ <xml>
2012
+ <correct>
2013
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2014
+ <div>
2015
+ <start>
2016
+ <element name="foo">
2017
+ <empty/>
2018
+ </element>
2019
+ </start>
2020
+ </div>
2021
+ </grammar>
2022
+ </correct>
2023
+ </xml>
2024
+ </testCase>
2025
+ <testCase>
2026
+ <compact>
2027
+ <correct><![CDATA[
2028
+ [xml:lang="jp"] div { start = element foo { empty } }
2029
+ ]]></correct>
2030
+ </compact>
2031
+ <xml>
2032
+ <correct>
2033
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2034
+ <div xml:lang="jp">
2035
+ <start>
2036
+ <element name="foo">
2037
+ <empty/>
2038
+ </element>
2039
+ </start>
2040
+ </div>
2041
+ </grammar>
2042
+ </correct>
2043
+ </xml>
2044
+ </testCase>
2045
+ <testCase>
2046
+ <compact>
2047
+ <correct><![CDATA[
2048
+ x |= element foo { empty }
2049
+ ]]></correct>
2050
+ </compact>
2051
+ <xml>
2052
+ <correct>
2053
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2054
+ <define name="x" combine="choice">
2055
+ <element name="foo"><empty/></element>
2056
+ </define>
2057
+ </grammar>
2058
+ </correct>
2059
+ </xml>
2060
+ </testCase>
2061
+ <testCase>
2062
+ <compact>
2063
+ <correct><![CDATA[
2064
+ namespace eg = "http://www.example.com"
2065
+
2066
+ [eg:foo [ "x" "y" ~ "z" "z" "y" ]]
2067
+ element foo { empty }
2068
+ ]]></correct>
2069
+ </compact>
2070
+ <xml>
2071
+ <correct>
2072
+ <element name="foo" xmlns:eg="http://www.example.com" xmlns="http://relaxng.org/ns/structure/1.0">
2073
+ <eg:foo>xyzzy</eg:foo>
2074
+ <empty/>
2075
+ </element>
2076
+ </correct>
2077
+ </xml>
2078
+ </testCase>
2079
+ <testCase>
2080
+ <compact>
2081
+ <correct><![CDATA[
2082
+ namespace eg = "http://www.example.com"
2083
+
2084
+ [eg:foo [ "x" "y" ~ "z" "z" "y" ]]
2085
+ start = element foo { empty }
2086
+ ]]></correct>
2087
+ </compact>
2088
+ <xml>
2089
+ <correct>
2090
+ <grammar xmlns:eg="http://www.example.com" xmlns="http://relaxng.org/ns/structure/1.0">
2091
+ <start>
2092
+ <eg:foo>xyzzy</eg:foo>
2093
+ <element name="foo">
2094
+ <empty/>
2095
+ </element>
2096
+ </start>
2097
+ </grammar>
2098
+ </correct>
2099
+ </xml>
2100
+ </testCase>
2101
+ <testCase>
2102
+ <compact>
2103
+ <correct><![CDATA[
2104
+ """"'""" ~ '''x''""y'''
2105
+ ]]></correct>
2106
+ </compact>
2107
+ <xml>
2108
+ <correct>
2109
+ <value xmlns="http://relaxng.org/ns/structure/1.0">"'x''""y</value>
2110
+ </correct>
2111
+ </xml>
2112
+ </testCase>
2113
+ <testCase>
2114
+ <compact>
2115
+ <incorrect><![CDATA[
2116
+ element foo { "x
2117
+ y" }
2118
+ ]]></incorrect>
2119
+ </compact>
2120
+ </testCase>
2121
+ <testCase>
2122
+ <compact>
2123
+ <incorrect><![CDATA[
2124
+ element \x{D}foo { empty }
2125
+ ]]></incorrect>
2126
+ </compact>
2127
+ </testCase>
2128
+ <testCase>
2129
+ <compact>
2130
+ <incorrect><![CDATA[
2131
+ namespace rng = "http://relaxng.org/ns/structure/1.0"
2132
+ [rng:foo = "val"]
2133
+ element foo { empty }
2134
+ ]]></incorrect>
2135
+ </compact>
2136
+ </testCase>
2137
+ <testCase>
2138
+ <compact>
2139
+ <incorrect><![CDATA[
2140
+ namespace rng = "http://relaxng.org/ns/structure/1.0"
2141
+ [rng:foo [ "val" ]]
2142
+ element foo { empty }
2143
+ ]]></incorrect>
2144
+ </compact>
2145
+ </testCase>
2146
+ <testCase>
2147
+ <compact>
2148
+ <correct><![CDATA[
2149
+ namespace rng = "http://relaxng.org/ns/structure/1.0"
2150
+ [foo [ rng:foo [ "val" ] ]]
2151
+ element foo { empty }
2152
+ ]]></correct>
2153
+ </compact>
2154
+ <xml>
2155
+ <correct>
2156
+ <element name="foo" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
2157
+ <foo xmlns="">
2158
+ <rng:foo>val</rng:foo>
2159
+ </foo>
2160
+ <empty/>
2161
+ </element>
2162
+ </correct>
2163
+ </xml>
2164
+ </testCase>
2165
+ <testCase>
2166
+ <compact>
2167
+ <correct><![CDATA[
2168
+ namespace rng = "http://relaxng.org/ns/structure/1.0"
2169
+ [foo [ rng:foo = "val" ]]
2170
+ element foo { empty }
2171
+ ]]></correct>
2172
+ </compact>
2173
+ <xml>
2174
+ <correct>
2175
+ <element name="foo" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
2176
+ <foo xmlns="" rng:foo="val"/>
2177
+ <empty/>
2178
+ </element>
2179
+ </correct>
2180
+ </xml>
2181
+ </testCase>
2182
+ <testCase>
2183
+ <compact>
2184
+ <correct><![CDATA[
2185
+ div {
2186
+ foo []
2187
+ foo = element foo { empty }
2188
+ }
2189
+ ]]></correct>
2190
+ </compact>
2191
+ <xml>
2192
+ <correct>
2193
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2194
+ <div>
2195
+ <foo xmlns=""/>
2196
+ <define name="foo">
2197
+ <element name="foo">
2198
+ <empty/>
2199
+ </element>
2200
+ </define>
2201
+ </div>
2202
+ </grammar>
2203
+ </correct>
2204
+ </xml>
2205
+ </testCase>
2206
+ <testCase>
2207
+ <compact>
2208
+ <resource name="x.rnc">
2209
+ foo = empty
2210
+ </resource>
2211
+ <correct><![CDATA[
2212
+ include "x.rnc" {
2213
+ foo []
2214
+ div {
2215
+ bar []
2216
+ foo = element foo { empty }
2217
+ }
2218
+ }
2219
+ ]]></correct>
2220
+ </compact>
2221
+ <xml>
2222
+ <correct>
2223
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2224
+ <include href="x.rng">
2225
+ <foo xmlns=""/>
2226
+ <div>
2227
+ <bar xmlns=""/>
2228
+ <define name="foo">
2229
+ <element name="foo">
2230
+ <empty/>
2231
+ </element>
2232
+ </define>
2233
+ </div>
2234
+ </include>
2235
+ </grammar>
2236
+ </correct>
2237
+ </xml>
2238
+ </testCase>
2239
+ <testCase>
2240
+ <compact>
2241
+ <correct><![CDATA[
2242
+ element foo { [x[]](text*) }
2243
+ ]]></correct>
2244
+ </compact>
2245
+ <xml>
2246
+ <correct>
2247
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
2248
+ <zeroOrMore>
2249
+ <x xmlns=""/>
2250
+ <text/>
2251
+ </zeroOrMore>
2252
+ </element>
2253
+ </correct>
2254
+ </xml>
2255
+ </testCase>
2256
+ <testCase>
2257
+ <compact>
2258
+ <correct><![CDATA[
2259
+ element foo {
2260
+ string - ((string|string) >> x[]) >> y[]
2261
+ }
2262
+ ]]></correct>
2263
+ </compact>
2264
+ <xml>
2265
+ <correct>
2266
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
2267
+ <data type="string">
2268
+ <except>
2269
+ <choice>
2270
+ <data type="string"/>
2271
+ <data type="string"/>
2272
+ </choice>
2273
+ <x xmlns=""/>
2274
+ </except>
2275
+ </data>
2276
+ <y xmlns=""/>
2277
+ </element>
2278
+ </correct>
2279
+ </xml>
2280
+ </testCase>
2281
+ <testCase>
2282
+ <compact>
2283
+ <correct><![CDATA[
2284
+ element foo {
2285
+ string - ("x" >> x[]) >> y[]
2286
+ }
2287
+ ]]></correct>
2288
+ </compact>
2289
+ <xml>
2290
+ <correct>
2291
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
2292
+ <data type="string">
2293
+ <except>
2294
+ <value>x</value>
2295
+ <x xmlns=""/>
2296
+ </except>
2297
+ </data>
2298
+ <y xmlns=""/>
2299
+ </element>
2300
+ </correct>
2301
+ </xml>
2302
+ </testCase>
2303
+ <testCase>
2304
+ <compact>
2305
+ <incorrect><![CDATA[
2306
+ element foo { empty } >> x[]
2307
+ ]]></incorrect>
2308
+ </compact>
2309
+ </testCase>
2310
+ <testCase>
2311
+ <compact>
2312
+ <incorrect><![CDATA[
2313
+ [x[]]
2314
+ "value"
2315
+ ]]></incorrect>
2316
+ </compact>
2317
+ </testCase>
2318
+ <testCase>
2319
+ <compact>
2320
+ <incorrect><![CDATA[
2321
+ [x[]]
2322
+ token "value"
2323
+ ]]></incorrect>
2324
+ </compact>
2325
+ </testCase>
2326
+ <testCase>
2327
+ <compact>
2328
+ <correct><![CDATA[
2329
+ [ x [
2330
+ "1"
2331
+ #2
2332
+ "3" ]]
2333
+ element foo { empty }
2334
+ ]]></correct>
2335
+ </compact>
2336
+ <xml>
2337
+ <correct>
2338
+ <element name="foo" xmlns="http://relaxng.org/ns/structure/1.0">
2339
+ <x xmlns="">1<!-- 2 -->3</x>
2340
+ <empty/>
2341
+ </element>
2342
+ </correct>
2343
+ </xml>
2344
+ </testCase>
2345
+ <testCase>
2346
+ <compact>
2347
+ <correct><![CDATA[
2348
+ xsd:string { maxLength = # short
2349
+ "2" }
2350
+ ]]></correct>
2351
+ </compact>
2352
+ <xml>
2353
+ <correct>
2354
+ <data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://relaxng.org/ns/structure/1.0">
2355
+ <!-- short -->
2356
+ <param name="maxLength">2</param>
2357
+ </data>
2358
+ </correct>
2359
+ </xml>
2360
+ </testCase>
2361
+ <testCase>
2362
+ <compact>
2363
+ <correct><![CDATA[
2364
+ element # hello
2365
+ foo { empty }
2366
+ ]]></correct>
2367
+ </compact>
2368
+ <xml>
2369
+ <correct>
2370
+ <element xmlns="http://relaxng.org/ns/structure/1.0">
2371
+ <!-- hello -->
2372
+ <name>foo</name>
2373
+ <empty/>
2374
+ </element>
2375
+ </correct>
2376
+ </xml>
2377
+ </testCase>
2378
+ <testCase>
2379
+ <compact>
2380
+ <incorrect><![CDATA[namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
2381
+ namespace xsd = "http://www.w3.org/2001/XMLSchema-instance"
2382
+
2383
+ creator =
2384
+ element creator {
2385
+ (attribute scheme { xsd:QName "p:A" },
2386
+ ("a" | "b" | "c"))
2387
+ | (attribute scheme { xsd:QName "p:B" },
2388
+ ("d" | "e" | "f"))
2389
+ }
2390
+ start = creator
2391
+ ]]></incorrect>
2392
+ </compact>
2393
+ </testCase>
2394
+ <testCase>
2395
+ <compact>
2396
+ <correct><![CDATA[namespace rng = "http://relaxng.org/ns/structure/1.0"
2397
+
2398
+ start = element rng:test { nonXMLForeignAttribute+ }
2399
+ nonXMLForeignAttribute = attribute * - xml:* { text }
2400
+ xmlAttribute =
2401
+ attribute xml:lang { text }
2402
+ | attribute xml:space { "default" | "preserve" }
2403
+ | attribute xml:base { xsd:anyURI }
2404
+ ]]></correct>
2405
+ </compact>
2406
+ <xml>
2407
+ <correct>
2408
+ <grammar ns="http://www.w3.org/XML/1998/namespace"
2409
+ xmlns:rng="http://relaxng.org/ns/structure/1.0"
2410
+ xmlns="http://relaxng.org/ns/structure/1.0"
2411
+ datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2412
+ <start>
2413
+ <element name="rng:test">
2414
+ <oneOrMore>
2415
+ <ref name="nonXMLForeignAttribute"/>
2416
+ </oneOrMore>
2417
+ </element>
2418
+ </start>
2419
+ <define name="nonXMLForeignAttribute">
2420
+ <attribute>
2421
+ <anyName>
2422
+ <except>
2423
+ <nsName/>
2424
+ </except>
2425
+ </anyName>
2426
+ </attribute>
2427
+ </define>
2428
+ <define name="xmlAttribute">
2429
+ <choice>
2430
+ <attribute name="xml:lang"/>
2431
+ <attribute name="xml:space">
2432
+ <choice>
2433
+ <value>default</value>
2434
+ <value>preserve</value>
2435
+ </choice>
2436
+ </attribute>
2437
+ <attribute name="xml:base">
2438
+ <data type="anyURI"/>
2439
+ </attribute>
2440
+ </choice>
2441
+ </define>
2442
+ </grammar>
2443
+ </correct>
2444
+ </xml>
2445
+ </testCase>
2446
+ <testCase>
2447
+ <compact>
2448
+ <correct>
2449
+ start = element foo {
2450
+ grammar {
2451
+ start = element bar { text }, element doh {text}
2452
+ }
2453
+ }
2454
+ </correct>
2455
+ </compact>
2456
+ <xml>
2457
+ <correct>
2458
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2459
+ <start>
2460
+ <element name="foo">
2461
+ <grammar>
2462
+ <start>
2463
+ <group>
2464
+ <element name="bar">
2465
+ <text/>
2466
+ </element>
2467
+ <element name="doh">
2468
+ <text/>
2469
+ </element>
2470
+ </group>
2471
+ </start>
2472
+ </grammar>
2473
+ </element>
2474
+ </start>
2475
+ </grammar>
2476
+
2477
+ </correct>
2478
+ </xml>
2479
+ </testCase>
2480
+ <!--
2481
+ <testCase>
2482
+ <compact>
2483
+ <incorrect><![CDATA[
2484
+ namespace local = ""
2485
+ foo [ local:xmlns = "bar" ]
2486
+ start = element foo { empty }
2487
+ ]]></incorrect>
2488
+ </compact>
2489
+ </testCase>
2490
+ -->
2491
+ <!--
2492
+ <testCase>
2493
+ <compact>
2494
+ <correct><![CDATA[
2495
+ ]]></correct>
2496
+ </compact>
2497
+ <xml>
2498
+ <correct>
2499
+ </correct>
2500
+ </xml>
2501
+ </testCase>
2502
+ -->
2503
+ <!--
2504
+ <testCase>
2505
+ <compact>
2506
+ <incorrect><![CDATA[
2507
+ ]]></incorrect>
2508
+ </compact>
2509
+ </testCase>
2510
+ -->
2511
+ </testSuite>