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

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

#######################################################################
## Replaced Content

## Images: <img>

	img.elem =
		element img { img.inner & img.attrs }
	img.attrs =
		(	common.attrs
		&	img.attrs.src
		&	img.attrs.srcset?
		&	img.attrs.sizes?
		&	img.attrs.alt? # ARIA: if alt empty, only allowed role value is "presentation"; check in assertions
		&	img.attrs.height?
		&	img.attrs.width?
		&	img.attrs.usemap?
		&	img.attrs.ismap?
		&	img.attrs.border? # obsolete
		&	embedded.content.attrs.crossorigin?
		&	(	common.attrs.aria.implicit.img
			|	common.attrs.aria
			)?
		)
		img.attrs.src =
			attribute src {
				common.data.uri.non-empty
			}
		img.attrs.srcset =
			attribute srcset {
				string
			} & v5only
		img.attrs.sizes =
			attribute sizes {
				common.data.source.size.list
			} & v5only
		img.attrs.alt =
			attribute alt {
				text
			}
		img.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		img.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		img.attrs.usemap =
			attribute usemap {
				common.data.hash-name
			}
		img.attrs.ismap =
			attribute ismap {
				w:string "ismap" | w:string ""
			}
		img.attrs.border =
			attribute border {
				common.data.zero
			}
	img.inner =
		empty

	common.elem.phrasing |= img.elem

## Image with multiple sources: <picture>

	picture.elem =
		element picture { picture.inner & picture.attrs }
		& v5only
	picture.attrs =
		( common.attrs )
	picture.inner =
		(	(	source.picture.elem*
			&	common.elem.script-supporting*
			),
			(	img.elem
			&	common.elem.script-supporting*
			)
		)

	common.elem.phrasing |= picture.elem

## Picture source: <source srcset>

	source.picture.elem =
		element source { source.picture.inner & source.picture.attrs }
	source.picture.attrs =
		(	common.attrs
		&	source.picture.attrs.media?
		&	source.picture.attrs.srcset
		&	source.picture.attrs.sizes?
		&	source.picture.attrs.type?
		)
		source.picture.attrs.media =
			attribute media {
				common.data.mediaquery
			}
		source.picture.attrs.srcset =
			attribute srcset {
				string
			}
		source.picture.attrs.sizes =
			attribute sizes {
				common.data.source.size.list
			}
		source.picture.attrs.type =
			attribute type {
				common.data.mimetype
			}
	source.picture.inner =
		( empty )

