O'Reilly logo

XMPP: The Definitive Guide by Remko Tronçon, Kevin Smith, Peter Saint-Andre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required