4 Using XForms with Other Document Types


Contents

This chapter is normative.

4.1 XForms Elements

XForms have been designed for use within other XML vocabularies, in particular XHTML. This chapter discusses some of the high-level features of XForms that allow it to be used with other document types.

Note: This document uses the convention of an xfm: prefix to represent elements and attributes that are part of the XForms Namespace. The unique, persistent namespace identifier used in this document is http://www.w3.org/2000/12/xforms. Future revisions are expected to use a different identifier.

The <xform> element is used as a container for other XForms elements, namely, <model>, <instance>, <submit> and <bind>. It can serve as a convenient place to declare the XForms namespace. It has one optional attribute, id of type xsd:ID.

4.1.1 Model

The <model> element is used to define the XForms Model. An optional id attribute of type xsd:ID is allowed. An element href of type xsd:uriReference is allowed, providing a link to an externally defined XForms Model.

[Ed. We are actively investigating the potential of using XLink simple links within XForms.]

The content of the <model> element is restricted to either XML Schema content, or XForms simple syntax. Schema content must be enclosed in the <xsd:schema> element, defined in [XSchema-1]. Simple syntax must be enclosed in the <simple> element. The content of <simple> is defined in the XForms Model chapter.

[Ed. Need to define behavior if both an inline XForms Model and an external model are used together.]

4.1.2 Instance

The <instance> element is used to define initial instance data. An optional id attribute of type xsd:ID is allowed. An attribute href of type xsd:uriReference is allowed, providing a link to externally defined instance data. An attribute model of type xsd:IDREF connects the instance data to a specific XForms Model.

The content of the <instance> element is arbitrary XML in any namespace. Authors must ensure that proper namespace declarations are used for content within the <instance> element.

[Ed. We are also considering whether a schemaLocation attribute is needed here.]

4.1.3 Submit

The <submit> element provides information on how and where to submit the instance data. An optional id attribute of type xsd:ID is allowed. A required target attribute of type xsd:uriReference provides the submit location. An optional method attribute of type xsd:string provides the submit method. For HTTP, the default is POST.

The content of the <submit> element is empty.

4.1.4 Bind

The <bind> element is the connection between the different parts of XForms. The syntax and contents of this element are defined in the Binding chapter.

4.1.5 Example

<xform xmlns="http://www.w3.org/2000/12/xforms">
   <model id="Person-model" href="Schema-Questionaire.xfm" />
   <instance model="Person-model" id="p0"
        href="URL-to-retrieve-defaults" /> 
   ...
</xform>

Alternatively, the instance data can be included in the containing document:

<xform xmlns="http://www.w3.org/2000/12/xforms">
   <model id="Person-model" href="Schema-Questionaire.xfm" />
   <instance model="Person-model" id="p0" xmlns="inst-ns"> 
      <person>
      ...
      </person>
   </instance>
   ...
</xform>