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

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

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

## Images: <img>

	shared-img.attrs =
		(	common.attrs
		&	(
				( img.attrs.src & img.attrs.srcset? )
				|
				( img.attrs.srcset & img.attrs.src? )
			)
		&	img.attrs.sizes?
		&	img.attrs.generator-unable-to-provide-required-alt?
		&	img.attrs.height?
		&	img.attrs.width?
		&	img.attrs.usemap?
		&	img.attrs.ismap?
		&	img.attrs.controls?
		&	img.attrs.decoding?
		&	img.attrs.loading?
		&	common.attrs.fetchpriority?
		&	referrerpolicy?
		&	embedded.content.attrs.crossorigin?
		)

	img.elem =
		element img { img.inner & img.attrs }
	img.attrs =
		(	shared-img.attrs
		&	img.attrs.alt?
		&	(	common.attrs.aria.implicit.img
			|	common.attrs.aria.role.button
			|	common.attrs.aria.role.checkbox
			|	common.attrs.aria.role.img
			|	common.attrs.aria.role.link
			|	common.attrs.aria.role.math
			|	common.attrs.aria.role.menuitem
			|	common.attrs.aria.role.menuitemcheckbox
			|	common.attrs.aria.role.menuitemradio
			|	common.attrs.aria.role.none
			|	common.attrs.aria.role.option
			|	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.progressbar
			|	common.attrs.aria.role.radio
			|	common.attrs.aria.role.scrollbar
			|	common.attrs.aria.role.separator
			|	common.attrs.aria.role.slider
			|	common.attrs.aria.role.switch
			|	common.attrs.aria.role.tab
			|	common.attrs.aria.role.treeitem
			|	common.attrs.aria.role.doc-cover
			)?
		)

		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.generator-unable-to-provide-required-alt =
			attribute generator-unable-to-provide-required-alt {
				string ""
			}
		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.controls =
			attribute controls {
				w:string "controls" | w:string ""
			}
		img.attrs.decoding =
			attribute decoding {
				(	string "sync"
				|	string "async"
				|	string "auto"
				)
			}
		img.attrs.loading =
			attribute loading {
				w:string "lazy" | w:string "eager"
			}
	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.width?
		&	source.picture.attrs.height?
		)
		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.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		source.picture.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
	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.role.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
			                    | is
			                    | slot
			                    | class
			                    | title
			                    | dir
			                    | lang
			                    | translate
			                    | style
			                    | tabindex
			                    | autofocus
			                    | inert
			                    | contenteditable
			                    | draggable
			                    | hidden
			                    | popover
			                    | inputmode
			                    | nonce
			                    | onauxclick
			                    | onbeforeinput
			                    | onbeforematch
			                    | onbeforetoggle
			                    | onblur
			                    | oncancel
			                    | oncanplay
			                    | oncanplaythrough
			                    | onchange
			                    | onclick
			                    | onclose
			                    | oncommand
			                    | oncontextlost
			                    | oncontextmenu
			                    | oncontextrestored
			                    | oncopy
			                    | oncuechange
			                    | oncut
			                    | ondblclick
			                    | ondrag
			                    | ondragend
			                    | ondragenter
			                    | ondragleave
			                    | ondragover
			                    | ondragstart
			                    | ondrop
			                    | ondurationchange
			                    | onemptied
			                    | onended
			                    | onerror
			                    | onfocus
			                    | onformdata
			                    | oninput
			                    | oninvalid
			                    | onkeydown
			                    | onkeypress
			                    | onkeyup
			                    | onload
			                    | onloadeddata
			                    | onloadedmetadata
			                    | onloadstart
			                    | onmousedown
			                    | onmouseenter
			                    | onmouseleave
			                    | onmousemove
			                    | onmouseout
			                    | onmouseover
			                    | onmouseup
			                    | onpaste
			                    | onpause
			                    | onplay
			                    | onplaying
			                    | onprogress
			                    | onratechange
			                    | onreset
			                    | onresize
			                    | onscroll
			                    | onscrollend
			                    | onsecuritypolicyviolation
			                    | onseeked
			                    | onseeking
			                    | onselect
			                    | onslotchange
			                    | onstalled
			                    | onsubmit
			                    | onsuspend
			                    | ontimeupdate
			                    | ontoggle
			                    | onvolumechange
			                    | onwaiting
			                    | onwheel
			                    | onpointerover
			                    | onpointerenter
			                    | onpointerdown
			                    | onpointermove
			                    | onpointerrawupdate
			                    | onpointerup
			                    | onpointercancel
			                    | onpointerout
			                    | onpointerleave
			                    | ongotpointercapture
			                    | onlostpointercapture
			                    | ontouchstart
			                    | ontouchend
			                    | ontouchmove
			                    | ontouchcancel
			                    | role
			                    | aria-activedescendant
			                    | aria-atomic
			                    | aria-braillelabel
			                    | aria-brailleroledescription
			                    | aria-busy
			                    | aria-controls
			                    | aria-current
			                    | aria-details
			                    | aria-describedby
			                    | aria-description
			                    | aria-disabled
			                    | aria-dropeffect
			                    | aria-errormessage
			                    | aria-expanded
			                    | aria-flowto
			                    | aria-grabbed
			                    | aria-haspopup
			                    | aria-hidden
			                    | aria-invalid
			                    | aria-keyshortcuts
			                    | aria-label
			                    | aria-labelledby
			                    | aria-live
			                    | aria-owns
			                    | aria-relevant
			                    | aria-required
			                    | aria-roledescription
			                    | spellcheck
			                    | autocorrect
			                    | writingsuggestions
			                    | autocapitalize
			                    | enterkeyhint
			                    | accesskey
			                    | itemref
			                    | itemprop
			                    | itemscope
			                    | itemtype
			                    | itemid
			                    | name
			                    | align
			                    | hspace
			                    | vspace
			                    | about
			                    | prefix
			                    | property
			                    | typeof
			                    | vocab
			                    | content
			                    | datatype
			                    | href
			                    | rel
			                    | resource
			                    | rev
			                    | inlist
			                    | its-loc-note
			                    | contextmenu
			                    | dropzone
			                    | onshow
			                    | headingoffset
			                    | headingreset
                                            | 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.classid?
