XEP-0141: Data Forms Layout

Abstract
This specification defines a backwards-compatible extension to the XMPP Data Forms protocol that enables an application to specify form layouts, including the layout of form fields, sections within pages, and subsections within sections.
Author
Matthew Miller
Copyright
© 1999 – 2020 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Draft

NOTICE: The protocol defined herein is a Draft Standard of the XMPP Standards Foundation. Implementations are encouraged and the protocol is appropriate for deployment in production systems, but some changes to the protocol are possible before it becomes a Final Standard.
Type
Standards Track
Version
1.0 (2005-05-12)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Draft
  4. Final

1. Introduction

Data Forms (XEP-0004) [1] ("x:data") provides a simple and interoperable way to request and present information for both applications and humans. However, the simple nature of "x:data" requires the form renderer to use a generic "key/value" format. This document builds upon "x:data" to enable applications to specify additional layout information.

2. Requirements

The requirements for this document are:

3. Use Cases

This document defines a new namespace, "http://jabber.org/protocol/xdata-layout". All layout is defined by "pages" and "sections".

All of the use cases refer to the following form:

Example 1. Sample form
<x xmlns='jabber:x:data' type='form'>
  <title>XSF Application</title>
  <instructions>Please fill out this form</instructions>

  <field var='name.first' type='text-single' label='First Name'>
    <required/>
  </field>
  <field var='name.last' type='text-single' label='Last Name'>
    <required/>
  </field>
  <field var='email' type='text-single' label='E-mail Address'>
    <required/>
  </field>
  <field var='jid' type='jid-single' label='Jabber JID'>
    <required/>
  </field>

  <field var='background' type='text-multi' label='Background Information'>
  </field>
  <field var='future' type='text-multi' label='Jabber Plans for the Next Six Months'>
  </field>
  <field var='reasoning' type='text-multi' label='Reasons for Joining'>
  </field>

  <field var='activity.mailing-lists' type='text-multi' label='Recent Mailing List Activity'>
  </field>
  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>
  </field>
</x>

Note: Any newlines in the following examples are provided for the purpose of legibility only.

3.1 Paging Fields

One of the simplest layout usages is to partition fields into pages. This is done by including one or more <page/> elements within the x:data form. Each <page/> element SHOULD possess a "label" attribute to label the page, MAY contain a <text/> child element for additional information, and SHOULD contain a <fieldref/> element for each field to be included in the page. To reference an x:data field, the <fieldref/> element's "var" attribute MUST be the same as the intended <field/> element's "var" attribute.

Example 2. Pages of fields
<x xmlns='jabber:x:data' type='form'>
  <title>XSF Application</title>
  <instructions>Please fill out this form</instructions>
  <page xmlns='http://jabber.org/protocol/xdata-layout' label='Personal Information'>
    <text>This is page one of three.</text>
    <text>
      Note: In accordance with the XSF privacy policy, your personal information will
      never be shared outside the organization in any way for any purpose; however,
      your name and JID may be published in the XSF membership directory.
    </text>
    <fieldref var='name.first'/>
    <fieldref var='name.last'/>
    <fieldref var='email'/>
    <fieldref var='jid'/>
    <fieldref var='background'/>
  </page>
  <page xmlns='http://jabber.org/protocol/xdata-layout' label='Community Activity'>
    <text>This is page two of three.</text>
    <text>
      We use this page to gather information about any XEPs you&apos;ve worked on,
      as well as your mailing list activity.
    </text>
    <text>You do post to the mailing lists, don't you?</text>
    <fieldref var='activity.mailing-lists'/>
    <fieldref var='activity.xeps'/>
  </page>
  <page xmlns='http://jabber.org/protocol/xdata-layout' label='Plans and Reasonings'>
    <text>This is page three of three.</text>
    <text>You're almost done!</text>
    <text>
      This is where you describe your future plans and why you think you
      deserve to be a member of the XMPP Standards Foundation.
    </text>
    <fieldref var='future'/>
    <fieldref var='reasoning'/>
  </page>
  <field var='name.first' type='text-single' label='First Name'>
    <required/>
  </field>
  <field var='name.last' type='text-single' label='Last Name'>
    <required/>
  </field>
  <field var='email' type='text-single' label='E-mail Address'>
    <required/>
  </field>
  <field var='jid' type='jid-single' label='Jabber JID'>
    <required/>
  </field>
  <field var='background' type='text-multi' label='Background Information'>
  </field>
  <field var='future' type='text-multi' label='Jabber Plans for the Next Six Months'>
  </field>
  <field var='reasoning' type='text-multi' label='Reasons for Joining'>
  </field>
  <field var='activity.mailing-lists' type='text-multi' label='Recent Mailing List Activity'>
  </field>
  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>
  </field>
</x>

Note: The preceding example partitions the fields into three pages, labeled "Personal Information", "Community Activity", and "Plans and Reasonings".

3.2 Sectioning Fields

The next usage of layout is to partition pages into sections. This is done by including one or more <section/> elements within each <page/> element. Each <section/> element SHOULD possess a "label" attribute to identify the section, MAY contain a <text/> child element for additional information, and SHOULD contain a <fieldref/> element for each field to be included in the section. A <section/> element MUST contain at least one <fieldref/> element or <reportedref/> element. To reference an x:data field, the <fieldref/> element's "var" attribute MUST be the same as the intended <field/> element's "var" attribute.

Example 3. Sections of fields
<x xmlns='jabber:x:data' type='form'>
  <title>XSF Application</title>
  <instructions>Please fill out this form</instructions>
  <page xmlns='http://jabber.org/protocol/xdata-layout'>
    <section label='Personal Information'>
      <text>
        Note: In accordance with the XSF privacy policy, your personal information will
        never be shared outside the organization in any way for any purpose; however,
        your name and JID may be published in the XSF membership directory.
      </text>
      <fieldref var='name.first'/>
      <fieldref var='name.last'/>
      <fieldref var='email'/>
      <fieldref var='jid'/>
      <fieldref var='background'/>
    </section>
    <section label='Community Activity'>
      <text>
        We use this page to gather information about any XEPs you&apos;ve worked on,
        as well as your mailing list activity.
      </text>
      <text>You do post to the mailing lists, don't you?</text>
      <fieldref var='activity.mailing-lists'/>
      <fieldref var='activity.xeps'/>
    </section>
    <section label='Plans and Reasoning'>
      <text>You're almost done!</text>
      <text>
        This is where you describe your future plans and why you think you
        deserve to be a member of the XMPP Standards Foundation.
      </text>
      <fieldref var='future'/>
      <fieldref var='reasoning'/>
    </section>
  </page>
  <field var='name.first' type='text-single' label='First Name'>
    <required/>
  </field>
  <field var='name.last' type='text-single' label='Last Name'>
    <required/>
  </field>
  <field var='email' type='text-single' label='E-mail Address'>
    <required/>
  </field>
  <field var='jid' type='jid-single' label='Jabber JID'>
    <required/>
  </field>
  <field var='background' type='text-multi' label='Background Information'>
  </field>
  <field var='future' type='text-multi' label='Jabber Plans for the Next Six Months'>
  </field>
  <field var='reasoning' type='text-multi' label='Reasons for Joining'>
  </field>
  <field var='activity.mailing-lists' type='text-multi' label='Recent Mailing List Activity'>
  </field>
  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>
  </field>
</x>

Note: The preceding example demonstrates a layout similar to the previous example, but using three sections within one page instead of three pages.

As shown in the following example, sections may be nested to produce a more granular partitioning of fields.

