datatypes w = "http://whattf.org/datatype-draft"
namespace c = "http://n.validator.nu/custom-elements/"

# #####################################################################
##  RELAX NG Schema for HTML 5: Web Components
# #####################################################################

## Templates: <template>

	template.elem =
		element template { template.inner & template.attrs }
	template.attrs =
		( common.attrs
		& template.attrs.shadowrootmode?
		& template.attrs.shadowrootdelegatesfocus?
		& template.attrs.shadowrootclonable?
		& template.attrs.shadowrootserializable?
		& template.attrs.shadowrootcustomelementregistry?
		& template.attrs.shadowrootslotassignment?
		)
	template.attrs.shadowrootmode =
			attribute shadowrootmode {
				w:string "open" | w:string "closed"
			}
	template.attrs.shadowrootdelegatesfocus =
			attribute shadowrootdelegatesfocus {
				w:string "shadowrootdelegatesfocus" | w:string ""
			}
	template.attrs.shadowrootclonable =
			attribute shadowrootclonable {
				w:string "shadowrootclonable" | w:string ""
			}
	template.attrs.shadowrootserializable =
			attribute shadowrootserializable {
				w:string "shadowrootserializable" | w:string ""
			}
	template.attrs.shadowrootcustomelementregistry =
			attribute shadowrootcustomelementregistry {
				w:string "shadowrootcustomelementregistry" | w:string ""
			}
	template.attrs.shadowrootslotassignment =
			attribute shadowrootslotassignment {
				w:string "named" | w:string "manual"
			}
	template.inner =
		(	common.inner.metadata
		|	common.inner.flow
		|	ol.inner
		|	ul.inner
		|	dl.inner
		|	figure.inner
		|	ruby.inner
		|	object.inner.flow
		|	object.inner.phrasing
		|	video.inner.flow
		|	video.inner.phrasing
		|	audio.inner.flow
		|	audio.inner.phrasing
		|	table.inner
		|	colgroup.inner
		|	thead.inner
		|	tbody.inner
		|	tfoot.inner
		|	tr.inner
		|	fieldset.inner
		|	select.inner
		|	details.inner
		)
	common.elem.metadata |= template.elem
	common.elem.phrasing |= template.elem
	common.elem.script-supporting |= template.elem

# also allow <script> wherever <template> is allowed
	common.elem.script-supporting |= script.elem

## Custom elements: <foo-bar>

	common.elem.flow |= element c:* { common.inner.transparent.flow & attr.any* }
	common.elem.phrasing |= element c:* { common.inner.phrasing & attr.any* }
	attr.any = attribute * { text }

## The "is" attribute
	common.attrs.other &= attribute is { common.data.custom.element.name }?

## Slot: <slot>

	slot.elem.flow =
		element slot { slot.inner.flow & slot.attrs }
	slot.elem.phrasing =
		element slot { slot.inner.phrasing & slot.attrs }
	slot.attrs =
		(	common.attrs
		&	slot.attrs.name?
		&	common.attrs.aria?
		)
	slot.attrs.name =
			attribute name {
				string
			}
	slot.inner.flow =
		( common.inner.transparent.flow )
	slot.inner.phrasing =
		( common.inner.phrasing )

	common.elem.flow |= slot.elem.flow
	common.elem.phrasing |= slot.elem.phrasing

## The "slot" attribute
	common.attrs.other &= attribute slot { text }?
