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

# #####################################################################
##  RELAX NG Schema for HTML 5: Common Definitions                    #
# #####################################################################


# #####################################################################
##  Language Parameters - redefine in inclusion block as necessary    #
# #####################################################################

## HTML vs. XHTML restrictions

	XMLonly = empty
	HTMLonly = notAllowed

## HTML 4 Compatibility - set to notAllowed to disallow markup introduced in HTML 5
#                         (This only affects mixed-version modules; wholly HTML5
#                          modules should simply be left out of the inclusion list.)

	v5only = empty

## HTML Compatibility Switches - set to notAllowed to disallow

	## XML features that can't be roundtripped HTML <-> XHTML
	#  (xml:base on elements other than <html>)
	nonRoundtrippable = empty

	## XML features that can't be serialized as HTML
	nonHTMLizable = empty

# #####################################################################
##  Wildcards                                                         #
# #####################################################################

## Any attribute from any namespace

	common.attr.anything =
		attribute * { text }*

## Any element from any namespace

	common.elem.anything =
		element * { common.inner.anything & common.attr.anything }

## Any content from any namespace

	common.inner.anything =
		(	text
		&	common.elem.anything*
		)

# #####################################################################
##  Common Element Classes                                            #
# #####################################################################

## Metadata Elements

	common.elem.metadata =
		( notAllowed )

## Phrase Elements

	common.elem.phrasing =
		( notAllowed )

## Prose Elements

	common.elem.flow =
		( common.elem.phrasing )


# #####################################################################
##  Common Content Models                                             #
# #####################################################################

## Metadata Content

	common.inner.metadata =
		( common.elem.metadata* )

## Phrase Content

	common.inner.phrasing =
		( text & common.elem.phrasing* )

## Prose Content

	common.inner.transparent.flow =
		( text & common.elem.flow* )

	common.inner.flow =
		(	text
		&	common.elem.flow*
		)

# #####################################################################
##  Common Attributes                                                 #
# #####################################################################

# When updating, check <bdo> definition too

common.attrs =
	(	common.attrs.basic
	&	common.attrs.i18n
	&	common.attrs.present
	&	common.attrs.other
	)

common.attrs.basic =
	(	common.attrs.id?
	&	common.attrs.class?
	&	common.attrs.title?
	&	common.attrs.base?
	&	common.attrs.space?
	)
	common.attrs.id =
		attribute id {
			common.data.id
		}
	common.attrs.class =
		attribute class {
			common.data.tokens
		}
	common.attrs.title =
		attribute title {
			text
		}
	common.attrs.base =
		common.attrs.xmlbase
		& nonRoundtrippable
	common.attrs.xmlbase =
		attribute xml:base {
			common.data.uri
		} & XMLonly
	common.attrs.space =
		common.attrs.xmlspace
	common.attrs.xmlspace =
		attribute xml:space {
			string "preserve" | string "default"
		} & XMLonly

common.attrs.i18n =
	(	common.attrs.dir?
	&	common.attrs.language?
	&	common.attrs.translate?
	)
	common.attrs.dir =
		attribute dir {
			w:string "ltr" | w:string "rtl" | w:string "auto"
		}
	# This lang definition is a hack for environments where
	# the HTML5 parser maps lang to xml:lang.
	# Sameness check left to Schematron
	common.attrs.language =
		(	common.attrs.xmllang?
		&	common.attrs.lang?
		)
	common.attrs.lang =
		attribute lang {
			common.data.langcode
		} & XMLonly
	common.attrs.xmllang =
		attribute xml:lang {
			common.data.langcode
		}
#	common.attrs.language =
#		(	common.attrs.lang
#		|	common.attrs.xmllang
#		)
#	common.attrs.lang =
#		attribute lang {
#			common.data.langcode
#		} & HTMLonly
#	common.attrs.xmllang =
#		attribute xml:lang {
#			common.data.langcode
#		} & XMLonly
	common.attrs.translate =
		attribute translate {
			w:string "" | w:string "yes" | w:string "no"
		}

common.attrs.present =
	(	common.attrs.style?
	&	common.attrs.tabindex?
	&	common.attrs.accesskey?
	)
	common.attrs.style =
		attribute style {
			string
		}
	common.attrs.tabindex =
		attribute tabindex {
			common.data.integer
		}
		# REVISIT move style to a module and bundle tabindex with ARIA
	common.attrs.accesskey =
		attribute accesskey {
			common.data.keylabellist
		}

common.attrs.other =
	(	common.attrs.autofocus?
	&	common.attrs.nonce?
	&	common.attrs.inert?
	)

	common.attrs.autofocus = 
		attribute autofocus {
			w:string "autofocus" | w:string ""
		}

	common.attrs.blocking = 
		attribute blocking {
			list { w:string "render" }
		}

	common.attrs.fetchpriority =
		attribute fetchpriority {
			w:string "high" | w:string "low" | w:string "auto"
		}

	common.attrs.nonce =
		attribute nonce {
			string
		}

	common.attrs.inert = 
		attribute inert {
			w:string "inert" | w:string ""
		}

