datatypes w = "http://whattf.org/datatype-draft"

# #####################################################################
##  RELAX NG Schema for HTML 5: Web Application Features              #
# #####################################################################

## Additions to Common Attributes

	common.attrs.interact &=
		(	common.attrs.contenteditable?
		&	common.attrs.draggable?
		&	common.attrs.hidden?
		&	common.attrs.popover?
		)
		
	common.attrs.other &= common.attrs.interact

## Editable Content: contenteditable

	common.attrs.contenteditable =
		attribute contenteditable {
			w:string "true" | w:string "plaintext-only" | w:string "false" | w:string ""
		}

## Draggable Element: draggable

	common.attrs.draggable =
		attribute draggable {
			w:string "true" | w:string "false"
		}

## Hidden Element: hidden

	common.attrs.hidden =
		attribute hidden {
			w:string "hidden" | w:string "until-found" | w:string ""
		}

## Popover Element: popover

	common.attrs.popover =
		attribute popover {
			w:string "auto" | w:string "manual" | w:string "hint" | w:string ""
		}

## Global attributes applicable on elements with editable content

	common.attrs.editing &=
		(	common.attrs.inputmode?
		&	common.attrs.spellcheck?
		&	common.attrs.autocapitalize?
		&	common.attrs.enterkeyhint?
		)
		
	common.attrs.other &= common.attrs.editing

## Hint expected data type: inputmode

	common.attrs.inputmode =
		attribute inputmode {
			(	w:string "none"
			|	w:string "text"
			|	w:string "tel"
			|	w:string "url"
			|	w:string "email"
			|	w:string "numeric"
			|	w:string "decimal"
			|	w:string "search"
			)
		}

## Spellchecking and grammar checking: spellcheck

	common.attrs.spellcheck =
		attribute spellcheck {
			w:string "true" | w:string "false" | w:string ""
		}

## Autocapitalization

	common.attrs.autocapitalize =
		attribute autocapitalize {
			(	w:string "off"
			|	w:string "none"
			|	w:string "on"
			|	w:string "sentences"
			|	w:string "words"
			|	w:string "characters"
			)
		}

## Type of Enter button on virtual keyboards: enterkeyhint

	common.attrs.enterkeyhint =
		attribute enterkeyhint {
			(	w:string "enter"
			|	w:string "done"
			|	w:string "go"
			|	w:string "next"
			|	w:string "previous"
			|	w:string "search"
			|	w:string "send"
			)
		}

## Progess Indicator: <progress>

	progress.elem =
		element progress { progress.inner & progress.attrs }
	progress.attrs =
		(	common.attrs
		&	progress.attrs.value?
		&	progress.attrs.max?
		&	(	common.attrs.aria.implicit.progressbar
			|	common.attrs.aria.role.progressbar
			)?
		)
		progress.attrs.value =
			attribute value {
				common.data.float.non-negative
			}
		progress.attrs.max =
			attribute max {
				common.data.float.positive
			}
	progress.inner =
		( common.inner.phrasing ) #Cannot enforce textContent format here

	common.elem.phrasing |= progress.elem

## Dialog box, inspector, or window: <dialog>
	dialog.elem =
		element dialog { dialog.inner & dialog.attrs }
	dialog.attrs =
		(	common.attrs
		&	dialog.attrs.open?
		&	(	common.attrs.aria.implicit.dialog
			|	common.attrs.aria.role.alertdialog
			)?
		)
		dialog.attrs.open =
			attribute open {
				w:string "open" | w:string ""
			}
	dialog.inner =
		( common.inner.flow )
	common.elem.flow |= dialog.elem

## Toolbar: <menu>

	menu.elem =
		element menu { menu.inner & menu.attrs }
	menu.attrs =
		(	common.attrs
		&	(	common.attrs.aria.implicit.list
			|	common.attrs.aria.role.directory
			|	common.attrs.aria.role.group
			|	common.attrs.aria.role.list
			|	common.attrs.aria.role.listbox
			|	common.attrs.aria.role.menu
			|	common.attrs.aria.role.menubar
			|	common.attrs.aria.role.radiogroup
			|	common.attrs.aria.role.tablist
			|	common.attrs.aria.role.toolbar
			|	common.attrs.aria.role.tree
			|	common.attrs.aria.role.presentation
			)?
		)
	menu.inner =
		(	mli.elem*
		&	common.elem.script-supporting*
		)
	common.elem.flow |= menu.elem

## Toolbar item: <li>

	mli.elem =
		element li { mli.inner & mli.attrs }
	mli.attrs =
		(	common.attrs
		&	(	(	common.attrs.aria.role.listitem
				|	common.attrs.aria.role.menuitem
				|	common.attrs.aria.role.menuitemcheckbox
				|	common.attrs.aria.role.menuitemradio
				|	common.attrs.aria.role.option
				|	common.attrs.aria.role.tab
				|	common.attrs.aria.role.treeitem
				|	common.attrs.aria.role.presentation
				)
			)?
		)
	mli.inner =
		( common.inner.flow )

## Canvas for Dynamic Graphics: <canvas>

	canvas.elem.flow =
		element canvas { canvas.inner.flow & canvas.attrs }
	canvas.elem.phrasing =
		element canvas { canvas.inner.phrasing & canvas.attrs }
	canvas.attrs =
		(	common.attrs
		&	canvas.attrs.height?
		&	canvas.attrs.width?
		&	common.attrs.aria?
		)
		canvas.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		canvas.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
	canvas.inner.flow =
		( common.inner.transparent.flow )
	canvas.inner.phrasing =
		( common.inner.phrasing )
	
	common.elem.flow |= canvas.elem.flow
	common.elem.phrasing |= canvas.elem.phrasing

## Additional On-Demand Information: <details>

	details.elem =
		element details { details.inner & details.attrs }
	details.attrs =
		(	common.attrs
		&	details.attrs.open?
		&	(	common.attrs.aria.implicit.group # aria-expanded must be true if open attr present; check by assertions
			|	common.attrs.aria.role.group
			)?
		)
		details.attrs.open =
			attribute open {
				w:string "open" | w:string ""
			}
	details.inner =
		(	summary.elem
		,	common.inner.flow
		)
	
	common.elem.flow |= details.elem

## Caption/summary for details element: <summary>

	summary.elem =
		element summary { summary.inner & summary.attrs }
	summary.attrs =
		(	common.attrs
		&	(	common.attrs.aria.implicit.button
			|	common.attrs.aria.role.button
			)?
		)
	summary.inner =
		(	common.inner.phrasing
		&	h1.elem?
		&	h2.elem?
		&	h3.elem?
		&	h4.elem?
		&	h5.elem?
		&	h6.elem?
		&	hgroup.elem?
		)
