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

# #####################################################################
##  RELAX NG Schema for HTML 5: Phrase Markup                         #
# #####################################################################

## Contextual Hyperlink: <a>

	a.elem.phrasing = a.href.elem.phrasing | a.nohref.elem.phrasing
	a.elem.flow = a.href.elem.flow | a.nohref.elem.flow
	a.href.elem.phrasing =
		element a { a.inner.phrasing & a.href.attrs }
	a.href.elem.flow =
		element a { a.inner.flow & a.href.attrs }
	a.nohref.elem.phrasing =
		element a { a.inner.phrasing & a.nohref.attrs }
	a.nohref.elem.flow =
		element a { a.inner.flow & a.nohref.attrs }
	a.href.attrs =
		( a.attrs
		& shared-hyperlink.attrs.href
		&	(	common.attrs.aria.implicit.link
			|	common.attrs.aria.role.button
			|	common.attrs.aria.role.checkbox
			|	common.attrs.aria.role.link
			|	common.attrs.aria.role.menuitem
			|	common.attrs.aria.role.menuitemcheckbox
			|	common.attrs.aria.role.menuitemradio
			|	common.attrs.aria.role.option
			|	common.attrs.aria.role.radio
			|	common.attrs.aria.role.switch
			|	common.attrs.aria.role.tab
			|	common.attrs.aria.role.treeitem
			|	common.attrs.aria.role.doc-backlink
			|	common.attrs.aria.role.doc-biblioref
			|	common.attrs.aria.role.doc-glossref
			|	common.attrs.aria.role.doc-noteref
			)?
		)
	a.nohref.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	common.attrs.aria?
		&	aria.global?
		)
	a.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	aria.global?
		&	shared-hyperlink.attrs.download?
		&	shared-hyperlink.attrs.target?
		&	shared-hyperlink.attrs.rel?
		&	shared-hyperlink.attrs.hreflang?
		&	shared-hyperlink.attrs.type?
		&	shared-hyperlink.attrs.ping?
		&	referrerpolicy?
		)
	a.inner.phrasing =
		( common.inner.phrasing )
	a.inner.flow =
		( common.inner.transparent.flow )

	common.elem.phrasing |= a.elem.phrasing
	common.elem.flow |= a.elem.flow

## Shared hyperlink attributes

  shared-hyperlink.attrs.download =
    attribute download {
      string
    }
  shared-hyperlink.attrs.href =
    attribute href {
      common.data.uri
    }
  shared-hyperlink.attrs.target =
    attribute target {
      common.data.browsing-context-or-keyword
    }
  shared-hyperlink.attrs.rel =
    attribute rel {
      w:rel-value
    }
  shared-hyperlink.attrs.hreflang =
    attribute hreflang {
      common.data.langcode
    }
  shared-hyperlink.attrs.media =
    attribute media {
      common.data.mediaquery
    }
  shared-hyperlink.attrs.type =
    attribute type {
      common.data.mimetype
    }
  shared-hyperlink.attrs.ping =
    attribute ping {
      common.data.uris.http.or.https
    } & v5only

referrerpolicy =
	attribute referrerpolicy {
		string ""
	|	string "no-referrer"
	|	string "no-referrer-when-downgrade"
	|	string "same-origin"
	|	string "origin"
	|	string "strict-origin"
	|	string "origin-when-cross-origin"
	|	string "strict-origin-when-cross-origin"
	|	string "unsafe-url"
	} & v5only

## Emphatic Stress: <em>

	em.elem =
		element em { em.inner & em.attrs }
	em.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	em.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= em.elem

## Strong Importance: <strong>

	strong.elem =
		element strong { strong.inner & strong.attrs }
	strong.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	strong.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= strong.elem

## Small Print and Side Comments: <small>

	small.elem =
		element small { small.inner & small.attrs }
	small.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	small.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= small.elem

## Marked (Highlighted) Text: <mark>

	mark.elem =
		element mark { mark.inner & mark.attrs }
		& v5only
	mark.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	mark.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= mark.elem

## Abbreviation: <abbr>

	abbr.elem =
		element abbr { abbr.inner & abbr.attrs }
	abbr.attrs =
		(	common.attrs
		#	abbr.attrs.title included in common.attrs
		&	common.attrs.aria?
		)
	abbr.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= abbr.elem

## Defining Instance: <dfn>

	dfn.elem =
		element dfn { dfn.inner & dfn.attrs }
	dfn.attrs =
		(	common.attrs
		#	dfn.attrs.title included in common.attrs
		&	common.attrs.aria?
		)
	dfn.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= dfn.elem

## Italic: <i>

	i.elem =
		element i { i.inner & i.attrs }
	i.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	i.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= i.elem

## Bold: <b>

	b.elem =
		element b { b.inner & b.attrs }
	b.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	b.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= b.elem

## Struck Text: <s>

	s.elem =
		element s { s.inner & s.attrs }
	s.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	s.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= s.elem

## Underline: <u>

	u.elem =
		element u { u.inner & u.attrs }
	u.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	u.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= u.elem

## Code Fragment: <code>

	code.elem =
		element code { code.inner & code.attrs }
	code.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	code.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= code.elem

## Variable or Placeholder: <var>

	var.elem =
		element var { var.inner & var.attrs }
	var.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	var.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= var.elem

## (Sample) Output: <samp>

	samp.elem =
		element samp { samp.inner & samp.attrs }
	samp.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	samp.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= samp.elem

## User Input: <kbd>

	kbd.elem =
		element kbd { kbd.inner & kbd.attrs }
	kbd.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	kbd.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= kbd.elem

## Superscript: <sup>

	sup.elem =
		element sup { sup.inner & sup.attrs }
	sup.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	sup.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= sup.elem

## Subscript: <sub>

	sub.elem =
		element sub { sub.inner & sub.attrs }
	sub.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	sub.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= sub.elem

## Quotation: <q>

	q.elem =
		element q { q.inner & q.attrs }
	q.attrs =
		(	common.attrs
		&	q.attrs.cite?
		&	common.attrs.aria?
		)
		q.attrs.cite =
			attribute cite {
				common.data.uri
			}
	q.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= q.elem

## Title of Work: <cite>

	cite.elem =
		element cite { cite.inner & cite.attrs }
	cite.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	cite.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= cite.elem

## Generic Span: <span>

	span.elem =
		element span { span.inner & span.attrs }
	span.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	span.inner =
		( common.inner.phrasing ) # REVISIT allow ol and ul?

	common.elem.phrasing |= span.elem

## Bidirectional Override: <bdo>

	bdo.elem =
		element bdo { bdo.inner & bdo.attrs }
	bdo.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	bdo.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= bdo.elem

## Bidirectional Isolate: <bdi>

	bdi.elem =
		element bdi { bdi.inner & bdi.attrs }
	bdi.attrs =
		(	common.attrs
		&	common.attrs.aria?
		)
	bdi.inner =
		( common.inner.phrasing )

	common.elem.phrasing |= bdi.elem

## Line Break: <br>

	br.elem =
		element br { br.inner & br.attrs }
	br.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	aria.state.hidden?
		&	common.attrs.aria.role.presentation?
		)
	br.inner =
		( empty )

	common.elem.phrasing |= br.elem

## Line-break opportunity: <wbr>

	wbr.elem =
		element wbr { wbr.inner & wbr.attrs }
	wbr.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	aria.state.hidden?
		&	common.attrs.aria.role.presentation?
		)
	wbr.inner =
		( empty )

	common.elem.phrasing |= wbr.elem