# #####################################################################
##  Common Datatypes                                                  #
# #####################################################################

## Names and Tokens

	common.data.tokens =
		list { token* }

	common.data.browsing-context =
		w:browsing-context

	common.data.browsing-context-or-keyword =
		w:browsing-context-or-keyword
#		xsd:string {
#			pattern = "()|([^_].*)|(_[bB][lL][aA][nN][kK])|(_[sS][eE][lL][fF])|(_[pP][aA][rR][eE][nN][tT])|(_[tT][oO][pP])"
#		}


## IDs and IDREFs

	common.data.id =
		w:ID
#		xsd:string {
#			pattern = "\S+"
#		}

	common.data.idref =
		w:IDREF
		
	common.data.idrefs =
		w:IDREFS

	common.data.name =
		w:ID #FIXME

	common.data.hash-name =
		w:hash-name	
#		xsd:string {
#			pattern = "#.+"
#		}

## Numerical

	common.data.integer =
		w:integer
#		xsd:string {
#			pattern = "-?[0-9]+"
#		}

	common.data.integer.positive =
		w:integer-positive
#		xsd:string {
#			pattern = "0*[1-9][0-9]*"
#		}

	common.data.integer.non-negative =
		w:integer-non-negative
#		xsd:string {
#			pattern = "[0-9]+"
#		}
		
#	common.data.percent =
#		xsd:string {
#			pattern = "(100)|([1-9]?[0-9](\.[0-9]+)?)%"
#		}
		
	common.data.float =
		w:float
#		xsd:string {
#			pattern = "-?[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?"
#		}

	common.data.float.positive =
		w:float-positive
#		xsd:string {
#			pattern = "(0*[1-9][0-9]*(\.[0-9]+)?)|([0-9]+(\.0*[1-9][0-9]*)?)([eE]-?[0-9]+)?"
#		}
		
	common.data.float.non-negative =
		w:float-non-negative
#		xsd:string {
#			pattern = "[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?"
#		}
		
## Temporal

	common.data.datetime =
		w:datetime-tz

	common.data.date =
		w:date

	common.data.time-datetime =
		w:time-datetime

## IRIs

	common.data.uri =
		# allow either a non-empty IRI ref or zero or more HTML
		# space characters (which are: space, tab, LF, FF, CR)
		(	w:iri-ref
		|	xsd:string {
				pattern = "[ \x{0A}-\x{0D}]*"
				# NOTE The range above incorrectly allows U+000B
				# in addition to the HTML space characters; but
				# that's not a problem in practice because HTML
				# and XML parsers will both catch any U+000B
				# and report an error for it before that pattern
				# ever gets evaluated.
		 	}
		)

	common.data.uri.non-empty =
		w:iri-ref

	common.data.uris =
		list { w:iri-ref* }

	common.data.uris.http.or.https =
		list { w:iri-ref-http-or-https* }

	common.data.uri.absolute =
		w:iri

## <link type='icon'> sizes

	common.data.sizes =
#		list { w:sizes }
		list {
			xsd:string {
				pattern = "[1-9][0-9]*x[1-9][0-9]*"
			}+
		}

## color for <link rel="mask-icon"> and <meta name="theme-color">

	common.data.color =
		w:color

## MIME types

	common.data.mimetype =
		w:mime-type

## Script type

	common.data.scripttype =
		w:script-type

## Encodings

	common.data.charset =
		w:charset

	common.data.meta-charset =
		w:meta-charset

## Refresh

	common.data.refresh =
		w:refresh

## Default style

	common.data.default-style =
        string
#		w:default-style

## X-UA-Compatible

	common.data.x-ua-compatible =
		string

## Media Queries

	common.data.mediaquery =
		w:media-query

## Language Codes

	common.data.langcode =
		w:string "" | w:language

## List of Key Labels
	common.data.keylabellist =
		w:keylabellist

## List of Source Sizes
	common.data.source.size.list =
		w:source-size-list

## Subresource Integrity
	common.data.integrity =
		w:integrity-metadata

## Content Security Policy
	common.data.content-security-policy =
		w:content-security-policy

## Feature Policy
	common.data.feature-policy =
		string

## List of sandbox keywords
	common.data.sandbox-allow-list =
		w:string "" | w:sandbox-allow-list

## Custom element name
	common.data.custom.element.name =
		w:custom-element-name

## Microdata Properties
  common.data.microdata-properties =
    list { w:microdata-property+ }

## Zero
  common.data.zero =
    w:zero

## ECMAScript FunctionBody
  common.data.functionbody =
    string

