All Downloads are FREE. Search and download functionalities are using the official Maven repository.

relaxng.web-forms.rnc Maven / Gradle / Ivy

The newest version!
datatypes w = "http://whattf.org/datatype-draft"

# #####################################################################
##  RELAX NG Schema for HTML 5: Web Forms 1.0 markup                  #
# #####################################################################

## Shared attributes for form controls

	common-form.attrs =
		(	common-form.attrs.name?
		&	common-form.attrs.disabled?
		)
		
	common-form.attrs.name = 
		attribute name {
			string #REVISIT should this be restricted somehow? No & and = perhaps?
		}

	common-form.attrs.disabled = 
		attribute disabled {
			w:string "disabled" | w:string ""
		}

	shared-form.attrs.readonly = 
		attribute readonly {
			w:string "readonly" | w:string ""
		}

	shared-form.attrs.maxlength = 
		attribute maxlength {
			common.data.integer.non-negative
		}

	shared-form.attrs.size = 
		attribute size {
			common.data.integer.positive
		}
	
	# REVISIT tabindex goes in common.attrs

## Shared attributes for 
	
	input.attrs.checked = 
		attribute checked {
			w:string "checked" | w:string ""
		}

## Text Field: 

	input.text.elem = 
		element input { input.text.attrs }
	input.text.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.text.attrs.type?
		&	shared-form.attrs.maxlength? 
		&	shared-form.attrs.readonly?
		&	shared-form.attrs.size?
		&	input.text.attrs.value? 
		&	(	common.attrs.aria.implicit.textbox
			|	common.attrs.aria.implicit.combobox
			|	common.attrs.aria.role.textbox
			|	common.attrs.aria.role.combobox
			)?
		)
		input.text.attrs.type = 
			attribute type {
				w:string "text"
			}
		input.text.attrs.value =
			attribute value {
				form.data.stringwithoutlinebreaks
			}
		
	input.elem = input.text.elem

## Password Field: 

	input.password.elem = 
		element input { input.password.attrs }
	input.password.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.password.attrs.type
		&	shared-form.attrs.maxlength? 
		&	shared-form.attrs.readonly? 
		&	shared-form.attrs.size?
		&	input.password.attrs.value? 
		&	(	common.attrs.aria.implicit.textbox
			|	common.attrs.aria.role.textbox
			)?
		)
		input.password.attrs.type = 
			attribute type {
				w:string "password"
			}
		input.password.attrs.value =
			attribute value {
				form.data.stringwithoutlinebreaks
			}
		
	input.elem |= input.password.elem
		
## Checkbox: 

	input.checkbox.elem = 
		element input { input.checkbox.attrs }
	input.checkbox.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.checkbox.attrs.type
		&	input.attrs.checked? 
		&	input.checkbox.attrs.value? 
		&	(	common.attrs.aria.implicit.checkbox
			|	common.attrs.aria.role.checkbox
			|	common.attrs.aria.role.menuitemcheckbox
			)?
		)
		input.checkbox.attrs.type = 
			attribute type {
				w:string "checkbox"
			}
		input.checkbox.attrs.value =
			attribute value {
				string #REVISIT require non-empty value?
			}
		
	input.elem |= input.checkbox.elem
	
## Radiobutton: 

	input.radio.elem = 
		element input { input.radio.attrs }
	input.radio.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.radio.attrs.type
		&	input.attrs.checked? 
		&	input.radio.attrs.value? 
		&	(	common.attrs.aria.implicit.radio
			|	common.attrs.aria.role.radio
			|	common.attrs.aria.role.menuitemradio
			)?
		)
		input.radio.attrs.type = 
			attribute type {
				w:string "radio"
			}
		input.radio.attrs.value =
			attribute value {
				string #REVISIT require non-empty value?
			}
		
	input.elem |= input.radio.elem
	
## Scripting Hook Button: 

	input.button.elem = 
		element input { input.button.attrs }
	input.button.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.button.attrs.type
		&	input.button.attrs.value? 
		&	(	common.attrs.aria.implicit.button
			|	common.attrs.aria.role.button
			|	common.attrs.aria.role.link
			|	common.attrs.aria.role.menuitem
			|	common.attrs.aria.role.menuitemcheckbox
			|	common.attrs.aria.role.menuitemradio
			|	common.attrs.aria.role.radio
			)?
		)
		input.button.attrs.type = 
			attribute type {
				w:string "button"
			}
		input.button.attrs.value =
			attribute value {
				string #REVISIT require non-empty value?
			}
		
	input.elem |= input.button.elem
	#REVISIT should this be enabled by a scripting module only?
	
## Submit Button: 

	input.submit.elem = 
		element input { input.submit.attrs }
	input.submit.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.submit.attrs.type
		&	input.submit.attrs.value? 
		&	(	common.attrs.aria.implicit.button
			|	common.attrs.aria.role.button
			)?
		)
		input.submit.attrs.type = 
			attribute type {
				w:string "submit"
			}
		input.submit.attrs.value =
			attribute value {
				string #REVISIT require non-empty value?
			}
		
	input.elem |= input.submit.elem
		
## Reset Button: 

	input.reset.elem = 
		element input { input.reset.attrs }
	input.reset.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.reset.attrs.type
		&	input.reset.attrs.value? 
		&	(	common.attrs.aria.implicit.button
			|	common.attrs.aria.role.button
			)?
		)
		input.reset.attrs.type = 
			attribute type {
				w:string "reset"
			}
		input.reset.attrs.value =
			attribute value {
				string #REVISIT require non-empty value?
			}
		
	input.elem |= input.reset.elem
	# REVISIT does reset make sense outside a form?
		
## File Upload: 

	input.file.elem = 
		element input { input.file.attrs }
	input.file.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.file.attrs.type
		&	input.file.attrs.accept?
		&	common.attrs.aria?
		)
		input.file.attrs.type = 
			attribute type {
				w:string "file"
			}
		input.file.attrs.accept = 
			attribute accept {
				form.data.mimetypelist
			}

	input.elem |= input.file.elem
	
## Hidden String: 

	input.hidden.elem = 
		element input { input.hidden.attrs }
	input.hidden.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.hidden.attrs.type
		&	input.hidden.attrs.value? 
		&	common.attrs.aria?
		)
		input.hidden.attrs.type = 
			attribute type {
				w:string "hidden"
			}
		input.hidden.attrs.value =
			attribute value {
				string
			}
		
	input.elem |= input.hidden.elem
		
## Image Submit Button: 

	input.image.elem = 
		element input { input.image.attrs }
	input.image.attrs = 
		(	common.attrs
		&	common-form.attrs
		&	input.image.attrs.type
		&	input.image.attrs.alt 
		&	input.image.attrs.src? 
		&	(	common.attrs.aria.implicit.button
			|	common.attrs.aria.role.button
			|	common.attrs.aria.role.link
			|	common.attrs.aria.role.menuitem
			|	common.attrs.aria.role.menuitemcheckbox
			|	common.attrs.aria.role.menuitemradio
			|	common.attrs.aria.role.radio
			)?
		)	
		input.image.attrs.type = 
			attribute type {
				w:string "image"
			}
		input.image.attrs.alt = 
			attribute alt {
				form.data.nonemptystring
			}
		input.image.attrs.src = 
			attribute src {
				common.data.uri.non-empty
			}
	
	input.elem |= input.image.elem
	
	common.elem.phrasing |= input.elem

## Text Area: