nonRDFaLite = empty
# #####################################################################
##  RELAX NG Schema for HTML 5: RDFa 1.1 and RDFa Lite 1.1            #
# #####################################################################

# #####################################################################
##  RDFa Datatypes                                                    #
# #####################################################################

common.data.rdfa.safecurie =
	xsd:string {
		pattern = "\[(([\i-[:]][\c-[:]]*)?:?)[^\s]*\]"
		minLength = "2"
	}
common.data.rdfa.curie =
	xsd:string {
		pattern = "(([\i-[:]][\c-[:]]*)?:)[^\s]*"
		minLength = "1"
	}
common.data.rdfa.term =
	xsd:string {
		pattern = "[\i-[:]][/\c-[:]]*"
	}

# #####################################################################
##  RDFa Attributes                                                   #
# #####################################################################

common.attrs.rdfa &=
	(	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.property?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.content?
	&	common.attrs.rdfa.datatype?
	&	common.attrs.rdfa.rel?
	&	common.attrs.rdfa.resource?
	&	common.attrs.rdfa.rev?
	&	common.attrs.rdfa.inlist?
	)
	common.attrs.rdfa.prefix =
		attribute prefix {
			(
				xsd:string {
					pattern = "\s*([\i-[:]][\c-[:]]*: [^ ]+)(\s+[\i-[:]][\c-[:]]*: [^ ]+)*\s*"
				}
				|	string ""
			)
		}
	common.attrs.rdfa.property =
		attribute property {
			(
				list {
					(	common.data.rdfa.term
					|	common.data.rdfa.curie
					|	common.data.uri.absolute
					)+
				}
			|	string ""
			)
		}
	common.attrs.rdfa.resource =
		attribute resource {
			(	common.data.rdfa.safecurie
			|	common.data.rdfa.curie
			|	common.data.uri
			)
		}
	common.attrs.rdfa.typeof =
		attribute typeof {
			(
			list {
				(	common.data.rdfa.term
				|	common.data.rdfa.curie
				|	common.data.uri.absolute
				)+
			}
			|	string ""
			)
		}
	common.attrs.rdfa.vocab =
		attribute vocab {
			(	common.data.uri.absolute
			|	string ""
			)
		}
	common.attrs.rdfa.about =
		attribute about {
			(	common.data.rdfa.safecurie
			|	common.data.rdfa.curie
			|	common.data.uri
			)
		} & nonRDFaLite
	common.attrs.rdfa.content =
		attribute content {
			string
		} & nonRDFaLite
	common.attrs.rdfa.datatype =
		attribute datatype {
			(	common.data.rdfa.term
			|	common.data.rdfa.curie
			|	common.data.uri.absolute
			|	string ""
			)
		} & nonRDFaLite
	common.attrs.rdfa.rel =
		attribute rel {
			(
				list {
					(	common.data.rdfa.term
					|	common.data.rdfa.curie
					|	common.data.uri.absolute
					)+
				}
				|	string ""
			)
		} & nonRDFaLite
	common.attrs.rdfa.rev =
		attribute rev {
			(
				list {
					(	common.data.rdfa.term
					|	common.data.rdfa.curie
					|	common.data.uri.absolute
					)+
				}
				|	string ""
			)
		} & nonRDFaLite
	common.attrs.rdfa.inlist =
		attribute inlist {
			string
		} & nonRDFaLite

common.attrs.rdfa.no-rel &=
	(	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.property?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.content?
	&	common.attrs.rdfa.datatype?
	&	common.attrs.rdfa.resource?
	&	common.attrs.rdfa.rev?
	&	common.attrs.rdfa.inlist?
	)
common.attrs.rdfa.no-rel-rev &=
	(	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.property?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.content?
	&	common.attrs.rdfa.datatype?
	&	common.attrs.rdfa.resource?
	&	common.attrs.rdfa.inlist?
	)
common.attrs.rdfa.no-content-noproperty &=
	(	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.datatype?
	&	common.attrs.rdfa.resource?
	&	common.attrs.rdfa.inlist?
	)

common.attrs &= common.attrs.rdfa

