Chapter 6. Data Forms

The World Wide Web started out as a way to publish physics papers, and only later gained transactional capabilities, such as electronic commerce. One of the key building blocks that enabled this transition was the HTML <FORM> tag, which made it possible for a website to offer an empty, but structured, form to the user and for the user to submit a completed form to the website.

XMPP includes a very similar technology for lightweight workflows called Data Forms, defined in XEP-0004. Because Data Forms are used throughout the technologies we’ll discuss in the following chapters, we introduce them now. In Chapter 11, we build on these basic concepts to explore more advanced workflows.

Basic Structure

A data form is made up of several pieces, as shown in the following “stub” example:

<message from="sender@wonderland.lit/foo" to="receiver@wonderland.lit/bar"> <x xmlns="jabber:x:data" type="form"> <title>My Special Form</title> <instructions>Please fill in the following form</instructions> <field label="Text Input" type="text-single" var="field-1"/> <field label="Make a Choice" type="boolean" var="field-2"/> <field label="For Your Eyes Only" type="text-private" var="field-3"/> <field label="Pick One" type="list-single" var="field-4"> <option label="First Option"><value>single-1</value></option> <option label="Second Option"><value>single-2</value></option> <option label="Third Option"><value>single-3</value></option> </field> <field label="Pick a Few" type="list-multi" ...

Get XMPP: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.