Example 4. Sections of fields (nested)
<x xmlns='jabber:x:data' type='form'>
  ...

  <page xmlns='http://jabber.org/protocol/xdata-layout'>
    <section label='Personal Information'>
      <text>
        Note: In accordance with the XSF privacy policy, your personal information will
        never be shared outside the organization in any way for any purpose; however,
        your name and JID may be published in the XSF membership directory.
      </text>
      <section label='Name'>
        <text>Who are you?</text>
        <fieldref var='name.first'/>
        <fieldref var='name.last'/>
      </section>
      <section label='Contact Information'>
        <text>How can we contact you?</text>
        <fieldref var='email'/>
        <fieldref var='jid'/>
      </section>
      <fieldref var='background'/>
    </section>
    <section label='Community Activity'>
      <text>
        We use this page to gather information about any XEPs you&apos;ve worked on,
        as well as your mailing list activity.
      </text>
      <text>You do post to the mailing lists, don't you?</text>
      <fieldref var='activity.mailing-lists'/>
      <fieldref var='activity.xeps'/>
    </section>
    <section label='Plans and Reasoning'>
      <text>
        This is where you describe your future plans and why you think you
        deserve to be a member of the XMPP Standards Foundation.
      </text>
      <fieldref var='future'/>
      <fieldref var='reasoning'/>
    </section>
  </page>

  ...
</x>

Note: The preceding example partitions the fields into one page and three sections, with the first section being further partitioned into two sub-sections and one free-standing field reference.

3.3 Including Tables

Data forms tables (the <reported/> and <item/> elements) can also be included in the layout, using the <reportedref/> element. This element MAY be included anywhere that the <fieldref/> element is allowed, but MUST NOT appear more than once.

If a <reportedref/> element is specified when no <reported/> element is included, then the reference MUST be ignored.

4. Business Rules

4.1 Discovery

Form providers MAY attempt to discover if the recipient of a form supports the data forms layout protocol extension, although implementations are not required to do so. If implemented, Discovery MUST be implemened as defined in Service Discovery (XEP-0030) [2], using the namespace "http://jabber.org/protocol/xdata-layout" as a feature.

4.2 Field Distribution

In order to prevent the processing from becoming too complex, there are some restrictions in how fields are distributed within the layout.

First, all displayable, modifiable fields (e.g. all except fields of type "FIXED" or "HIDDEN") SHOULD be referenced by a page or section. Any that are not referenced MAY remain unrendered, although implementations MAY provide some support for this. To include a "FIXED" field in the layout, it MUST possess a "var" attribute.

Second, the same field SHOULD NOT be referenced by more than one page or section. Additionally, a field SHOULD NOT be referenced by the same page or section more than once.

Finally, the order of layout elements SHOULD be maintained. Pages SHOULD be rendered in the order they are defined within the x:data form, and sections and fields SHOULD be rendered in the order they are defined or referenced within a page or section.

4.3 Page Labels and Descriptions

