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