]> code.delx.au - gnu-emacs-elpa/blob - web-forms.rnc
Sync up with latest ARIA-in-HTML spec changes
[gnu-emacs-elpa] / web-forms.rnc
1 datatypes w = "http://whattf.org/datatype-draft"
2
3 # #####################################################################
4 ## RELAX NG Schema for HTML 5: Web Forms 1.0 markup #
5 # #####################################################################
6
7 ## Shared attributes for form controls
8
9 common-form.attrs =
10 ( common-form.attrs.name?
11 & common-form.attrs.disabled?
12 )
13
14 common-form.attrs.name =
15 attribute name {
16 form.data.nonemptystring
17 }
18
19 common-form.attrs.disabled =
20 attribute disabled {
21 w:string "disabled" | w:string ""
22 }
23
24 shared-form.attrs.readonly =
25 attribute readonly {
26 w:string "readonly" | w:string ""
27 }
28
29 shared-form.attrs.maxlength =
30 attribute maxlength {
31 common.data.integer.non-negative
32 }
33
34 shared-form.attrs.size =
35 attribute size {
36 common.data.integer.positive
37 }
38
39 # REVISIT tabindex goes in common.attrs
40
41 ## Shared attributes for <input>
42
43 input.attrs.checked =
44 attribute checked {
45 w:string "checked" | w:string ""
46 }
47
48 ## Text Field: <input type='text'>
49
50 input.text.elem =
51 element input { input.text.attrs }
52 input.text.attrs =
53 ( common.attrs
54 & common-form.attrs
55 & input.text.attrs.type?
56 & shared-form.attrs.maxlength?
57 & shared-form.attrs.readonly?
58 & shared-form.attrs.size?
59 & input.text.attrs.value?
60 & ( common.attrs.aria.implicit.textbox
61 | common.attrs.aria.implicit.combobox
62 | common.attrs.aria.role.textbox
63 | common.attrs.aria.role.combobox
64 )?
65 )
66 input.text.attrs.type =
67 attribute type {
68 w:string "text"
69 }
70 input.text.attrs.value =
71 attribute value {
72 form.data.stringwithoutlinebreaks
73 }
74
75 input.elem = input.text.elem
76
77 ## Password Field: <input type='password'>
78
79 input.password.elem =
80 element input { input.password.attrs }
81 input.password.attrs =
82 ( common.attrs
83 & common-form.attrs
84 & input.password.attrs.type
85 & shared-form.attrs.maxlength?
86 & shared-form.attrs.readonly?
87 & shared-form.attrs.size?
88 & input.password.attrs.value?
89 & ( common.attrs.aria.implicit.textbox
90 | common.attrs.aria.role.textbox
91 )?
92 )
93 input.password.attrs.type =
94 attribute type {
95 w:string "password"
96 }
97 input.password.attrs.value =
98 attribute value {
99 form.data.stringwithoutlinebreaks
100 }
101
102 input.elem |= input.password.elem
103
104 ## Checkbox: <input type='checkbox'>
105
106 input.checkbox.elem =
107 element input { input.checkbox.attrs }
108 input.checkbox.attrs =
109 ( common.attrs
110 & common-form.attrs
111 & input.checkbox.attrs.type
112 & input.attrs.checked?
113 & input.checkbox.attrs.value?
114 & ( common.attrs.aria.implicit.checkbox
115 | common.attrs.aria.role.checkbox
116 | common.attrs.aria.role.menuitemcheckbox
117 )?
118 )
119 input.checkbox.attrs.type =
120 attribute type {
121 w:string "checkbox"
122 }
123 input.checkbox.attrs.value =
124 attribute value {
125 string #REVISIT require non-empty value?
126 }
127
128 input.elem |= input.checkbox.elem
129
130 ## Radiobutton: <input type='radio'>
131
132 input.radio.elem =
133 element input { input.radio.attrs }
134 input.radio.attrs =
135 ( common.attrs
136 & common-form.attrs
137 & input.radio.attrs.type
138 & input.attrs.checked?
139 & input.radio.attrs.value?
140 & ( common.attrs.aria.implicit.radio
141 | common.attrs.aria.role.radio
142 | common.attrs.aria.role.menuitemradio
143 )?
144 )
145 input.radio.attrs.type =
146 attribute type {
147 w:string "radio"
148 }
149 input.radio.attrs.value =
150 attribute value {
151 string #REVISIT require non-empty value?
152 }
153
154 input.elem |= input.radio.elem
155
156 ## Scripting Hook Button: <input type='button'>
157
158 input.button.elem =
159 element input { input.button.attrs }
160 input.button.attrs =
161 ( common.attrs
162 & common-form.attrs
163 & input.button.attrs.type
164 & input.button.attrs.value?
165 & ( common.attrs.aria.implicit.button
166 | common.attrs.aria.role.button
167 | common.attrs.aria.role.link
168 | common.attrs.aria.role.menuitem
169 | common.attrs.aria.role.menuitemcheckbox
170 | common.attrs.aria.role.menuitemradio
171 | common.attrs.aria.role.radio
172 )?
173 )
174 input.button.attrs.type =
175 attribute type {
176 w:string "button"
177 }
178 input.button.attrs.value =
179 attribute value {
180 string #REVISIT require non-empty value?
181 }
182
183 input.elem |= input.button.elem
184 #REVISIT should this be enabled by a scripting module only?
185
186 ## Submit Button: <input type='submit'>
187
188 input.submit.elem =
189 element input { input.submit.attrs }
190 input.submit.attrs =
191 ( common.attrs
192 & common-form.attrs
193 & input.submit.attrs.type
194 & input.submit.attrs.value?
195 & ( common.attrs.aria.implicit.button
196 | common.attrs.aria.role.button
197 )?
198 )
199 input.submit.attrs.type =
200 attribute type {
201 w:string "submit"
202 }
203 input.submit.attrs.value =
204 attribute value {
205 string #REVISIT require non-empty value?
206 }
207
208 input.elem |= input.submit.elem
209
210 ## Reset Button: <input type='reset'>
211
212 input.reset.elem =
213 element input { input.reset.attrs }
214 input.reset.attrs =
215 ( common.attrs
216 & common-form.attrs
217 & input.reset.attrs.type
218 & input.reset.attrs.value?
219 & ( common.attrs.aria.implicit.button
220 | common.attrs.aria.role.button
221 )?
222 )
223 input.reset.attrs.type =
224 attribute type {
225 w:string "reset"
226 }
227 input.reset.attrs.value =
228 attribute value {
229 string #REVISIT require non-empty value?
230 }
231
232 input.elem |= input.reset.elem
233 # REVISIT does reset make sense outside a form?
234
235 ## File Upload: <input type='file'>
236
237 input.file.elem =
238 element input { input.file.attrs }
239 input.file.attrs =
240 ( common.attrs
241 & common-form.attrs
242 & input.file.attrs.type
243 & input.file.attrs.accept?
244 & common.attrs.aria?
245 )
246 input.file.attrs.type =
247 attribute type {
248 w:string "file"
249 }
250 input.file.attrs.accept =
251 attribute accept {
252 form.data.mimetypelist
253 }
254
255 input.elem |= input.file.elem
256
257 ## Hidden String: <input type='hidden'>
258
259 input.hidden.elem =
260 element input { input.hidden.attrs }
261 input.hidden.attrs =
262 ( common.attrs
263 & common-form.attrs
264 & input.hidden.attrs.type
265 & input.hidden.attrs.value?
266 & common.attrs.aria?
267 )
268 input.hidden.attrs.type =
269 attribute type {
270 w:string "hidden"
271 }
272 input.hidden.attrs.value =
273 attribute value {
274 string
275 }
276
277 input.elem |= input.hidden.elem
278
279 ## Image Submit Button: <input type='image'>
280
281 input.image.elem =
282 element input { input.image.attrs }
283 input.image.attrs =
284 ( common.attrs
285 & common-form.attrs
286 & input.image.attrs.type
287 & input.image.attrs.alt
288 & input.image.attrs.src?
289 & ( common.attrs.aria.implicit.button
290 | common.attrs.aria.role.button
291 | common.attrs.aria.role.link
292 | common.attrs.aria.role.menuitem
293 | common.attrs.aria.role.menuitemcheckbox
294 | common.attrs.aria.role.menuitemradio
295 | common.attrs.aria.role.radio
296 )?
297 )
298 input.image.attrs.type =
299 attribute type {
300 w:string "image"
301 }
302 input.image.attrs.alt =
303 attribute alt {
304 form.data.nonemptystring
305 }
306 input.image.attrs.src =
307 attribute src {
308 common.data.uri.non-empty
309 }
310
311 input.elem |= input.image.elem
312
313 common.elem.phrasing |= input.elem
314
315 ## Text Area: <textarea>
316
317 textarea.elem =
318 element textarea { textarea.inner & textarea.attrs }
319 textarea.attrs =
320 ( common.attrs
321 & common-form.attrs
322 & shared-form.attrs.readonly?
323 & textarea.attrs.rows-and-cols-wf1
324 & ( common.attrs.aria.implicit.textbox
325 | common.attrs.aria.role.textbox
326 )?
327 #FIXME onfocus, onblur, onselect,onchange
328 )
329 # This is ugly.
330 textarea.attrs.rows-and-cols-wf1 =
331 textarea.attrs.rows-and-cols-wf1.inner
332 textarea.attrs.rows-and-cols-wf1.inner =
333 ( textarea.attrs.cols
334 & textarea.attrs.rows
335 )
336 textarea.attrs.cols =
337 attribute cols {
338 common.data.integer.positive
339 }
340 textarea.attrs.rows =
341 attribute rows {
342 common.data.integer.positive
343 }
344 textarea.inner =
345 ( text )
346
347 common.elem.phrasing |= textarea.elem
348
349 # Due to limitations with interleave, handling single/multiple selection
350 # enforcement in RELAX NG seems to be possible but really awkward.
351 # Tried it. Leaving it to Schematron.
352
353 ## Select menu option: <option selected>
354
355 option.elem =
356 element option { option.inner & option.attrs }
357 option.attrs =
358 ( common.attrs
359 & common-form.attrs.disabled?
360 & option.attrs.selected?
361 & option.attrs.label?
362 & option.attrs.value?
363 & ( common.attrs.aria.implicit.option
364 | common.attrs.aria.role.option
365 )?
366 )
367 option.attrs.selected =
368 attribute selected {
369 w:string "selected" | w:string ""
370 }
371 option.attrs.label =
372 attribute label {
373 form.data.nonemptystring
374 }
375 option.attrs.value =
376 attribute value {
377 string
378 }
379 option.inner =
380 ( text )
381
382 ## Option Group: <optgroup>
383
384 optgroup.elem =
385 element optgroup { optgroup.inner & optgroup.attrs }
386 optgroup.attrs =
387 ( common.attrs
388 & optgroup.attrs.label
389 & common-form.attrs.disabled?
390 & ( common.attrs.aria.role.presentation
391 | common.attrs.aria.role.menuitem
392 )?
393 )
394 optgroup.attrs.label =
395 attribute label {
396 string
397 }
398 optgroup.inner =
399 ( option.elem*
400 & common.elem.script-supporting*
401 )
402
403 ## Selection Menu: <select>
404
405 select.elem =
406 element select { select.inner & select.attrs }
407 select.attrs =
408 ( common.attrs
409 & common-form.attrs
410 & select.attrs.size?
411 & select.attrs.multiple?
412 # FIXME onfocus, onblur, onchange
413 & ( common.attrs.aria.implicit.listbox
414 | common.attrs.aria.role.listbox # aria-multiselectable depends on "multiple" value; check in assertions
415 )?
416 )
417 select.attrs.size =
418 attribute size {
419 common.data.integer.positive
420 }
421 select.attrs.multiple =
422 attribute multiple {
423 w:string "multiple" | w:string ""
424 }
425 select.inner =
426 ( optgroup.elem*
427 & option.elem*
428 & common.elem.script-supporting*
429 )
430
431 common.elem.phrasing |= select.elem
432
433 ## Shared Definitions for Complex Button
434
435 button.attrs.value =
436 attribute value {
437 string
438 }
439 button.inner =
440 ( common.inner.phrasing )
441
442 ## Complex Submit Button: <button type='submit'>
443
444 button.submit.elem =
445 element button { button.inner & button.submit.attrs }
446 button.submit.attrs =
447 ( common.attrs
448 & common-form.attrs
449 & button.submit.attrs.type?
450 & button.attrs.value?
451 & ( common.attrs.aria.implicit.button
452 | common.attrs.aria.role.button
453 | common.attrs.aria.role.link
454 | common.attrs.aria.role.menuitem
455 | common.attrs.aria.role.menuitemcheckbox
456 | common.attrs.aria.role.menuitemradio
457 | common.attrs.aria.role.radio
458 )?
459 )
460 button.submit.attrs.type =
461 attribute type {
462 w:string "submit"
463 }
464
465 button.elem = button.submit.elem
466
467 ## Complex Reset Button: <button type='reset'>
468
469 button.reset.elem =
470 element button { button.inner & button.reset.attrs }
471 button.reset.attrs =
472 ( common.attrs
473 & common-form.attrs
474 & button.reset.attrs.type
475 & button.attrs.value? #REVISIT I guess this still affects the DOM
476 & ( common.attrs.aria.implicit.button
477 | common.attrs.aria.role.button
478 | common.attrs.aria.role.link
479 | common.attrs.aria.role.menuitem
480 | common.attrs.aria.role.menuitemcheckbox
481 | common.attrs.aria.role.menuitemradio
482 | common.attrs.aria.role.radio
483 )?
484 )
485 button.reset.attrs.type =
486 attribute type {
487 w:string "reset"
488 }
489
490 button.elem |= button.reset.elem
491
492 ## Complex Push Button: <button type='button'>
493
494 button.button.elem =
495 element button { button.inner & button.button.attrs }
496 button.button.attrs =
497 ( common.attrs
498 & common-form.attrs
499 & button.button.attrs.type
500 & button.attrs.value? #REVISIT I guess this still affects the DOM
501 & ( common.attrs.aria.implicit.button
502 | common.attrs.aria.role.button
503 | common.attrs.aria.role.link
504 | common.attrs.aria.role.menuitem
505 | common.attrs.aria.role.menuitemcheckbox
506 | common.attrs.aria.role.menuitemradio
507 | common.attrs.aria.role.radio
508 )?
509 )
510 button.button.attrs.type =
511 attribute type {
512 w:string "button"
513 }
514
515 button.elem |= button.button.elem
516
517 common.elem.phrasing |= button.elem
518
519 ## Form: <form>
520
521 form.elem =
522 element form { form.inner & form.attrs }
523 form.attrs =
524 ( common.attrs
525 & form.attrs.action? #REVISIT Should this be required anyway?
526 & form.attrs.method?
527 & form.attrs.enctype?
528 & common-form.attrs.name?
529 & form.attrs.accept-charset?
530 & ( common.attrs.aria.implicit.form
531 | common.attrs.aria.landmark.form
532 | common.attrs.aria.role.search
533 | common.attrs.aria.role.presentation
534 )?
535 )
536 form.attrs.action =
537 attribute action {
538 common.data.uri.non-empty
539 }
540 form.attrs.method =
541 attribute method {
542 form.attrs.method.data
543 }
544 form.attrs.method.data =
545 ( w:string "get" | w:string "post" )
546 form.attrs.enctype =
547 attribute enctype {
548 form.attrs.enctype.data
549 }
550 form.attrs.enctype.data =
551 ( w:string "application/x-www-form-urlencoded"
552 | w:string "multipart/form-data"
553 )
554 form.attrs.accept-charset =
555 attribute accept-charset {
556 form.data.charsetlist
557 }
558 form.inner =
559 ( common.inner.flow )
560
561 common.elem.flow |= form.elem
562
563 ## Fieldset: <fieldset>
564
565 fieldset.elem =
566 element fieldset { fieldset.inner & fieldset.attrs }
567 fieldset.attrs =
568 ( common.attrs
569 & ( common.attrs.aria.implicit.group
570 | common.attrs.aria
571 )?
572 )
573 fieldset.inner =
574 ( legend.elem? #REVISIT should this be required?
575 , common.inner.flow
576 )
577
578 common.elem.flow |= fieldset.elem
579
580 ## Label: <label>
581
582 label.elem =
583 element label { label.inner & label.attrs }
584 label.attrs =
585 ( common.attrs
586 & label.attrs.for?
587 & ( common.attrs.aria.role.presentation
588 | common.attrs.aria.role.menuitem
589 )?
590 )
591 label.attrs.for =
592 attribute for {
593 common.data.idref
594 }
595 label.inner =
596 ( common.inner.phrasing ) #REVISIT making obvious guess
597
598 common.elem.phrasing |= label.elem
599