## autocomplete

	common.data.autocomplete.any =
		w:autocomplete-any

# #####################################################################
##  WF2 Module Hook                                                   #
# #####################################################################
		
common-form.attrs.form = ( notAllowed )

# #####################################################################
##  Script-supporting elements
# #####################################################################

common.elem.script-supporting = ( notAllowed )

# #####################################################################
##  ARIA Module Hooks                                                 #
# #####################################################################

common.attrs.aria = ( notAllowed )
common.attrs.aria.role.alert = ( notAllowed )
common.attrs.aria.role.alertdialog = ( notAllowed )
common.attrs.aria.role.application = ( notAllowed )
common.attrs.aria.role.article = ( notAllowed )
common.attrs.aria.role.banner = ( notAllowed )
common.attrs.aria.role.button = ( notAllowed )
common.attrs.aria.role.cell |= ( notAllowed )
common.attrs.aria.role.checkbox = ( notAllowed )
common.attrs.aria.role.combobox = ( notAllowed )
common.attrs.aria.role.complementary = ( notAllowed )
common.attrs.aria.role.dialog = ( notAllowed )
common.attrs.aria.role.directory = ( notAllowed )
common.attrs.aria.role.document = ( notAllowed )
common.attrs.aria.role.feed |= ( notAllowed )
common.attrs.aria.role.figure |= ( notAllowed )
common.attrs.aria.role.group = ( notAllowed )
common.attrs.aria.role.heading = ( notAllowed )
common.attrs.aria.role.img = ( notAllowed )
common.attrs.aria.role.link = ( notAllowed )
common.attrs.aria.role.list = ( notAllowed )
common.attrs.aria.role.listitem = ( notAllowed )
common.attrs.aria.role.log = ( notAllowed )
common.attrs.aria.role.listbox = ( notAllowed )
common.attrs.aria.role.main = ( notAllowed )
common.attrs.aria.role.marquee = ( notAllowed )
common.attrs.aria.role.menu = ( notAllowed )
common.attrs.aria.role.menubar = ( notAllowed )
common.attrs.aria.role.menuitem = ( notAllowed )
common.attrs.aria.role.menuitemcheckbox = ( notAllowed )
common.attrs.aria.role.menuitemradio = ( notAllowed )
common.attrs.aria.role.option = ( notAllowed )
common.attrs.aria.role.presentation = ( notAllowed )
common.attrs.aria.role.progressbar = ( notAllowed )
common.attrs.aria.role.radio = ( notAllowed )
common.attrs.aria.role.radiogroup |= ( notAllowed )
common.attrs.aria.role.region = ( notAllowed )
common.attrs.aria.role.rowgroup |= ( notAllowed )
common.attrs.aria.role.search = ( notAllowed )
common.attrs.aria.role.searchbox |= ( notAllowed )
common.attrs.aria.role.separator = ( notAllowed )
common.attrs.aria.role.slider = ( notAllowed )
common.attrs.aria.role.spinbutton = ( notAllowed )
common.attrs.aria.role.status = ( notAllowed )
common.attrs.aria.role.switch = ( notAllowed )
common.attrs.aria.role.tab = ( notAllowed )
common.attrs.aria.role.table |= ( notAllowed )
common.attrs.aria.role.tablist = ( notAllowed )
common.attrs.aria.role.tabpanel = ( notAllowed )
common.attrs.aria.role.textbox = ( notAllowed )
common.attrs.aria.role.toolbar = ( notAllowed )
common.attrs.aria.role.tree = ( notAllowed )
common.attrs.aria.role.treeitem = ( notAllowed )
common.attrs.aria.implicit.article = ( notAllowed )
common.attrs.aria.implicit.banner = ( notAllowed )
common.attrs.aria.implicit.button = ( notAllowed )
common.attrs.aria.implicit.cell |= ( notAllowed )
common.attrs.aria.implicit.checkbox = ( notAllowed )
common.attrs.aria.implicit.column-or-row-header = ( notAllowed )
common.attrs.aria.implicit.combobox = ( notAllowed )
common.attrs.aria.implicit.complementary = ( notAllowed )
common.attrs.aria.implicit.contentinfo = ( notAllowed )
common.attrs.aria.implicit.dialog = ( notAllowed )
common.attrs.aria.implicit.figure |= ( notAllowed )
common.attrs.aria.implicit.document = ( notAllowed )
common.attrs.aria.implicit.form = ( notAllowed )
common.attrs.aria.implicit.group = ( notAllowed )
common.attrs.aria.implicit.heading = ( notAllowed )
common.attrs.aria.implicit.img = ( notAllowed )
common.attrs.aria.implicit.landmark = ( notAllowed )
common.attrs.aria.implicit.link = ( notAllowed )
common.attrs.aria.implicit.list = ( notAllowed )
common.attrs.aria.implicit.listbox = ( notAllowed )
common.attrs.aria.implicit.listitem = ( notAllowed )
common.attrs.aria.implicit.main = ( notAllowed )
common.attrs.aria.implicit.math |= ( notAllowed )
common.attrs.aria.implicit.navigation = ( notAllowed )
common.attrs.aria.implicit.option = ( notAllowed )
common.attrs.aria.implicit.progressbar = ( notAllowed )
common.attrs.aria.implicit.radio = ( notAllowed )
common.attrs.aria.implicit.region = ( notAllowed )
common.attrs.aria.implicit.row |= ( notAllowed )
common.attrs.aria.implicit.rowgroup |= ( notAllowed )
common.attrs.aria.implicit.searchbox |= ( notAllowed )
common.attrs.aria.implicit.section = ( notAllowed )
common.attrs.aria.implicit.select = ( notAllowed )
common.attrs.aria.implicit.separator = ( notAllowed )
common.attrs.aria.implicit.slider = ( notAllowed )
common.attrs.aria.implicit.spinbutton = ( notAllowed )
common.attrs.aria.implicit.status = ( notAllowed )
common.attrs.aria.implicit.structure = ( notAllowed )
common.attrs.aria.implicit.table |= ( notAllowed )
common.attrs.aria.implicit.textbox = ( notAllowed )
common.attrs.aria.implicit.toolbar = ( notAllowed )
common.attrs.aria.prop.readonly = ( notAllowed )
common.attrs.aria.landmark.banner = ( notAllowed )
common.attrs.aria.landmark.complementary = ( notAllowed )
common.attrs.aria.landmark.contentinfo = ( notAllowed )
common.attrs.aria.landmark.form = ( notAllowed )
common.attrs.aria.landmark.main = ( notAllowed )
common.attrs.aria.landmark.navigation = ( notAllowed )
common.attrs.aria.landmark.search = ( notAllowed )
# per ARIA spec: article, document, and note are not actually landmarks
common.attrs.aria.landmark.article = ( notAllowed )
common.attrs.aria.landmark.document = ( notAllowed )
common.attrs.aria.landmark.note = ( notAllowed )