#		&	object.attrs.codebase?
#		&	object.attrs.codetype?
		&	object.attrs.height?
		&	object.attrs.width?
		&	object.attrs.name?
		&	common-form.attrs.form?
		&	(	common.attrs.aria.role.application
			|	common.attrs.aria.landmark.document
			|	common.attrs.aria.role.img
			)?
		)
		object.attrs.data =
			attribute data {
				common.data.uri.non-empty
			}
		object.attrs.type =
			attribute type {
				common.data.mimetype
			}
		object.attrs.height =
			attribute height {
				common.data.integer.non-negative
			}
		object.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		object.attrs.name =
			attribute name {
				common.data.browsing-context
			}
	object.inner.flow =
		( common.inner.transparent.flow )
	object.inner.phrasing =
		( common.inner.phrasing )

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

## 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.loading?
		&	iframe.attrs.sandbox?
		&	iframe.attrs.allowfullscreen?
		&	iframe.attrs.allow?
		&	referrerpolicy?
		&	(	common.attrs.aria.role.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.loading =
			attribute loading {
				w:string "lazy" | w:string "eager"
			}
		iframe.attrs.width =
			attribute width {
				common.data.integer.non-negative
			}
		iframe.attrs.sandbox =
			attribute sandbox {
				common.data.sandbox-allow-list
			} & v5only
		iframe.attrs.allowfullscreen =
			attribute allowfullscreen {
				w:string "allowfullscreen" | w:string ""
			} & v5only
		iframe.attrs.allow =
			attribute allow {
				common.data.feature-policy
			}
	iframe.inner =
		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
		) # 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
		&	aria.global?
		&	shared-hyperlink.attrs.download?
		&	(	area.attrs.alt
			&	shared-hyperlink.attrs.href
			)?
		&	shared-hyperlink.attrs.target?
		&	shared-hyperlink.attrs.ping?
		&	shared-hyperlink.attrs.rel?
		&	area.attrs.shape?
		&	(	common.attrs.aria.role.link
			|	common.attrs.aria.role.button
			|	common.attrs.aria.implicit.link
			)?
		)
		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