## Plug-ins: <embed>

	embed.elem =
		element embed { embed.inner & embed.attrs }
	embed.attrs =
		(	common.attrs
		&	embed.attrs.src?
		&	embed.attrs.type?
		&	embed.attrs.height?
		&	embed.attrs.width?
		&	embed.attrs.other*
		&	(	common.attrs.aria.landmark.application
			|	common.attrs.aria.landmark.document
			|	common.attrs.aria.role.img
			|	common.attrs.aria.role.presentation
			)?
		)
		embed.attrs.src =
			attribute src {
				common.data.uri.non-empty
			}
		embed.attrs.type =
			attribute type {
				common.data.mimetype
			}
		embed.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		embed.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		embed.attrs.other = # REVISIT common.attrs
			attribute local:* - ( src 
			                    | type 
			                    | height 
			                    | width 
			                    | id 
			                    | class
			                    | title 
			                    | dir 
			                    | lang 
			                    | translate 
			                    | style 
			                    | tabindex 
			                    | contextmenu 
			                    | contenteditable 
			                    | draggable 
			                    | dropzone
			                    | hidden
			                    | onabort
			                    | onblur
			                    | oncanplay
			                    | oncanplaythrough
			                    | onchange
			                    | onclick
			                    | onclose
			                    | oncontextmenu
			                    | ondblclick
			                    | ondrag
			                    | ondragend
			                    | ondragenter
			                    | ondragleave
			                    | ondragover
			                    | ondragstart
			                    | ondrop
			                    | ondurationchange
			                    | onemptied
			                    | onended
			                    | onerror
			                    | onfocus
			                    | oninput
			                    | oninvalid
			                    | onkeydown
			                    | onkeypress
			                    | onkeyup
			                    | onload
			                    | onloadeddata
			                    | onloadedmetadata
			                    | onloadstart
			                    | onmousedown
			                    | onmousemove
			                    | onmouseout
			                    | onmouseover
			                    | onmouseup
			                    | onmousewheel
			                    | onpause
			                    | onplay
			                    | onplaying
			                    | onprogress
			                    | onratechange
			                    | onreset
			                    | onscroll
			                    | onseeked
			                    | onseeking
			                    | onselect
			                    | onshow
			                    | onstalled
			                    | onsubmit
			                    | onsuspend
			                    | ontimeupdate
			                    | onvolumechange
			                    | onwaiting
			                    | onafterprint
			                    | onbeforeprint
			                    | onbeforeunload
			                    | onhashchange
			                    | onmessage
			                    | onoffline
			                    | ononline
			                    | onpopstate
			                    | onredo
			                    | onresize
			                    | onstorage
			                    | onundo
			                    | onunload
			                    | role
			                    | aria-atomic
			                    | aria-busy
			                    | aria-controls
			                    | aria-describedby
			                    | aria-disabled
			                    | aria-dropeffect
			                    | aria-expanded
			                    | aria-flowto
			                    | aria-grabbed
			                    | aria-haspopup
			                    | aria-hidden
			                    | aria-invalid
			                    | aria-label
			                    | aria-labelledby
			                    | aria-live
			                    | aria-owns
			                    | aria-relevant
			                    | aria-required
			                    | spellcheck
			                    | accesskey
			                    | itemref
			                    | itemprop
			                    | itemscope
			                    | itemtype
			                    | itemid
			                    | name
			                    | align
			                    | about
			                    | prefix
			                    | property
			                    | typeof
			                    | vocab
			                    | content
			                    | datatype
			                    | href
			                    | rel
			                    | resource
			                    | rev
			                    | inlist
			                    | its-loc-note
                                            | its-loc-note-type
                                            | its-loc-note-ref
                                            | its-term-info-ref
                                            | its-term
                                            | its-term-confidence
                                            | its-within-text
                                            | its-domain-mapping
                                            | its-ta-confidence
                                            | its-ta-class-ref
                                            | its-ta-ident
                                            | its-ta-ident-ref
                                            | its-ta-source
                                            | its-locale-filter-list
                                            | its-locale-filter-type
                                            | its-person
                                            | its-person-ref
                                            | its-org
                                            | its-org-ref
                                            | its-tool
                                            | its-tool-ref
                                            | its-rev-person
                                            | its-rev-person-ref
                                            | its-rev-org
                                            | its-rev-org-ref
                                            | its-rev-tool
                                            | its-rev-tool-ref
                                            | its-prov-ref
                                            | its-provenance-records-ref
                                            | its-loc-quality-issues-ref
                                            | its-loc-quality-issue-type
                                            | its-loc-quality-issue-comment
                                            | its-loc-quality-issue-severity
                                            | its-loc-quality-issue-profile-ref
                                            | its-loc-quality-issue-enabled
                                            | its-loc-quality-rating-score
                                            | its-loc-quality-rating-vote
                                            | its-loc-quality-rating-score-threshold
                                            | its-loc-quality-rating-vote-threshold
                                            | its-loc-quality-rating-profile-ref
                                            | its-mt-confidence
                                            | its-allowed-characters
                                            | its-storage-size
                                            | its-storage-encoding
                                            | its-line-break-type
                                            | its-annotators-ref
			                    ) 
			{
				string
			}
	embed.inner =
		empty

	common.elem.phrasing |= embed.elem

## Generic Objects: <object>

	object.elem.flow =
		element object { object.inner.flow & object.attrs }
	object.elem.phrasing =
		element object { object.inner.phrasing & object.attrs }
	object.attrs =
		(	common.attrs
		&	(	(	object.attrs.data
				&	object.attrs.type?
				)
			|	object.attrs.type
			)
		&	object.attrs.typemustmatch?
#		&	object.attrs.classid?
#		&	object.attrs.codebase?
#		&	object.attrs.codetype?
		&	object.attrs.height?
		&	object.attrs.width?
		&	object.attrs.usemap?
		&	object.attrs.name?
		&	common-form.attrs.form?
		&	(	common.attrs.aria.landmark.application
			|	common.attrs.aria.landmark.document
			|	common.attrs.aria.role.img
			|	common.attrs.aria.role.presentation
			)?
		)
		object.attrs.data =
			attribute data {
				common.data.uri.non-empty
			}
		object.attrs.type =
			attribute type {
				common.data.mimetype
			}
		object.attrs.typemustmatch =
			attribute typemustmatch {
				w:string "typemustmatch" | w:string ""
			} & v5only
		object.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		object.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		object.attrs.usemap =
			attribute usemap {
				common.data.hash-name
			}
		object.attrs.name =
			attribute name {
				common.data.browsing-context
			}
	object.inner.flow =
		(	param.elem*
		,	common.inner.transparent.flow
		)
	object.inner.phrasing =
		(	param.elem*
		,	common.inner.phrasing
		)

	common.elem.flow |= object.elem.flow
	common.elem.phrasing |= object.elem.phrasing

## Initialization Parameters: <param>

	param.elem =
		element param { param.inner & param.attrs }
	param.attrs =
		(	common.attrs
		&	param.attrs.name
		&	param.attrs.value
		&	(	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.menuitem
			)?
		)
		param.attrs.name =
			attribute name {
				string
			}
		param.attrs.value =
			attribute value {
				string
			}
	param.inner =
		( empty )