The "label" attribute of the <page/> element is RECOMMENDED (although not required). If it is missing, the renderer MAY display whatever it deems appropriate (including nothing or character data of the containing form's <title/> element).

The <text/> child element of the <page/> element is OPTIONAL. If it is missing, the renderer MAY display whatever it deems appropriate (including nothing or character data of the containing form's <instructions/> element).

4.4 Section Labels and Descriptions

The "label" attribute of the <section/> element RECOMMENDED (but not required). If it is missing, the renderer MAY use whatever it deems appropriate (including nothing).

The <text/> child element of the <section/> element is OPTIONAL. If it is missing, the renderer MAY use whatever it deems appropriate (including nothing).

4.5 Internationalization/Localization

This document relies on the internationalization/localization mechanisms provided by XMPP Core [3]. Specifically, labels and descriptions MUST be appropriate for the locale indicated by the containing stanza or <form/> element.

5. Security Considerations

There are no security considerations introduced by this document.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [4].

7. XMPP Registrar Considerations

7.1 Protocol Namespaces

The XMPP Registrar [5] includes 'http://jabber.org/protocol/xdata-layout' in its registry of protocol namespaces.

8. Formal Definition

8.1 <page/> Root Element

The <page/> element is the root layout element for "http://jabber.org/protocol/xdata-layout" namespace. One <page/> elements is contained within the <x xmlns='jabber:x:data'/> element for each page to be rendered. The <page/> element MAY possess an attribute that specifies a natural-language label for the page, and MAY contain child elements specifying a description, sections of the page, and field and table references.

The 'label' attribute specifies the label for this page. This attribute is OPTIONAL. Its value is any string.

8.2 <section/> Element

The <section/> element is used to further partition the layout within a page. The <section/> element MAY possess an attribute that specifies a natural-language label for the section, and MAY contain child elements specifying a description, subsections, and field and table references.

The 'label' attribute specifies the label for this section. This attribute is OPTIONAL. Its value is any string.

8.3 <fieldref/> Element

The <fieldref/> element is used to situate a form field within the layout. The <fieldref/> element MUST possess a single attribute to identify the field it references, and is otherwise empty.

If a <fieldref/> element within a <page/> or <section/> references a non-existent field, then that reference MUST be ignored.

The 'var' attribute specifies the form field being referenced. This attribute is REQUIRED, and its value SHOULD be the same as the "var" attribute of one of the <field/> elements in the containing form.

8.4 <reportedref/> Element

The <reportedref/> element is used to situate a form "table" (as described by the <reported/< and <item/> elements) within the layout. The <reportedref/> element has no attributes or children.

8.5 <text/> Element

The <text/> element is used to provide natural-language text that describes a page or section, provides instructions or notes about the page or section, and the like. A <page/> or <section/> element MAY contain an unbounded number of <text/> child elements. The XML character data of this element SHOULD NOT contain newlines (the \n and \r characters), and any handling of newlines (e.g., presentation in a user interface) is unspecified herein.

8.6 XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/xdata-layout'
    xmlns='http://jabber.org/protocol/xdata-layout'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0141: http://www.xmpp.org/extensions/xep-0141.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='page'>
    <xs:complexType>
      <xs:choice minOccurs='0' maxOccurs='unbounded'>
        <xs:element ref='text' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='section' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='fieldref' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='reportedref' minOccurs='0' maxOccurs='unbounded'/>
      </xs:choice>
      <xs:attribute name='label' type='xs:string' use='optional'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='section'>
    <xs:complexType>
      <xs:choice minOccurs='0' maxOccurs='unbounded'>
        <xs:element ref='text' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='section' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='fieldref' minOccurs='0' maxOccurs='unbounded'/>
        <xs:element ref='reportedref' minOccurs='0' maxOccurs='unbounded'/>
      </xs:choice>
      <xs:attribute name='label' type='xs:string' use='optional'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='fieldref'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='empty'>
          <xs:attribute name='var' type='xs:string' use='required'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name='reportedref' type='empty'/>

  <xs:element name='text' type='xs:string'/>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

Appendices

Appendix A: Document Information

Series
XEP
Number
0141
Publisher
XMPP Standards Foundation
Status
Draft
Type
Standards Track
Version
1.0
Last Updated
2005-05-12
Approving Body
XMPP Council
Dependencies
XMPP Core, XEP-0004
Supersedes
None
Superseded By
None
Short Name
xdata-layout
Schema
<http://www.xmpp.org/schemas/xdata-layout.xsd>
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

Matthew Miller
Email
linuxwolf@outer-planes.net
JabberID
linuxwolf@outer-planes.net

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0004: Data Forms <https://xmpp.org/extensions/xep-0004.html>.

2. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

3. RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc6120>.

4. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

5. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>.

Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

  1. Version 1.0 (2005-05-12)
    Per a vote of the Jabber Council, advanced status to Draft.
    psa
  2. Version 0.3 (2005-05-03)
    Renamed <desc/> element to <text/> to avoid confusion with XEP-0004 element names; clarified formal definition of <text/> element; added <text/> elements to examples.
    psa
  3. Version 0.2 (2005-03-28)
    Editorial review: cleanup of text, examples, and schema.
    psa
  4. Version 0.1 (2004-08-10)
    Initial version.
    lw

END