<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE grammar SYSTEM "relaxng.dtd">
<grammar ns="http://www.w3.org/1999/xhtml" xml:lang="en"
         xmlns="http://relaxng.org/ns/structure/1.0"
         xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

  <a:documentation>
    Experimental RELAX NG schema for XHTML's some head stuff

      Allow XHTML's 'link', 'script' and 'style' elements to be imported
      into other schema

    $Id: xhtml-head.rng,v 1.1 2003/03/28 08:06:10 mimasa Exp $
  </a:documentation>

  <start>
    <choice>
      <ref name="link"/>
      <ref name="script"/>
      <ref name="style"/>
    </choice>
  </start>

  <a:documentation>
    ================== Imported Names ====================================
  </a:documentation>

  <define name="ContentType">
    <a:documentation>
      media type, as per [RFC2045]
    </a:documentation>
    <data type="string"/>
  </define>

  <define name="Charset">
    <a:documentation>
      a character encoding, as per [RFC2045]
    </a:documentation>
    <data type="string"/>
  </define>

  <define name="LanguageCode">
    <a:documentation>
      a language code, as per [RFC3066]
    </a:documentation>
    <data type="language"/>
  </define>

  <define name="LinkTypes">
    <a:documentation>
      space-separated list of link types
    </a:documentation>
    <data type="NMTOKENS"/>
  </define>

  <define name="MediaDesc">
    <a:documentation>
      single or comma-separated list of media descriptors
    </a:documentation>
    <data type="string">
      <param name="pattern">[^,]+(,\s*[^,]+)*</param>
    </data>
  </define>

  <define name="URI">
    <a:documentation>
      a Uniform Resource Identifier, see [RFC2396]
    </a:documentation>
    <data type="anyURI"/>
  </define>

  <define name="Script">
    <a:documentation>
      script expression
    </a:documentation>
    <text/>
  </define>

  <define name="StyleSheet">
    <a:documentation>
      style sheet data
    </a:documentation>
    <text/>
  </define>

  <define name="Text">
    <a:documentation>
      used for titles etc.
    </a:documentation>
    <text/>
  </define>

  <a:documentation>
   =================== Generic Attributes ===============================
  </a:documentation>

  <define name="coreattrs">
    <a:documentation>
      core attributes common to most elements
      id       document-wide unique id
      class    space separated list of classes
      style    associated style info
      title    advisory title/amplification
    </a:documentation>
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="class">
        <data type="NMTOKENS"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="style">
        <ref name="StyleSheet"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="title">
        <ref name="Text"/>
      </attribute>
    </optional>
  </define>

  <define name="i18n">
    <a:documentation>
      internationalization attributes
      lang        language code (backwards compatible)
      xml:lang    language code (as per XML 1.0 spec)
      dir         direction for weak/neutral text
    </a:documentation>
    <optional>
      <attribute name="lang">
        <ref name="LanguageCode"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="xml:lang">
        <ref name="LanguageCode"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="dir">
        <choice>
          <value>ltr</value>
          <value>rtl</value>
        </choice>
      </attribute>
    </optional>
  </define>

  <define name="events">
    <a:documentation>
     attributes for common UI events
     onclick     a pointer button was clicked
     ondblclick  a pointer button was double clicked
     onmousedown a pointer button was pressed down
     onmouseup   a pointer button was released
     onmousemove a pointer was moved onto the element
     onmouseout  a pointer was moved away from the element
     onkeypress  a key was pressed and released
     onkeydown   a key was pressed down
     onkeyup     a key was released
    </a:documentation>
    <optional>
      <attribute name="onclick">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="ondblclick">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onmousedown">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onmouseup">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onmouseover">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onmousemove">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onmouseout">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onkeypress">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onkeydown">
        <ref name="Script"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="onkeyup">
        <ref name="Script"/>
      </attribute>
    </optional>
  </define>

  <define name="attrs">
    <ref name="coreattrs"/>
    <ref name="i18n"/>
    <ref name="events"/>
  </define>

  <a:documentation>
    ================ Document Head =======================================
  </a:documentation>

  <define name="head.misc">
    <zeroOrMore>
      <choice>
        <ref name="script"/>
        <ref name="style"/>
        <ref name="link"/>
      </choice>
    </zeroOrMore>
  </define>

  <define name="title">
    <element name="title">
      <ref name="title.attlist"/>
      <text/>
    </element>
  </define>

  <define name="title.attlist" combine="interleave">
    <ref name="i18n"/>
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
  </define>

  <define name="link">
    <element name="link">
      <ref name="link.attlist"/>
      <empty/>
    </element>
  </define>

  <define name="link.attlist" combine="interleave">
    <ref name="attrs"/>
    <optional>
      <attribute name="charset">
        <ref name="Charset"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="href">
        <ref name="URI"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="hreflang">
        <ref name="LanguageCode"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="type">
        <ref name="ContentType"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="rel">
        <ref name="LinkTypes"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="rev">
        <ref name="LinkTypes"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="media">
        <ref name="MediaDesc"/>
      </attribute>
    </optional>
  </define>

  <define name="style">
    <element name="style">
      <ref name="style.attlist"/>
      <text/>
    </element>
  </define>

  <define name="style.attlist" combine="interleave">
    <ref name="i18n"/>
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <attribute name="type">
      <ref name="ContentType"/>
    </attribute>
    <optional>
      <attribute name="media">
        <ref name="MediaDesc"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="title">
        <ref name="Text"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="xml:space" a:defaultValue="preserve">
        <value>preserve</value>
      </attribute>
    </optional>
  </define>

  <define name="script">
    <element name="script">
      <ref name="script.attlist"/>
      <text/>
    </element>
  </define>

  <define name="script.attlist" combine="interleave">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="charset">
        <ref name="Charset"/>
      </attribute>
    </optional>
    <attribute name="type">
      <ref name="ContentType"/>
    </attribute>
    <optional>
      <attribute name="src">
        <ref name="URI"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="defer">
        <choice>
          <value>defer</value>
        </choice>
      </attribute>
    </optional>
    <optional>
      <attribute name="xml:space" a:defaultValue="preserve">
        <value>preserve</value>
      </attribute>
    </optional>
  </define>

</grammar>
