<?xml version="1.0"?>
<schema xmlns="http://www.ascc.net/xml/schematron"
        xmlns:x="http://www.w3.org/1999/xhtml">
  <title>Schematron schema for XHTML 1.0</title>

  <ns prefix="x" uri="http://www.w3.org/1999/xhtml"/>

  <p>Author: Masayasu Ishikawa</p>

  <p>CAUTION: This is purely experimental.</p>

  <phase id="normative">
    <active pattern="h-4.10"/>
    <active pattern="B1"/>
    <active pattern="B2"/>
    <active pattern="nohref"/>
    <active pattern="ismap"/>
  </phase>

  <phase id="comatibility">
    <active pattern="h-4.10"/>
    <active pattern="B1"/>
    <active pattern="B2"/>
    <active pattern="nohref"/>
    <active pattern="ismap"/>
    <active pattern="C7"/>
    <active pattern="C8"/>
  </phase>

  <pattern name="The elements with 'id' and 'name' attributes" id="h-4.10"
    see="http://www.w3.org/TR/xhtml1/#h-4.10">

    <rule role="bothid" context="x:a[@name]|x:applet[@name]|x:form[@name]|
      x:frame[@name]|x:iframe[@name]|x:img[@name]|x:map[@name]">
      <assert test="@id and @name">XHTML 1.0 documents MUST use
      the id attribute when defining fragment identifiers. The name
      attribute MAY also be used for backward compatibility.</assert>
    </rule>

  </pattern>

  <pattern name="Element Prohibitions" id="B1"
    see="http://www.w3.org/TR/xhtml1/#prohibitions">

    <rule role="a_nest" context="x:a">
      <report test="ancestor::x:a"
      >The a element MUST NOT contain other a elements.</report>
    </rule>

    <rule role="pre_nest" context="x:img|x:object|x:big|x:small|x:sub|x:sup">
      <report test="ancestor::x:pre"
      >The pre element MUST NOT contain the <name/> element.</report>
    </rule>

    <rule role="label_nest" context="x:label">
      <report test="ancestor::x:label"
      >The label element MUST NOT contain other label elements.</report>
    </rule>

    <rule role="form_nest" context="x:form">
      <report test="ancestor::x:form"
      >The form element MUST NOT contain other form elements.</report>
    </rule>

  </pattern>

  <pattern name="Element Prohibitions" id="B2"
    see="http://www.w3.org/TR/xhtml1/#prohibitions">

    <rule role="button_nest" context="x:input|x:select|x:textarea|x:label|
      x:button|x:form|x:fieldset|x:iframe|x:isindex">
      <report test="ancestor::x:button"
      >The button element MUST NOT contain the <name/> element.</report>
    </rule>

  </pattern>

  <pattern name="Client-side image maps" id="nohref"
    see="http://www.w3.org/TR/html4/struct/objects.html#adef-nohref">

    <rule role="nohref" context="x:area">
      <report test="@href and @nohref">The href and nohref attributes
      on the area element MUST NOT be used at the same time.</report>
    </rule>

  </pattern>

  <pattern name="Server-side image maps" id="ismap"
    see="http://www.w3.org/TR/html4/struct/objects.html#adef-ismap">

    <rule role="ismap" context="x:img[@ismap]">
      <assert test="ancestor::x:a">The img element MUST be inside
      an a element to define a server-side image map.</assert>
    </rule>

  </pattern>

  <pattern name="HTML Compatibility Guidelines, C.7" id="C7"
    see="http://www.w3.org/TR/xhtml1/#C_7">

    <rule role="samelang" context="x:*[@lang][@xml:lang]">
      <report test="@lang != @xml:lang">The value of
      the lang and xml:lang attributes MUST be identical.</report>
    </rule>

    <rule role="bothlang" context="x:*[@lang]">
      <assert test="@lang and @xml:lang">XHTML 1.0 documents SHOULD use
      the xml:lang attribute when specifying the language. The lang
      attribute MAY also be used for backward compatibility.</assert>
    </rule>

  </pattern>

  <pattern name="HTML Compatibility Guidelines, C.8" id="C8"
    see="http://www.w3.org/TR/xhtml1/#C_8">

    <rule role="sameid" context="x:a[@id][@name]|x:applet[@id][@name]|
      x:form[@id][@name]|x:frame[@id][@name]|x:iframe[@id][@name]|
      x:img[@id][@name]|x:map[@id][@name]">
      <report test="@id != @name">The value of
      the id and name attributes MUST be identical.</report>
    </rule>

  </pattern>

</schema>

