<?xml version="1.0" encoding="iso-8859-1"?>

<!-- file: xhtml-basic-form-1.rng

     This is XHTML, a reformulation of HTML as a modular XML application.
     Copyright 1998-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved.
     Revision: $Id: xhtml-basic-form-1.rng,v 1.1 2010/12/12 23:24:10 smccarro Exp $

     This RelaxNG module is identified by URI:
        
        http://www.w3.org/MarkUp/RELAXNG/xhtml-basic-form-1.rng
     .................................................................... -->
<!-- Simplified Forms Module -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

<define name="xhtml.form">
  <element name="form">
    <ref name="xhtml.form.attlist"/>
    <!-- Don't use Block.model, because this gets redefined by the
	 legacy module. -->
    <oneOrMore>
      <ref name="xhtml.Block.class"/>
    </oneOrMore>
  </element>
</define>

<define name="xhtml.form.attlist">
  <ref name="xhtml.Common.attrib"/>
  <attribute name="action">
    <ref name="xhtml.URI.datatype"/>
  </attribute>
  <optional>
    <attribute name="method">
      <choice>
	<value>get</value>
	<value>post</value>
      </choice>
    </attribute>
  </optional>
  <optional>
    <attribute name="enctype">
      <ref name="xhtml.ContentType.datatype"/>
    </attribute>
  </optional>
</define>

<define name="xhtml.label">
  <element name="label">
    <ref name="xhtml.label.attlist"/>
    <ref name="xhtml.Inline.model"/>
  </element>
</define>

<define name="xhtml.label.attlist">
  <ref name="xhtml.Common.attrib"/>
  <optional>
    <attribute name="for">
      <data type="IDREF"/>
    </attribute>
  </optional>
  <optional>
    <attribute name="accesskey">
      <ref name="xhtml.Character.datatype"/>
    </attribute>
  </optional>
</define>

<define name="xhtml.input">
  <element name="input">
    <ref name="xhtml.input.attlist"/>
  </element>
</define>

<define name="xhtml.input.attlist">
  <ref name="xhtml.Common.attrib"/>
  <optional>
    <attribute name="type">
      <ref name="xhtml.InputType.class"/>
    </attribute>
  </optional>
  <optional>
    <attribute name="name"/>
  </optional>
  <optional>
    <attribute name="value"/>
  </optional>
  <optional>
    <attribute name="checked">
      <value>checked</value>
    </attribute>
  </optional>
  <optional>
    <attribute name="size"/>
  </optional>
  <optional>
    <attribute name="maxlength">
      <ref name="xhtml.Number.datatype"/>
    </attribute>
  </optional>
  <optional>
    <attribute name="src">
       <ref name="xhtml.URI.datatype"/>
    </attribute>
  </optional>
  <optional>
    <attribute name="accesskey">
      <ref name="xhtml.Character.datatype"/>
    </attribute>
  </optional>
</define>

<define name="xhtml.InputType.class">
  <choice>
    <value>text</value>
    <value>password</value>
    <value>checkbox</value>
    <value>radio</value>
    <value>submit</value>
    <value>reset</value>
    <value>hidden</value>
  </choice>
</define>

<define name="xhtml.select">
  <element name="select">
    <ref name="xhtml.select.attlist"/>
    <oneOrMore>
      <ref name="xhtml.option"/>
    </oneOrMore>
  </element>
</define>

<define name="xhtml.select.attlist">
  <ref name="xhtml.Common.attrib"/>
  <optional>
    <attribute name="name"/>
  </optional>
  <optional>
    <attribute name="size">
      <ref name="xhtml.Number.datatype"/>
    </attribute>
  </optional>
  <optional>
    <attribute name="multiple">
      <value>multiple</value>
    </attribute>
  </optional>
</define>
   
<define name="xhtml.option">
  <element name="option">
    <ref name="xhtml.Common.attrib"/>
    <optional>
      <attribute name="selected">
        <value>selected</value>
      </attribute>
    </optional>
    <optional>
      <attribute name="value"/>
    </optional>
    <text/>
  </element>
</define>

<define name="xhtml.textarea">
  <element name="textarea">
    <ref name="xhtml.textarea.attlist"/>
  </element>
</define>

<define name="xhtml.textarea.attlist">
  <ref name="xhtml.Common.attrib"/>
  <optional>
    <attribute name="name"/>
  </optional>
  <attribute name="rows">
    <ref name="xhtml.Number.datatype"/>
  </attribute>
  <attribute name="cols">
    <ref name="xhtml.Number.datatype"/>
  </attribute>
  <optional>
    <attribute name="accesskey">
      <ref name="xhtml.Character.datatype"/>
    </attribute>
  </optional>
  <text/>
</define>

<define name="xhtml.Form.class">
  <ref name="xhtml.form"/>
</define>

<define name="xhtml.Formctrl.class">
  <choice>
    <ref name="xhtml.input"/>
    <ref name="xhtml.label"/>
    <ref name="xhtml.select"/>
    <ref name="xhtml.textarea"/>
  </choice>
</define>

<define name="xhtml.Block.class" combine="choice">
  <ref name="xhtml.Form.class"/>
</define>

<define name="xhtml.Inline.class" combine="choice">
  <ref name="xhtml.Formctrl.class"/>
</define>

</grammar>

