3 Document Structure

The XForms specification is an application of XML [XML 1.0] and has been designed for use within other XML vocabularies—in particular within XHTML [XHTML 1.0]. This chapter discusses the structure of XForms that allow this specification to be used with other document types.

3.1 The XForms Namespace

The XForms namespace has the URI: http://www.w3.org/2002/01/xforms. Any future Working Drafts are expected to use a different identifier, though a final identifier will be allocated before XForms becomes a W3C Recommendation.

XForms Processors must use the XML namespaces mechanism [XML Names] to recognize elements and attributes from this namespace.

3.2 Horizontally Applicable Markup

Every element defined in this specification declares attribute id of type xsd:ID—see the schema for XForms—this allows these elements to be referenced via attributes of type xsd:idref.

The XForms Processor must ignore any foreign-namespaced elements or attributes that are unrecognized.

Note that except where specifically allowed by the Schema for XForms, foreign-namespaced elements are not allowed as content of elements in the XForms namespace.

3.3 Model

This section describes XForms element model used as a container for XForms elements defining the XForms model. The containing document may contain one or more model elements. Element model defines the underlying model to which the XForms document binds user interaction. Hence, model elements occur before the user interaction markup. The content of element model is typically not rendered. As an example, model elements occur within element html:head of an XHTML document, whereas XForms user interface markup appears within element html:body.

XML Representation: <model>
<model
  extensionFunctions = list of QNames
>
  <!-- Content: instance?, schema?, (privacy|submitInfo|bind|action|extension)* -->
</model>

extensionFunctions - Optional list of XPath extension functions used by this XForms Model. It is an error to use an undeclared extension function.

Element model can contain the following elements.

Instance

Defines skeleton instance document and holds initialization data if any—see 3.4 instance.

Schema

Defines schema for the instance—see 3.5 schema

submitInfo

Holds submit details—see 3.6 submitInfo

Bindings

Elements bind that establish one or more XForms bindings to define model item constraints—see 6 Constraints.

Privacy

Establishes P3P properties—see 3.7 privacy

Action

Event handlers—see 10.16 action. This allows the author to handle events that arrive at node model—see the processing model 4 Processing Model.

Extension

Extension elements if any—see 8.12.4.5 extension

Model
<model xmlns="http://www.w3.org/2002/01/xforms" id="Person">
   <instance xlink:href="http://example.com/cgi-bin/get-instance" /> 
   <schema xlink:href="Schema-Questionnaire.xsd" />
   ...
</model>

3.4 instance

Element instance contains a skeleton instance document that provides initial instance data. The instance data may be defined inline or obtained from an external URI.

XML Representation: <instance>
<instance xlink:href = xsd:anyURI >
  <!-- Content: (##any) -->
</instance>

xlink:href - Optional link to externally defined instance data

The content of the instance element is arbitrary XML in any namespace. The content of this element is treated as opaque data. Authors must ensure that proper namespace declarations are used for content within the instance element.

3.5 schema

Element schema contains the schema defining the instance. The schema may be defined inline or obtained from an external URI.

XML Representation: <schema>
<schema xlink:href = xsd:anyURI >
  <!-- Content: ##other (though typically <xsd:schema>) -->
</schema>

xlink:href - Optional link to an externally defined schema.

3.6 submitInfo

Element submitInfo encodes how, where and what to submit.

XML Representation: <submitInfo>
<submitInfo
  (single node binding attributes)
  action = xsd:anyURI
  mediaTypeExtension = "none" | qname-but-not-ncname : "none"
  method = "post" | "get" | qname-but-not-ncname : "post"
  version = xsd:NMTOKEN
  indent = xsd:boolean
  encoding = xsd:string
  mediaType = xsd:string
  omitXMLDeclaration = xsd:boolean
  standalone = xsd:boolean
  CDATASectionElements = list of xsd:QName
  replace = "all" | "instance" | "none" | qname-but-not-ncname : "all"
>
  <!-- Content: XForms Actions -->
</submitInfo>

single node binding attributes - optional selector enabling submission of a portion of the instance data
action - Required destination for submitting instance data.
mediaTypeExtension - Optional information describing the serialization format. This is in addition to the mediaType.
method - Optional indicator as to the protocol to be used to transmit the serialized instance data.
version - corresponds to the version attribute of xsl:output
indent - corresponds to the indent attribute of xsl:output
encoding - corresponds to the encoding attribute of xsl:output
mediaType - corresponds to the media-type attribute of xsl:output
omitXMLDeclaration - corresponds to the omit-xml-declaration attribute of xsl:output
standalone - corresponds to the standalone attribute of xsl:output
CDATASectionElements - corresponds to the cdata-section-elements attribute of xsl:output
replace - specifier for how the information returned after submit should be applied.

Note:

Many of these attributes correspond to XSLT attributes [XSLT]. Note that the XSLT attributes doctype-system and doctype-public are not supported in XForms processing.

Note:

Note also that attribute mediaTypeExtension is useful in cases where a media type alone is not sufficiently precise. For instance, a SOAP envelope would not be adequately described simply by "text/xml", additional information would be required.

3.7 privacy

Element privacy is used to associate a P3P [P3P 1.0] policy reference with a particular form.

XML Representation: <privacy>
<privacy
  xlink:href = xsd:anyURI
>
  <!-- Content: (##empty) -->
</privacy>

xlink:href - Optional link to an externally defined P3P policyref file (not an actual policy).

3.8 XForms and XLink

XForms uses XLink [XLink] for linking and for defining an explicit relationship between resources that may be either local or remote. To this end, the XForms schema references the XLink namespace with sensible defaults. Other than in the case of attribute xlink:href, form authors will not be required to explicitly write XLink-specific elements or attributes.

All XLinks in XForms are simple links. For further details, see 3.8.1 XLink Conformance and Examples.

3.8.1 XLink Conformance and Examples

An XForms processor is not required to implement full XLink—correct behavior of the xlink:href attribute (as defined in this chapter) is sufficient. For example, an XForms Processor must accept and correctly process the schema in both of the following:

External schema constraints
<xforms:model>
  <xforms:schema xlink:href="URI-to-remote-schema.xsd" />
</xforms:model>
Inline schema constraints
<xforms:model>
  <xforms:schema>
    <xsd:schema ...>
      <!-- Content: ... -->
    </xsd:schema>
  </xforms:schema>
</xforms:model>

This second example is unusual in that the xforms:schema element defaults an attribute xlink:type="simple" but lacks an xlink:href attribute to make the link meaningful. In this situation, the XForms Processor should switch from simple mode to none mode for the element lacking attribute xlink:href. For compatibility with XLink, the second example should be explicitly authored as follows:

Inline schema constraints, with explicit xlink:type
<xforms:model>
  <xforms:schema xlink:type="none">
    <xsd:schema...>
      <!-- Content: ... -->
    </xsd:schema>
  </xforms:schema>
</xforms:model>

Notice the explicit override of the xlink:type attribute.

If both inline content and external reference is provided, a processor must use the external reference and ignore the inline content.