c3d2-web/html5-syntax/common.rng

537 lines
16 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- ##################################################################### -->
<define name="XMLonly">
<a:documentation> RELAX NG Schema for HTML 5: Common Definitions #</a:documentation>
<!-- ##################################################################### -->
<!-- ##################################################################### -->
<a:documentation> Language Parameters - redefine in inclusion block as necessary #</a:documentation>
<!-- ##################################################################### -->
<a:documentation>HTML vs. XHTML restrictions</a:documentation>
<empty/>
</define>
<define name="HTMLonly">
<notAllowed/>
</define>
<!--
(This only affects mixed-version modules; wholly HTML5
modules should simply be left out of the inclusion list.)
-->
<define name="v5only">
<a:documentation>HTML 4 Compatibility - set to notAllowed to disallow markup introduced in HTML 5</a:documentation>
<empty/>
</define>
<!-- (xml:base on elements other than <html>) -->
<define name="nonRoundtrippable">
<a:documentation>HTML Compatibility Switches - set to notAllowed to disallow</a:documentation>
<a:documentation>XML features that can't be roundtripped HTML &lt;-&gt; XHTML</a:documentation>
<empty/>
</define>
<define name="nonHTMLizable">
<a:documentation>XML features that can't be serialized as HTML</a:documentation>
<empty/>
</define>
<!-- ##################################################################### -->
<define name="common.attr.anything">
<a:documentation> Wildcards #</a:documentation>
<!-- ##################################################################### -->
<a:documentation>Any attribute from any namespace</a:documentation>
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
</define>
<define name="common.elem.anything">
<a:documentation>Any element from any namespace</a:documentation>
<element>
<anyName/>
<interleave>
<ref name="common.inner.anything"/>
<ref name="common.attr.anything"/>
</interleave>
</element>
</define>
<define name="common.inner.anything">
<a:documentation>Any content from any namespace</a:documentation>
<interleave>
<text/>
<zeroOrMore>
<ref name="common.elem.anything"/>
</zeroOrMore>
</interleave>
</define>
<!-- ##################################################################### -->
<define name="common.elem.metadata">
<a:documentation> Common Element Classes #</a:documentation>
<!-- ##################################################################### -->
<a:documentation>Metadata Elements</a:documentation>
<notAllowed/>
</define>
<define name="common.elem.phrasing">
<a:documentation>Phrase Elements</a:documentation>
<notAllowed/>
</define>
<define name="common.elem.flow">
<a:documentation>Prose Elements</a:documentation>
<ref name="common.elem.phrasing"/>
</define>
<!-- ##################################################################### -->
<define name="common.inner.metadata">
<a:documentation> Common Content Models #</a:documentation>
<!-- ##################################################################### -->
<a:documentation>Metadata Content</a:documentation>
<zeroOrMore>
<ref name="common.elem.metadata"/>
</zeroOrMore>
</define>
<define name="common.inner.phrasing">
<a:documentation>Phrase Content</a:documentation>
<interleave>
<text/>
<zeroOrMore>
<ref name="common.elem.phrasing"/>
</zeroOrMore>
</interleave>
</define>
<define name="common.inner.flow">
<a:documentation>Prose Content</a:documentation>
<interleave>
<text/>
<zeroOrMore>
<ref name="common.elem.flow"/>
</zeroOrMore>
</interleave>
</define>
<!-- REVISIT <style scoped> -->
<!-- ##################################################################### -->
<!-- ##################################################################### -->
<!-- When updating, check <bdo> definition too -->
<define name="common.attrs">
<a:documentation> Common Attributes #</a:documentation>
<interleave>
<ref name="common.attrs.basic"/>
<ref name="common.attrs.i18n"/>
<ref name="common.attrs.present"/>
<ref name="common.attrs.other"/>
</interleave>
</define>
<define name="common.attrs.basic">
<interleave>
<optional>
<choice>
<ref name="common.attrs.id"/>
<ref name="common.attrs.xml-id"/>
</choice>
</optional>
<optional>
<!-- REVISIT assuming only either one is allowed -->
<ref name="common.attrs.class"/>
</optional>
<optional>
<ref name="common.attrs.title"/>
</optional>
<optional>
<ref name="common.attrs.base"/>
</optional>
<optional>
<ref name="common.attrs.space"/>
</optional>
</interleave>
</define>
<define name="common.attrs.id">
<attribute name="id">
<ref name="common.data.id"/>
</attribute>
</define>
<define name="common.attrs.xml-id">
<interleave>
<attribute name="xml:id">
<data type="NCName"/>
</attribute>
<ref name="XMLonly"/>
</interleave>
</define>
<define name="common.attrs.class">
<attribute name="class">
<ref name="common.data.tokens"/>
</attribute>
</define>
<define name="common.attrs.title">
<attribute name="title"/>
</define>
<define name="common.attrs.base">
<interleave>
<ref name="common.attrs.xmlbase"/>
<ref name="nonRoundtrippable"/>
</interleave>
</define>
<define name="common.attrs.xmlbase">
<interleave>
<attribute name="xml:base">
<ref name="common.data.uri"/>
</attribute>
<ref name="XMLonly"/>
</interleave>
</define>
<define name="common.attrs.space">
<ref name="common.attrs.xmlspace"/>
</define>
<define name="common.attrs.xmlspace">
<interleave>
<attribute name="xml:space">
<value type="string" datatypeLibrary="">preserve</value>
<!-- REVISIT this is not allowed per spec -->
</attribute>
<ref name="XMLonly"/>
</interleave>
</define>
<define name="common.attrs.i18n">
<interleave>
<optional>
<ref name="common.attrs.dir"/>
</optional>
<optional>
<ref name="common.attrs.language"/>
</optional>
</interleave>
</define>
<define name="common.attrs.dir">
<attribute name="dir">
<choice>
<value type="string">ltr</value>
<value type="string">rtl</value>
</choice>
</attribute>
</define>
<!--
This lang definition is a hack for enviroments where
the HTML5 parser maps lang to xml:lang.
Sameness check left to Schematron
-->
<define name="common.attrs.language">
<interleave>
<optional>
<ref name="common.attrs.xmllang"/>
</optional>
<optional>
<ref name="common.attrs.lang"/>
</optional>
</interleave>
</define>
<define name="common.attrs.lang">
<interleave>
<attribute name="lang">
<ref name="common.data.langcode"/>
</attribute>
<ref name="XMLonly"/>
</interleave>
</define>
<define name="common.attrs.xmllang">
<attribute name="xml:lang">
<ref name="common.data.langcode"/>
</attribute>
</define>
<!--
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
-->
<define name="common.attrs.present">
<interleave>
<optional>
<ref name="common.attrs.style"/>
</optional>
<optional>
<ref name="common.attrs.tabindex"/>
</optional>
<optional>
<ref name="common.attrs.accesskey"/>
</optional>
</interleave>
</define>
<define name="common.attrs.style">
<attribute name="style">
<data type="string" datatypeLibrary=""/>
</attribute>
</define>
<define name="common.attrs.tabindex">
<attribute name="tabindex">
<ref name="common.data.integer"/>
</attribute>
</define>
<!-- REVISIT move style to a module and bundle tabindex with ARIA -->
<define name="common.attrs.accesskey">
<attribute name="accesskey">
<ref name="common.data.keylabellist"/>
</attribute>
</define>
<define name="common.attrs.other">
<empty/>
</define>
<!-- ##################################################################### -->
<define name="common.data.tokens">
<a:documentation> Common Datatypes #</a:documentation>
<!-- ##################################################################### -->
<a:documentation>Names and Tokens</a:documentation>
<list>
<zeroOrMore>
<data type="token" datatypeLibrary=""/>
</zeroOrMore>
</list>
</define>
<define name="common.data.browsing-context">
<data type="string"/>
</define>
<define name="common.data.browsing-context-or-keyword">
<data type="string"/>
</define>
<!--
xsd:string {
pattern = "()|([^_].*)|(_[bB][lL][aA][nN][kK])|(_[sS][eE][lL][fF])|(_[pP][aA][rR][eE][nN][tT])|(_[tT][oO][pP])"
}
-->
<define name="common.data.id">
<a:documentation>IDs and IDREFs</a:documentation>
<data type="ID"/>
</define>
<!--
xsd:string {
pattern = "\S+"
}
-->
<define name="common.data.idref">
<data type="IDREF"/>
</define>
<define name="common.data.idrefs">
<data type="IDREFS"/>
</define>
<define name="common.data.name">
<data type="ID"/>
</define>
<!-- FIXME -->
<define name="common.data.hash-name">
<data type="string"/>
</define>
<!--
xsd:string {
pattern = "#.+"
}
-->
<define name="common.data.integer">
<a:documentation>Numerical</a:documentation>
<data type="integer"/>
</define>
<!--
xsd:string {
pattern = "-?[0-9]+"
}
-->
<define name="common.data.integer.positive">
<data type="positiveInteger"/>
</define>
<!--
xsd:string {
pattern = "0*[1-9][0-9]*"
}
-->
<define name="common.data.integer.non-negative">
<data type="nonNegativeInteger"/>
</define>
<!--
xsd:string {
pattern = "[0-9]+"
}
-->
<!--
common.data.percent =
xsd:string {
pattern = "(100)|([1-9]?[0-9](\.[0-9]+)?)%"
}
-->
<define name="common.data.float">
<data type="float"/>
</define>
<!--
xsd:string {
pattern = "-?[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?"
}
-->
<define name="common.data.float.positive">
<data type="float"/>
</define>
<!--
xsd:string {
pattern = "(0*[1-9][0-9]*(\.[0-9]+)?)|([0-9]+(\.0*[1-9][0-9]*)?)([eE]-?[0-9]+)?"
}
-->
<define name="common.data.float.non-negative">
<data type="float"/>
</define>
<!--
xsd:string {
pattern = "[0-9]+(\.[0-9]+)?([eE]-?[0-9]+)?"
}
-->
<define name="common.data.datetime">
<a:documentation>Temporal</a:documentation>
<data type="dateTime"/>
</define>
<define name="common.data.date-or-time">
<data type="date"/>
</define>
<define name="common.data.uri">
<a:documentation>IRIs</a:documentation>
<choice>
<value type="string"/>
<data type="anyURI"/>
</choice>
</define>
<define name="common.data.uris">
<list>
<zeroOrMore>
<data type="anyURI"/>
</zeroOrMore>
</list>
</define>
<define name="common.data.uri.absolute">
<data type="anyURI"/>
</define>
<define name="common.data.sizes">
<a:documentation>&lt;link type='icon'&gt; sizes</a:documentation>
<!-- list { w:sizes } -->
<list>
<oneOrMore>
<data type="string">
<param name="pattern">[1-9][0-9]*x[1-9][0-9]*</param>
</data>
</oneOrMore>
</list>
</define>
<define name="common.data.mimetype">
<a:documentation>MIME types</a:documentation>
<data type="string"/>
</define>
<define name="common.data.charset">
<a:documentation>Encodings</a:documentation>
<data type="string"/>
</define>
<define name="common.data.meta-charset">
<data type="string"/>
</define>
<define name="common.data.refresh">
<a:documentation>Refresh</a:documentation>
<data type="string"/>
</define>
<define name="common.data.default-style">
<a:documentation>Default style</a:documentation>
<data type="string" datatypeLibrary=""/>
</define>
<!-- w:default-style -->
<define name="common.data.mediaquery">
<a:documentation>Media Queries</a:documentation>
<data type="string"/>
</define>
<define name="common.data.langcode">
<a:documentation>Language Codes</a:documentation>
<choice>
<value type="string"/>
<data type="language"/>
</choice>
</define>
<define name="common.data.keylabellist">
<a:documentation>List of Key Labels</a:documentation>
<data type="anyType"/>
</define>
<define name="common.data.microdata-identifier">
<a:documentation>Microdata Identifier</a:documentation>
<data type="string"/>
</define>
<define name="common.data.zero">
<a:documentation>Zero</a:documentation>
<data type="anyType"/>
</define>
<!-- ##################################################################### -->
<!-- ##################################################################### -->
<define name="common-form.attrs.form">
<a:documentation> WF2 Module Hook #</a:documentation>
<notAllowed/>
</define>
<!-- ##################################################################### -->
<!-- ##################################################################### -->
<define name="common.attrs.aria">
<a:documentation> ARIA Module Hooks #</a:documentation>
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.button">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.input">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.region">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.group">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.th">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.structure">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.link">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.listitem">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.img">
<notAllowed/>
</define>
<define name="common.attrs.aria.implicit.select">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.application">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.banner">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.complementary">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.contentinfo">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.main">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.navigation">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.search">
<notAllowed/>
</define>
<!-- per ARIA spec: article, document, and note are not actually landmarks -->
<define name="common.attrs.aria.landmark.article">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.document">
<notAllowed/>
</define>
<define name="common.attrs.aria.landmark.note">
<notAllowed/>
</define>
</grammar>