Appendix C: サンプルフォーム


Contents

C.1 XFormsとXHTML

複数のXFowmsとXHTMLドキュメント - 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>
これは手入力されうる単一ドキュメントの例である。 この例は単純なシンタックスを用いて埋め込まれた、2つの独立したXFormsをもつXHTMLドキュメントを表している。うち1つは一連のインスタンスデータをもつ。
ポーリングのためのサンプルインスタンスデータ
<choiceCode>30</choiceCode>

これはポーリングフォームのためのインスタンスデータのサンプルである。

サイト検索のためのサンプルインスタンスデータ
<query xmlns="http://example.com/ns" searchstring="MP3" />

これはサイト検索フォームのためのインスタンスデータのサンプルである。