a.attrs &= common.attrs.rdfa.no-rel-rev
area.attrs &= common.attrs.rdfa.no-rel
base.attrs &= common.attrs.rdfa.no-rel

link.rdfa.elem.metadata =
	element link { link.inner & link.rdfa.attrs.metadata }
link.rdfa.elem.phrasing =
	element link { link.inner & link.rdfa.attrs.phrasing }
link.rdfa.attrs.metadata =
	(	common.attrs.basic
	&	common.attrs.i18n
	&	common.attrs.present
	&	common.attrs.other
	&	(	(	common.attrs.rdfa.property
			&	link.attrs.rel?
			)
			|
			(	common.attrs.rdfa.property?
			&	link.attrs.rel
			)
		)
	&	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.content?
	&	common.attrs.rdfa.datatype?
	&	(	(	common.attrs.rdfa.resource
			&	link.attrs.href?
			)
			|
			(	common.attrs.rdfa.resource?
			&	link.attrs.href
			)
		)
	&	common.attrs.rdfa.rev?
	&	common.attrs.rdfa.inlist?
	&	shared-hyperlink.attrs.hreflang?
	&	shared-hyperlink.attrs.media?
	&	shared-hyperlink.attrs.type?
	&	link.attrs.sizes?
	&	link.attrs.as?
	#	link.attrs.title included in common.attrs
	&	embedded.content.attrs.crossorigin?
	&	(	common.attrs.aria.role.link
		|	common.attrs.aria.role.presentation
		|	common.attrs.aria.role.menuitem
		)?
	)
link.rdfa.attrs.phrasing =
	(	common.attrs.basic
	&	common.attrs.i18n
	&	common.attrs.present
	&	common.attrs.other
	&	common.attrs.rdfa.property
	&	link.attrs.rel?
	&	(	(	common.attrs.rdfa.resource
			&	link.attrs.href?
			)
			|
			(	common.attrs.rdfa.resource?
			&	link.attrs.href
			)
		)
	&	common.attrs.rdfa.about?
	&	common.attrs.rdfa.prefix?
	&	common.attrs.rdfa.typeof?
	&	common.attrs.rdfa.vocab?
	&	common.attrs.rdfa.content?
	&	common.attrs.rdfa.datatype?
	&	common.attrs.rdfa.rev?
	&	common.attrs.rdfa.inlist?
	&	shared-hyperlink.attrs.hreflang?
	&	shared-hyperlink.attrs.media?
	&	shared-hyperlink.attrs.type?
	&	link.attrs.sizes?
	#	link.attrs.title included in common.attrs
	&	embedded.content.attrs.crossorigin?
	&	(	common.attrs.aria.role.link
		|	common.attrs.aria.role.presentation
		|	common.attrs.aria.role.menuitem
		)?
	)
	common.elem.metadata |= link.rdfa.elem.metadata
	common.elem.phrasing |= link.rdfa.elem.phrasing

## <meta property=foo content=bar> in head ("name" attribute optional)
	meta.property.elem =
		element meta { meta.inner & meta.property.attrs }
	meta.property.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	meta.name.attrs.name?
		&	common.attrs.rdfa.property
		&	meta.name.attrs.content
		)
	common.elem.metadata |= meta.property.elem

## <meta property=foo content=bar> in body ("name" attribute disallowed)
	meta.property-no-name.elem =
		element meta { meta.inner & meta.property-no-name.attrs }
	meta.property-no-name.attrs =
		(	common.attrs.basic
		&	common.attrs.i18n
		&	common.attrs.present
		&	common.attrs.other
		&	common.attrs.rdfa.property
		&	meta.name.attrs.content
		&	(	common.attrs.aria.role.presentation
			|	common.attrs.aria.role.menuitem
			)?
		)
	common.elem.phrasing |= meta.property-no-name.elem

meta.property.attrs &= common.attrs.rdfa.no-content-noproperty
meta.property-no-name.attrs &= common.attrs.rdfa.no-content-noproperty
meta.name.attrs &= common.attrs.rdfa.no-content-noproperty