common.attrs.aria.role.doc-abstract = ( notAllowed )
common.attrs.aria.role.doc-acknowledgments = ( notAllowed )
common.attrs.aria.role.doc-afterword = ( notAllowed )
common.attrs.aria.role.doc-appendix = ( notAllowed )
common.attrs.aria.role.doc-backlink = ( notAllowed )
common.attrs.aria.role.doc-biblioentry = ( notAllowed )
common.attrs.aria.role.doc-bibliography = ( notAllowed )
common.attrs.aria.role.doc-biblioref = ( notAllowed )
common.attrs.aria.role.doc-chapter = ( notAllowed )
common.attrs.aria.role.doc-colophon = ( notAllowed )
common.attrs.aria.role.doc-conclusion = ( notAllowed )
common.attrs.aria.role.doc-cover = ( notAllowed )
common.attrs.aria.role.doc-credit = ( notAllowed )
common.attrs.aria.role.doc-credits = ( notAllowed )
common.attrs.aria.role.doc-dedication = ( notAllowed )
common.attrs.aria.role.doc-endnote = ( notAllowed )
common.attrs.aria.role.doc-endnotes = ( notAllowed )
common.attrs.aria.role.doc-epigraph = ( notAllowed )
common.attrs.aria.role.doc-epilogue = ( notAllowed )
common.attrs.aria.role.doc-errata = ( notAllowed )
common.attrs.aria.role.doc-example = ( notAllowed )
common.attrs.aria.role.doc-footnote = ( notAllowed )
common.attrs.aria.role.doc-foreword = ( notAllowed )
common.attrs.aria.role.doc-glossary = ( notAllowed )
common.attrs.aria.role.doc-glossref = ( notAllowed )
common.attrs.aria.role.doc-index = ( notAllowed )
common.attrs.aria.role.doc-introduction = ( notAllowed )
common.attrs.aria.role.doc-noteref = ( notAllowed )
common.attrs.aria.role.doc-notice = ( notAllowed )
common.attrs.aria.role.doc-pagebreak = ( notAllowed )
common.attrs.aria.role.doc-pagelist = ( notAllowed )
common.attrs.aria.role.doc-part = ( notAllowed )
common.attrs.aria.role.doc-preface = ( notAllowed )
common.attrs.aria.role.doc-prologue = ( notAllowed )
common.attrs.aria.role.doc-pullquote = ( notAllowed )
common.attrs.aria.role.doc-qna = ( notAllowed )
common.attrs.aria.role.doc-subtitle = ( notAllowed )
common.attrs.aria.role.doc-tip = ( notAllowed )
common.attrs.aria.role.doc-toc = ( notAllowed )
