XForms Submission: Transmitting XML to a Server

This article provides a comprehensive overview of how the XForms <submission> element handles the transmission of instance XML data to a web server. It details the core attributes governing the transmission, the serialization and validation processes, the underlying HTTP transport mechanics, and how server responses are managed within the XForms processing model.

The Role of the Submission Element

In XForms, the <submission> element acts as the communication pipeline between the client-side form interface and the server-side architecture. Unlike standard HTML forms that typically flatten form data into URL-encoded key-value pairs, XForms preserves the rich, hierarchical structure of XML data throughout the entire transmission lifecycle.

Core Configuration Attributes

The behavior of the transmission is configured using several primary attributes defined within the <submission> element:

The Transmission Process

The process of sending XML data via an XForms submission follows a strict, event-driven pipeline:

  1. Invocation: The submission is initiated either automatically through an internal form event or explicitly via user interaction, such as clicking a <submit> control linked to the submission’s identifier.
  2. Data Selection and Validation: The XForms processor resolves the ref attribute to locate the target XML nodes. Before serialization, it evaluates all data constraints, such as required fields, data types, and custom validation rules defined in the <bind> elements. If validation fails, the submission halts, and an xforms-submit-error event is dispatched.
  3. Serialization: Once validated, the selected in-memory XML DOM structure is serialized into an XML text stream. Standard XML declarations and character encodings (typically UTF-8) are applied.
  4. HTTP Request Execution: The processor constructs an HTTP request targeting the designated URI. It sets the Content-Type header (usually to application/xml; charset=UTF-8) and writes the serialized XML stream directly into the HTTP request body.
  5. Response Handling: The server processes the XML payload and returns an HTTP status code along with any response data. Upon receiving a successful status code (such as 200 OK), the processor dispatches an xforms-submit-done event and applies the behavior specified by the replace attribute. If the server returns an error code (such as 4xx or 5xx), an xforms-submit-error event is triggered to allow error handling within the form.