Compact syntax parsing fixes
[cxml-rng.git] / rng.rng
blobcd0f537b16f37c14d7640739fdd942ddc1677f66
1 <grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
2          ns="http://relaxng.org/ns/structure/1.0"
3          xmlns="http://relaxng.org/ns/structure/1.0">
5   <start>
6     <ref name="pattern"/>
7   </start>
9   <define name="pattern">
10     <choice>
11       <element name="element">
12         <choice>
13           <attribute name="name">
14             <data type="QName"/>
15           </attribute>
16           <ref name="open-name-class"/>
17         </choice>
18         <ref name="common-atts"/>
19         <ref name="open-patterns"/>
20       </element>
21       <element name="attribute">
22         <ref name="common-atts"/>
23         <choice>
24           <attribute name="name">
25             <data type="QName"/>
26           </attribute>
27           <ref name="open-name-class"/>
28         </choice>
29         <interleave>
30           <ref name="other"/>
31           <optional>
32             <ref name="pattern"/>
33           </optional>
34         </interleave>
35       </element>
36       <element name="group">
37         <ref name="common-atts"/>
38         <ref name="open-patterns"/>
39       </element>
40       <element name="interleave">
41         <ref name="common-atts"/>
42         <ref name="open-patterns"/>
43       </element>
44       <element name="choice">
45         <ref name="common-atts"/>
46         <ref name="open-patterns"/>
47       </element>
48       <element name="optional">
49         <ref name="common-atts"/>
50         <ref name="open-patterns"/>
51       </element>
52       <element name="zeroOrMore">
53         <ref name="common-atts"/>
54         <ref name="open-patterns"/>
55       </element>
56       <element name="oneOrMore">
57         <ref name="common-atts"/>
58         <ref name="open-patterns"/>
59       </element>
60       <element name="list">
61         <ref name="common-atts"/>
62         <ref name="open-patterns"/>
63       </element>
64       <element name="mixed">
65         <ref name="common-atts"/>
66         <ref name="open-patterns"/>
67       </element>
68       <element name="ref">
69         <attribute name="name">
70           <data type="NCName"/>
71         </attribute>
72         <ref name="common-atts"/>
73         <ref name="other"/>
74       </element>
75       <element name="parentRef">
76         <attribute name="name">
77           <data type="NCName"/>
78         </attribute>
79         <ref name="common-atts"/>
80         <ref name="other"/>
81       </element>
82       <element name="empty">
83         <ref name="common-atts"/>
84         <ref name="other"/>
85       </element>
86       <element name="text">
87         <ref name="common-atts"/>
88         <ref name="other"/>
89       </element>
90       <element name="value">
91         <optional>
92           <attribute name="type">
93             <data type="NCName"/>
94           </attribute>
95         </optional>
96         <ref name="common-atts"/>
97         <text/>
98       </element>
99       <element name="data">
100         <attribute name="type">
101           <data type="NCName"/>
102         </attribute>
103         <ref name="common-atts"/>
104         <interleave>
105           <ref name="other"/>
106           <group>
107             <zeroOrMore>
108               <element name="param">
109                 <attribute name="name">
110                   <data type="NCName"/>
111                 </attribute>
112                 <ref name="common-atts"/>
113                 <text/>
114               </element>
115             </zeroOrMore>
116             <optional>
117               <element name="except">
118                 <ref name="common-atts"/>
119                 <ref name="open-patterns"/>
120               </element>
121             </optional>
122           </group>
123         </interleave>
124       </element>
125       <element name="notAllowed">
126         <ref name="common-atts"/>
127         <ref name="other"/>
128       </element>
129       <element name="externalRef">
130         <attribute name="href">
131           <data type="anyURI"/>
132         </attribute>
133         <ref name="common-atts"/>
134         <ref name="other"/>
135       </element>
136       <element name="grammar">
137         <ref name="common-atts"/>
138         <ref name="grammar-content"/>
139       </element>
140     </choice>
141   </define>
143   <define name="grammar-content">
144     <interleave>
145       <ref name="other"/>
146       <zeroOrMore>
147         <choice>
148           <ref name="start-element"/>
149           <ref name="define-element"/>
150           <element name="div">
151             <ref name="common-atts"/>
152             <ref name="grammar-content"/>
153           </element>
154           <element name="include">
155             <attribute name="href">
156               <data type="anyURI"/>
157             </attribute>
158             <ref name="common-atts"/>
159             <ref name="include-content"/>
160           </element>
161         </choice>
162       </zeroOrMore>
163     </interleave>
164   </define>
166   <define name="include-content">
167     <interleave>
168       <ref name="other"/>
169       <zeroOrMore>
170         <choice>
171           <ref name="start-element"/>
172           <ref name="define-element"/>
173           <element name="div">
174             <ref name="common-atts"/>
175             <ref name="include-content"/>
176           </element>
177         </choice>
178       </zeroOrMore>
179     </interleave>
180   </define>
182   <define name="start-element">
183     <element name="start">
184       <ref name="combine-att"/>
185       <ref name="common-atts"/>
186       <ref name="open-pattern"/>
187     </element>
188   </define>
190   <define name="define-element">
191     <element name="define">
192       <attribute name="name">
193         <data type="NCName"/>
194       </attribute>
195       <ref name="combine-att"/>
196       <ref name="common-atts"/>
197       <ref name="open-patterns"/>
198     </element>
199   </define>
201   <define name="combine-att">
202     <optional>
203       <attribute name="combine">
204         <choice>
205           <value>choice</value>
206           <value>interleave</value>
207         </choice>
208       </attribute>
209     </optional>
210   </define>
212   <define name="open-patterns">
213     <interleave>
214       <ref name="other"/>
215       <oneOrMore>
216         <ref name="pattern"/>
217       </oneOrMore>
218     </interleave>
219   </define>
221   <define name="open-pattern">
222     <interleave>
223       <ref name="other"/>
224       <ref name="pattern"/>
225     </interleave>
226   </define>
228   <define name="name-class">
229     <choice>
230       <element name="name">
231         <ref name="common-atts"/>
232         <data type="QName"/>
233       </element>
234       <element name="anyName">
235         <ref name="common-atts"/>
236         <ref name="except-name-class"/>
237       </element>
238       <element name="nsName">
239         <ref name="common-atts"/>
240         <ref name="except-name-class"/>
241       </element>
242       <element name="choice">
243         <ref name="common-atts"/>
244         <ref name="open-name-classes"/>
245       </element>
246     </choice>
247   </define>
249   <define name="except-name-class">
250     <interleave>
251       <ref name="other"/>
252       <optional>
253         <element name="except">
254           <ref name="open-name-classes"/>
255         </element>
256       </optional>
257     </interleave>
258   </define>
260   <define name="open-name-classes">
261     <interleave>
262       <ref name="other"/>
263       <oneOrMore>
264         <ref name="name-class"/>
265       </oneOrMore>
266     </interleave>
267   </define>
269   <define name="open-name-class">
270     <interleave>
271       <ref name="other"/>
272       <ref name="name-class"/>
273     </interleave>
274   </define>
276   <define name="common-atts">
277     <optional>
278       <attribute name="ns"/>
279     </optional>
280     <optional>
281       <attribute name="datatypeLibrary">
282         <data type="anyURI"/>
283       </attribute>
284     </optional>
285     <zeroOrMore>
286       <attribute>
287         <anyName>
288           <except>
289             <nsName/>
290             <nsName ns=""/>
291           </except>
292         </anyName>
293       </attribute>
294     </zeroOrMore>
295   </define>
297   <define name="other">
298     <zeroOrMore>
299       <element>
300         <anyName>
301           <except>
302             <nsName/>
303           </except>
304         </anyName>
305         <zeroOrMore>
306           <choice>
307             <attribute>
308               <anyName/>
309             </attribute>
310             <text/>
311             <ref name="any"/>
312           </choice>
313         </zeroOrMore>
314       </element>
315     </zeroOrMore>
316   </define>
318   <define name="any">
319     <element>
320       <anyName/>
321       <zeroOrMore>
322         <choice>
323           <attribute>
324             <anyName/>
325           </attribute>
326           <text/>
327           <ref name="any"/>
328         </choice>
329       </zeroOrMore>
330     </element>
331   </define>
333 </grammar>