## Inline Frame: <iframe>

	iframe.elem =
		element iframe { iframe.inner & iframe.attrs }
	iframe.attrs =
		(	common.attrs
		&	iframe.attrs.src?
		&	iframe.attrs.srcdoc?
		&	iframe.attrs.name?
		&	iframe.attrs.width?
		&	iframe.attrs.height?
		&	iframe.attrs.sandbox?
		&	iframe.attrs.seamless?
		&	iframe.attrs.allowfullscreen?
		&	(	common.attrs.aria.landmark.application
			|	common.attrs.aria.landmark.document
			|	common.attrs.aria.role.img
			|	common.attrs.aria.role.presentation
			)?
		)
		iframe.attrs.src =
			attribute src {
				common.data.uri.non-empty
			}
		iframe.attrs.srcdoc =
			attribute srcdoc {
				string #FIXME
			}
		iframe.attrs.name =
			attribute name {
				common.data.browsing-context
			}
		iframe.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		iframe.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		iframe.attrs.seamless =
			attribute seamless {
				w:string "seamless" | w:string ""
			} & v5only
		iframe.attrs.sandbox =
			attribute sandbox
				{	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-scripts" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-forms" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					,	( w:string "allow-same-origin" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					}
				|	list 
					{	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-top-navigation" )?
					}
				|	list 
					{	( w:string "allow-forms" )?
					,	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-top-navigation" )?
					}
				|	list 
					{	( w:string "allow-scripts" )?
					,	( w:string "allow-forms" )?
					,	( w:string "allow-same-origin" )?
					,	( w:string "allow-top-navigation" )?
					}
				} & v5only
		iframe.attrs.allowfullscreen =
			attribute allowfullscreen {
				w:string "allowfullscreen" | w:string ""
			} & v5only
	iframe.inner =
		( ( text & HTMLonly ) | empty )

	common.elem.phrasing |= iframe.elem

#######################################################################
## Image Maps

## Map Definition: <map>

	map.elem.flow =
		element map { map.inner.flow & map.attrs }
	map.elem.phrasing  =
		element map { map.inner.phrasing & map.attrs }
	map.attrs =
		(	common.attrs
		&	map.attrs.name
		&	(	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.menuitem
			)?
		) # REVISIT make id required in Schematron
		map.attrs.name =
			attribute name {
				common.data.name
			}
	map.inner.flow =
		( common.inner.transparent.flow )
	map.inner.phrasing =
		( common.inner.phrasing )

	common.elem.flow |= map.elem.flow
	common.elem.phrasing |= map.elem.phrasing

## Map Area Definition: <area>

	area.elem =
		element area { area.inner & area.attrs }
	area.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	shared-hyperlink.attrs.download?
		&	(	area.attrs.alt
			&	shared-hyperlink.attrs.href
			)?
		&	shared-hyperlink.attrs.target?
		&	shared-hyperlink.attrs.ping?
		&	shared-hyperlink.attrs.rel?
		&	shared-hyperlink.attrs.hreflang?
		&	shared-hyperlink.attrs.type?
		&	area.attrs.shape?
		&	(	common.attrs.aria.role.link
			|	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.menuitem
			)?
		)
		area.attrs.alt =
			attribute alt {
				text
			}
		area.attrs.shape =
			(	( area.attrs.shape.rect?  & area.attrs.coords.rect   )
			|	( area.attrs.shape.circle & area.attrs.coords.circle )
			|	( area.attrs.shape.poly   & area.attrs.coords.poly   )
			|	( area.attrs.shape.default )
			)
		area.attrs.shape.rect =
			attribute shape {
				w:string "rect"
			}
		area.attrs.coords.rect =
			attribute coords {
				w:rectangle
#				xsd:token {
#					pattern = "-?[0-9]+,-?[0-9]+,-?[0-9]+,-?[0-9]+"
#				}
			}
		area.attrs.shape.circle =
			attribute shape {
				w:string "circle"
			}
		area.attrs.coords.circle =
			attribute coords {
				w:circle
#				xsd:token {
#					pattern = "-?[0-9]+,-?[0-9]+,[0-9]+"
#				}
			}
		area.attrs.shape.poly =
			attribute shape {
				w:string "poly"
			}
		area.attrs.coords.poly =
			attribute coords {
				w:polyline
#				xsd:token {
#					pattern = "-?[0-9]+,-?[0-9]+,-?[0-9]+,-?[0-9]+,-?[0-9]+,-?[0-9]+(,-?[0-9]+,-?[0-9]+)*"
#				}
			}
		area.attrs.shape.default =
			attribute shape {
				w:string "default"
			}
	area.inner =
		( empty )

	common.elem.phrasing |= area.elem

## Attributes Common to Embedded Content

		embedded.content.attrs.crossorigin =
			attribute crossorigin {
				w:string "anonymous" | w:string "use-credentials" | w:string ""
			} & v5only
