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

# #####################################################################
##  RELAX NG Schema for HTML 5: Advanced Embedded Content             #
# #####################################################################

## Attributes Common to Media Elements

	# src not included
	media.attrs = 
		(	media.attrs.autoplay?
		&	media.attrs.preload?
		&	media.attrs.controls?
		&	media.attrs.loop?
		&	media.attrs.muted?
		&	embedded.content.attrs.crossorigin?
		)
		media.attrs.autoplay   =
			attribute autoplay   {
				w:string "autoplay" | w:string ""
			}
		media.attrs.preload   =
			attribute preload   {
				w:string "none" | w:string "metadata" | w:string "auto" | w:string ""
			}
		media.attrs.controls  =
			attribute controls  {
				w:string "controls" | w:string ""
			}
		media.attrs.loop =
			attribute loop {
				w:string "loop" | w:string ""
			}
		media.attrs.muted =
			attribute muted {
				w:string "muted" | w:string ""
			}
		
## Source: <source>

	source.elem =
		element source { source.inner & source.attrs }
	source.attrs =
		(	common.attrs
		&	source.attrs.src
		&	source.attrs.type?
		&	source.attrs.media?
		)
		source.attrs.src =
			attribute src {
				common.data.uri.non-empty
			}
		source.attrs.type =
			attribute type {
				common.data.mimetype
			}
		source.attrs.media =
			attribute media {
				common.data.mediaquery
			}
	source.inner =
		( empty )

## Media Source

	media.source = 
		(	media.attrs.src
		|	source.elem*
		)

	media.attrs.src =
		attribute src {
			common.data.uri.non-empty
		}

## Video: <video>

	video.elem.flow =
		element video { video.inner.flow & video.attrs }
	video.elem.phrasing =
		element video { video.inner.phrasing & video.attrs }
	video.attrs =
		(	common.attrs
		&	media.attrs
		&	video.attrs.poster?
		&	video.attrs.height?
		&	video.attrs.width?
		&	video.attrs.playsinline?
		&	video.attrs.loading?
		&	common.attrs.aria.role.application?
		)
		video.attrs.poster =
			attribute poster {
				common.data.uri.non-empty
			}
		video.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		video.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		video.attrs.playsinline =
			attribute playsinline {
				w:string "playsinline" | w:string ""
			}
		video.attrs.loading =
			attribute loading {
				w:string "lazy" | w:string "eager"
			}
	video.inner.flow =
		(	media.source
		,	track.elem*
		,	common.inner.transparent.flow
		)
	video.inner.phrasing =
		(	media.source
		,	track.elem*
		,	common.inner.phrasing
		)

	common.elem.flow |= video.elem.flow
	common.elem.phrasing |= video.elem.phrasing

## Audio: <audio>

	audio.elem.flow =
		element audio { audio.inner.flow & audio.attrs }
	audio.elem.phrasing =
		element audio { audio.inner.phrasing & audio.attrs }
	audio.attrs =
		(	common.attrs
		&	media.attrs
		&	audio.attrs.loading?
		&	common.attrs.aria.role.application?
		)
		audio.attrs.loading =
			attribute loading {
				w:string "lazy" | w:string "eager"
			}
	audio.inner.flow =
		(	media.source
		,	track.elem*
		,	common.inner.transparent.flow
		)
	audio.inner.phrasing =
		(	media.source
		,	track.elem*
		,	common.inner.phrasing
		)

	common.elem.flow |= audio.elem.flow
	common.elem.phrasing |= audio.elem.phrasing

## supplementary media track: <track>
#
	track.elem =
		element track { track.inner & track.attrs }

	track.attrs =
		(	common.attrs
		&	track.attrs.kind?
		&	track.attrs.src
		&	track.attrs.srclang?
		&	track.attrs.label?
		&	track.attrs.default?
		)
		track.attrs.kind =
			attribute kind {
				w:string "subtitles" | w:string "captions" | w:string "descriptions" | w:string "chapters" | w:string "metadata"
			}
		track.attrs.src =
			attribute src {
				common.data.uri.non-empty
			}
		track.attrs.srclang =
			attribute srclang {
				common.data.langcode
			}
		track.attrs.label =
			attribute label {
				string # must be non-empty value; check is in assertions code
			}
		track.attrs.default =
			attribute default {
				w:string "default" | w:string ""
			}

	track.inner =
		( empty )

## Captioned Content: <figure>

	figure.elem =
		element figure { figure.inner & figure.attrs }
	figure.attrs =
		(	common.attrs
		&	(	common.attrs.aria.implicit.figure
			|	common.attrs.aria?
			)?
		)
	figure.inner =
		(	( figcaption.elem?, common.inner.flow )
		|	( common.inner.flow, figcaption.elem? )
		)

	common.elem.flow |= figure.elem

## Figure caption: <figcaption>

	figcaption.elem =
		element figcaption { figcaption.inner & figcaption.attrs }
	figcaption.attrs =
		(	common.attrs
		&	(	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.group
			)?
		)
	figcaption.inner =
		( common.inner.flow )
