Appendix C: Sample Forms


Contents

C.1 XForms and XHTML

XHTML Document with Multiple XForms - Page.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xml:lang="en" lang="en" 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
  xmlns:xform="http://www.w3.org/2001/02/xforms">

<head>
  <title>Sample XForms Document</title>

  <xform xmlns="http://www.w3.org/2001/02/xforms" id="poll">
    <submitInfo target="http://example.com/app1" />
    <model>
      <simple>
        <number name="choiceCode" enum="closed">
          <value>-1</value>
          <value>10</value>
          <value>20</value>
          <value>30</value>
        </number>
      </simple>
    </model>
  </xform>

  <xform xmlns="http://www.w3.org/2001/02/xforms" id="search">
    <submitInfo target="http://example.com/app2" />
    <bind id="Query" ref="/query/searchstring"/>
    <model>
      <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
        <element name="query">
          <complexType>
            <attribute name="searchstring" type="string" />
          </complexType>
        <element>
      <schema>
    </model>
    <instance model="search" xmlns="http://example.org/ns">
      <query searchstring="Enter your Query Here" />
    </instance>
  </xform>
</head>

<body>
  <!-- ... -->

  <!-- Site Search Markup -->
  <xform:textbox ref="id('Query')">
    <xform:caption>Search our Web Site<xform:caption>
    <xform:help>Enter your search term here and hit "Go!"</xform:help>
  </xform:textbox>
  <xform:submit xform="search">
    <xform:caption>Go!</xform:caption>
  </xform:submit>  

  <!-- ... -->

  <!-- Daily Poll Markup -->
  <xform:exclusiveSelect style="list-ui: radio" xform="poll"
                ref="choiceCode">
    <xform:caption>When do you plan to implement XForms?</xform:caption>
    <xform:item value="-1">Don't know</xform:item>
    <xform:item value="10">0-6 Months</xform:item>
    <xform:item value="20">6-12 Months</xform:item>
    <xform:item value="30">More than 12 Months</xform:item>
  </xform:exclusiveSelect>
  <xform:submit xform="poll">
    <xform:caption>Submit</xform:caption>
  </xform:submit>

  <!-- ... -->

</body>
</html>
This is an example of a single document that might be hand authored. This example shows an XHTML document with two separate XForms embedded using simple syntax, one with a set of initial instance data.
Sample Instance Data for Poll
<choiceCode>30</choiceCode>

Here is a sample of the instance data for the Poll form.

Sample Instance Data for Site Search
<query xmlns="http://example.com/ns" searchstring="MP3" />

Here is a sample of the instance data for Site Search form.