W3C

XForms 1.0

W3C Working Draft 28 August 2001

This version:
http://www.w3.org/TR/2001/WD-xforms-20010828 (One big file, diff-marked HTML, Zip archive)
Latest version:
http://www.w3.org/TR/xforms/
Previous versions:
http://www.w3.org/TR/2001/WD-xforms-20010608
Editors:
Micah Dubinko, Cardiff <mdubinko@Cardiff.com>
Josef Dietl, Mozquito Technologies <josef@mozquito.com>
Roland Merrick, IBM <Roland_Merrick@uk.ibm.com>
Dave Raggett, W3C/Openwave <dsr@w3.org>
T. V. Raman, IBM <tvraman@almaden.ibm.com>
Linda Bucsay Welsh, Intel <linda@intel.com>

Abstract

Forms were introduced into HTML in 1993. Since then they have become a critical part of the Web. The existing mechanisms in HTML for forms are now outdated, and the W3C has started work on developing an effective replacement. This document defines "XForms", W3C's name for the next generation of web forms.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. The latest status of this document series is maintained at the W3C.

This is a Working Draft that incorporates new material agreed upon at the Amsterdam face to face meeting and ongoing feedback from the general public. According to our current plan, the next Working Draft after this one will be a "Last Call" Working Draft. Interested parties are encouraged to provide additional feedback and comments.

This document is a W3C Working Draft for review by W3C members and other interested parties. It is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". A list of current public W3C Working Drafts can be found at http://www.w3.org/TR.

This document has been produced as part of the W3C HTML Activity.

Please send detailed comments on this document to www-forms@w3.org, the public forum for discussion of the W3C's work on web forms. To subscribe, send an email to the above address with the word subscribe in the subject line (include the word unsubscribe if you want to unsubscribe). The archive for the list is accessible online.

Table of Contents

1 About the XForms 1.0 Specification
    1.1 Background
    1.2 Reading the Specification
    1.3 How the Specification is Organized
    1.4 Documentation Conventions
2 Concepts
    2.1 Purpose and Presentation
    2.2 Current Approach: XHTML
    2.3 Stepping Up to XForms
    2.4 Providing XML Instance Data
    2.5 The XForms Model
    2.6 Multiple Forms per Document
    2.7 Complete Document
3 Terminology
4 Datatypes
    4.1 XML Schema Datatypes
    4.2 XForms Datatypes
        4.2.1 tokenList
5 The XForms Model
    5.1 Introduction
    5.2 Model Item Properties
        5.2.1 type
        5.2.2 readOnly
        5.2.3 required
        5.2.4 relevant
        5.2.5 calculate
        5.2.6 isValid
        5.2.7 maxOccurs
        5.2.8 minOccurs
    5.3 Binding
        5.3.1 bind
        5.3.2 Binding Constraints
        5.3.3 Binding References
        5.3.4 Binding Example
    5.4 Applying XML Schema Datatypes
        5.4.1 Atomic Datatype
        5.4.2 Closed Enumeration
        5.4.3 Open Enumeration
        5.4.4 Union
        5.4.5 Multiple Selection
        5.4.6 Repeating Line Items
        5.4.7 Alternate Representation
6 XPath Expressions in XForms
    6.1 Datatypes
    6.2 Instance Data
    6.3 Evaluation Context
    6.4 Canonical Binding Expressions
    6.5 Forms Core Function Library
        6.5.1 Boolean Methods
        6.5.2 Number Methods
        6.5.3 String Methods
        6.5.4 Miscellaneous Methods
    6.6 Extensibility
        6.6.1 Extension Functions
7 Form Controls
    7.1 Introduction
    7.2 input
    7.3 textarea
    7.4 secret
    7.5 output
    7.6 upload
    7.7 range
    7.8 submit
    7.9 button
    7.10 selectBoolean
    7.11 selectOne
    7.12 selectMany
    7.13 Common Markup forselectOneand selectMany
        7.13.1 item
        7.13.2 itemref
        7.13.3 choices
    7.14 Common Markup
        7.14.1 Common Attributes
        7.14.2 Single Node Binding Attributes
        7.14.3 Nodeset Binding Attributes
        7.14.4 Common Child Elements
            7.14.4.1 caption
            7.14.4.2 help
            7.14.4.3 hint
            7.14.4.4 alert
            7.14.4.5 action
            7.14.4.6 extension
8 XForms Actions
    8.1 Using XForms Actions
    8.2 dispatch
    8.3 refresh
    8.4 recalculate
    8.5 revalidate
    8.6 setFocus
    8.7 setValue
    8.8 submitInstance
    8.9 resetInstance
    8.10 insert
    8.11 delete
    8.12 scroll
    8.13 setRepeatCursor
    8.14 toggle
    8.15 script
9 XForms User Interface
    9.1 Grouping Form Controls
    9.2 Conditional Constructs For Dynamic User Interfaces
    9.3 Repeating Structures
        9.3.1 Repeat Processing
        9.3.2 User Interface Interaction
    9.4 Dynamic Selection Choices
    9.5 Reusable Form Controls
10 Document Structure
    10.1 The XForms Namespace
    10.2 XForms Elements
        10.2.1 xform
        10.2.2 model
        10.2.3 instance
        10.2.4 submitInfo
        10.2.5 bindings
        10.2.6 privacy
        10.2.7 action
        10.2.8 extension
    10.3 Integration with XLink
        10.3.1 XLink role for XForms
        10.3.2 XLink role for the XForms Model
        10.3.3 XLink role for the Instance Data
        10.3.4 XLink role for the XForms User Interface
11 Processing Model
    11.1 Introduction
        11.1.1 Design Rationale
    11.2 XForms Properties
    11.3 Events
    11.4 XForms Processing
        11.4.1 Initialization/Resume
        11.4.2 Instance Data Construction
        11.4.3 Navigation Sequence Algorithm
        11.4.4 Interactivity
        11.4.5 Recalculation Sequence Algorithm
            11.4.5.1 Details on Creating the Master Dependency Directed Graph
            11.4.5.2 Details on Creating the Pertinent Dependency Subgraph
            11.4.5.3 Details on Computing Individual Vertices
            11.4.5.4 Example of Calculation Processing
        11.4.6 UI Refresh Algorithm
        11.4.7 Revalidation Algorithm
    11.5 Submit and Reset
        11.5.1 Submit
        11.5.2 Reset
    11.6 Serialization Formats for Instance Data
        11.6.1 application/x-www-form-urlencoded
        11.6.2 multipart/form-data
        11.6.3 text/xml
            11.6.3.1 Binary Content
    11.7 Conformance
        11.7.1 XForms Basic
        11.7.2 XForms Full
        11.7.3 Conforming XForms Processors
        11.7.4 Conforming XForms Containing Documents
        11.7.5 Conforming XForms Generators

Appendices

A Schema for XForms
B Input Modes
C References
    C.1 Normative References
    C.2 Informative References
D Changes from Previous Release (Non-Normative)
    D.1 Changes since the 08-June-2001 release
    D.2 Changes to Chapter 1 'About XForms'
    D.3 Changes to Chapter 2 'Concepts'
    D.4 Changes to Chapter 3 'Terminology'
    D.5 Changes to Chapter 4 'Datatypes'
    D.6 Changes to Chapter 5 'XForms Model'
    D.7 Changes to Chapter 6 'XPath Expressions in XForms'
    D.8 Changes to Chapter 7 'Form Controls'
    D.9 New Chapter 8 'XForms Actions'
    D.10 Changes to Chapter 9 'XForms User Interface'
    D.11 Removed Chapter 'Binding'
    D.12 Changes to Chapter 10 'Document Structure'
    D.13 Changes to Chapter 11 'Processing Model and Conformance'
    D.14 Changes to Appendix 'Schema for XForms'
    D.15 New Appendix 'Input Modes'
    D.16 Changes to Appendix 'References'
E Acknowledgements (Non-Normative)
F Production Notes (Non-Normative)


1 About the XForms 1.0 Specification

1.1 Background

Forms are an important part of the Web, and they continue to be the primary means of interactivity used by many Web sites. Web applications and eCommerce solutions have sparked the demand for better web forms with richer interactions. XForms are the response to this demand--extended analysis, followed by the creation of a new platform-independent markup language for online interaction between an XForms Processor and a remote entity. XForms are the successor to XHTML forms, and benefit from the lessons learned in the years of HTML forms implementation experience.

Further background information on XForms can be found at http://www.w3.org/MarkUp/Forms.

1.2 Reading the Specification

This specification has been written with various types of readers in mind--in particular XForms authors and XForms implementors. We hope the specification will provide authors with the tools they need to write efficient, attractive, and accessible documents, without overexposing them to the XForms implementation details. Implementors, however, should find all they need to build conforming XForms Processors. The specification begins with a general presentation of XForms and becomes more and more technical and specific towards the end. For quick access to information, a general table of contents, specific tables of contents at the beginning of each section provide easy navigation.

The specification has been written with various modes of presentation in mind. In case of a discrepancy, the online electronic version is considered the authoritative version of the document.

1.3 How the Specification is Organized

The specification is organized into the following chapters:

Chapters 1 and 2

An introduction to XForms The introduction includes a brief tutorial on XForms and a discussion of design principles behind XForms.

Chapters 3 and up

XForms reference manual. The bulk of the reference manual consists of the specification of XForms. This reference defines XForms and how XForms Processors must interpret the various components in order to claim conformance.

Appendixes

Appendixes contain a normative description of XForms described in XML Schema, information on references, and other useful information.

1.4 Documentation Conventions

The following highlighting and typography is used to present technical material in this document:

Throughout this document, the namespace prefixes "xform:", "xsd:", and "xsi:" are used to denote the XForms, XML Schema, and XML Schema for Instances namespaces respectively. This is by convention only; any namespace prefix may be used in practice.

Official terms are defined in the following manner: [Definition: You can find most terms in the chapter 3 Terminology ]. Links to terms may be specially highlighted in the text, though typically only on introductory usage or when special attention needs to be directed toward the term.

The XML representations of various elements within XForms are presented as follows: Listed are the element name, names of all attributes, allowed values of attributes appearing after a "=" character, default values of attributes appearing after a ":" character, and allowed content. One or more headings below the table provide additional explanatory information.

Example: XML Syntax Representation <example>
<example
  count = xsd:integer
  size = (small | medium | large) : medium
>
  <!-- Content: (allowed-content) -->
</example>

count = xsd:integer - description of this attribute
size = (small | medium | large) : medium - description of this attribute

Non-normative short examples are set off typographically:

Example Item

or

Example Item

References to external documents appear as follows: [Sample Reference] with links to the references section of this document.

Sample Reference
Reference - linked to from above.

The following highlighting is used for non-normative commentary:

Note:

A general admonition to readers.

Editorial note: Editorial Note Name 
Editorial commentary, not intended for final publication.

Issue (issue-id):

Issue-Name

A specific issue to which input from readers is requested, not intended for final publication.

2 Concepts

This informative chapter provides an easily approachable description of the design of XForms, describing the major components and how they relate. Not every feature of XForms is covered here. For a complete, normative description of XForms, refer to the remainder of this document.

2.1 Purpose and Presentation

For explanatory purposes, a form can be considered to consist of 'purpose', 'presentation', and 'data'. Some examples:

Purpose Presentation Data
Data collection Arrangement of form controls Registration information
Time card How dates are entered Days and hours worked
Order form How to render the form controls on small devices Order, shipping, and payment info
Information Please How the form integrates with a Web site User contact information

The design of existing Web forms didn't separate the purpose from the presentation of a form, and additionally offered only a restricted representation for data captured through the form. This is the primary difference between XForms and previous form technologies.

2.2 Current Approach: XHTML

Take for instance a simple eCommerce form authored in XHTML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
          "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>eCommerce Form</title>
</head>
<body>
<form action="http://example.com/submit" method="post">
  <table>
    <tr>
      <td><p>Select Payment Method:</p></td>
      <td><label><input type="radio" name="as" value="cash"/>Cash</label>
      <label><input type="radio" name="as" value="credit"/>Credit</label></td>
    </tr>
    <tr>
      <td><label for="cc">Credit Card Number:</label></td>
      <td><input type="text" name="cc" id="cc"/></td>
    </tr>
    <tr>
       <td><label for="exp">Expiration Date:</label></td>
       <td><input type="text" name="exp" id="exp"/></td>
    </tr>
    <tr>
       <td colspan="2"><input type="submit"/></td>
    </tr>
  </table>
</form>
</body>
</html>

A browser might render this form as follows:

screen shot of a graphic rendering

This form makes no effort to separate purpose (data collection semantics) from presentation (the <input> form controls), and offers no control over the basic name/value pair serialization of the resulting data. XForms greatly improve the expressive capabilities of electronic forms.

2.3 Stepping Up to XForms

XForms are comprised of separate sections that describe what the form does, and how the form is to be presented. This allows for flexible presentation options, making it possible for classic XHTML form controls, as well as other form control sets such as WML, to be leveraged as shown here:

puzzle pieces; 'XForms Model' on the left, on the right 'XForms User Interface', 'XHTML', 'WML', and a stack of 'proprietary' pieces

The simplest case involves authoring only the new XForms form controls, leaving out the other sections of the form. To convert the previous form into XForms this way, an xform element is needed in the head section of the document:

<xform:xform>
  <xform:submitInfo .../>
</xform:xform>

With these changes to the containing document, the previous example could be rewritten like this:

<xform:selectOne ref="as">
  <xform:caption>Select Payment Method</xform:caption>
  <xform:choices>
    <xform:item value="cash"><xform:caption>Cash</xform:caption></xform:item>
    <xform:item value="credit"><xform:caption>Credit</xform:caption></xform:item>
  </xform:choices>
</xform:selectOne>
<xform:input ref="cc">
  <xform:caption>Credit Card Number</xform:caption>
</xform:input>
<xform:input ref="exp">
  <xform:caption>Expiration Date</xform:caption>
</xform:input>
<xform:submit>
  <xform:caption>Submit</xform:caption>
</xform:submit>

Notice the following features of this design:

  • The user interface is not hard-coded to use radio buttons. Different devices (such as a voice browser) can render the concept of "selectOne" as appropriate.

  • Form controls always have captions directly associated with them, as child elements.

  • There is no need for an enclosing form element.

  • Markup for specifying form controls has been simplified: <xform:input> rather than <input type="text">; and <xform:selectOne> instead of <html:select multiple="multiple>

  • Data entered through the form controls ends up submitted as XML.

With these changes, the XForms Processor will be able to directly submit XML instance data. The XML is constructed by creating a root element with child elements reflecting the names given to each form control. For instance, the submitted data would look like this:

<!-- envelope, generated separately -->
<Envelope>
  <Body>
    <!-- serialized instance data -->
    <as>Credit</as>
    <cc>1235467789012345</cc>
    <exp>2001-08</exp>
  <!-- envelope, generated separately -->
  </Body>
</Envelope>

2.4 Providing XML Instance Data

Understandably, authors will often desire greater control over exact construction of the submitted instance data. One common case might be submitting to a server XML data that is validated against a predefined DTD or XML Schema.

XForms processing keeps track of the state of the partially filled form through instance data, which provides an outline of the desired XML data, including namespace information. The instance data starts off with the initial values for the form, is updated as the user fills the form, and eventually is serialized and submitted. The initial instance data is taken from the instance element inside thexform element, defined as follows:

<xform:xform>
  <xform:submitInfo action="http://example.com/submit" method="..."/>
  <xform:instance>
    <payment as="credit" xmlns="http://commerce.example.com/payment">
      <cc/>
      <exp/>
    </payment>
  </xform:instance>
</xform:xform>

This design has features worth calling out:

  • There is complete flexibility in the structure of the XML. Notice that XML namespaces are now used, and thata wrapper element of the author's choosing wraps the instance data.

  • Empty elements pay:cc and pay:exp serve as placeholders in the XML structure, and will be filled in with form data provided by the user.

  • An initial value ("credit") for the form control is provided through the instance data, in this case an attribute as. In the submitted XML, this initial value will be replaced by the user input, if any.

To connect this instance data with form controls, therefattributes on the form controls need to point to the proper part of the instance data, using binding expressions:

... xmlns:pay="http://commerce.example.com/payment"...
  <xform:selectOne ref="pay:payment/@as">
  ...
  <xform:input ref="pay:payment/pay:cc">
  ...
  <xform:input ref="pay:payment/pay:exp">

Binding expressions are based on XPath [XPath 1.0], including the use of the '@' character to refer to attributes, as seen here.

2.5 The XForms Model

Referring to the earlier XHTML form in 2.2 Current Approach: XHTML, there are several aspects that would be desirable to express, but would only be possible through the addition of unstructured script code:

  • The credit card information fields cc and exp are only relevant if the "credit" option is chosen in the as field.

  • The credit card information fields cc and exp should be required when the "credit" option is chosen in the as field.

  • The field cc should accept digits only, and should have exactly 14, 15, or 16 digits.

  • The field exp should accept only valid month/date combinations.

By specifying a 3rd component, the XForms Model, authors can include rich declarative datatype and validation information in forms.

An XForms Model consists of model items, which include XML Schema datatype facet information [XML Schema part 2] as well as properties specific to XForms.

... xmlns:pay="http://commerce.example.com/payment"...
<xform:bind ref="pay:payment/pay:cc"
  relevant="pay:payment/@as == 'credit'"
  required="true"
  type="pay:cc"/>

<xform:bind ref="pay:payment/pay:exp"
  relevant="pay:payment/@as == 'credit'"
  required="true"
  type="xsd:gYearMonth"/>

<!-- Plus the following in an external Schema -->
...
  <xsd:simpleType name="cc">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{14,16}"/>
    </xsd:restriction>
  </xsd:simpleType>
...

2.6 Multiple Forms per Document

XForms processing places no limits on the number of individual forms that can be placed in a single containing document. When multiple forms share the same containing document, multiple xform elements are needed. The first xform element may skip a unique id attribute (as have all the examples above), but subsequent xform elements require an id so that they can be referenced from elsewhere in the containing document.

The other side of the equation is that form controls throughout the document need to specify which xform element is associated with the instance data to which they bind. This is accomplished through anxformattribute alongside the ref attribute. The default for thexform attribute is to refer to the firstxformelement in document order.

To add a second form, an opinion poll, to our commerce example, the following would be authored in the head section of the XHTML:

<xform:xform>
  <xform:submitInfo action="http://example.com/submit" method="..."/>
  <xform:instance>
     ...payment instance data...
  </xform:instance>
</xform:xform>

<xform:xform id="poll">
  <xform:submitInfo .../>
</xform:xform>

Additionally, the following form control markup in the body:

<xform:selectOne ref="pollOption" xform="poll">
  <xform:caption>How useful is this page to you?</xform:caption>
  <xform:choices>
    <xform:item value="0"><xform:caption>Not at all helpful</xform:caption></xform:item>
    <xform:item value="1"><xform:caption>Barely helpful</xform:caption></xform:item>
    <xform:item value="2"><xform:caption>Somewhat helpful</xform:caption></xform:item>
    <xform:item value="3"><xform:caption>Very helpful</xform:caption></xform:item>
  </xform:choices>
</xform:selectOne>
<xform:submit xform="poll">
  <xform:caption>Submit</xform:caption>
</xform:submit>

The main difference to note here is the use of xform="poll", which identifies which form the form control binds to.

2.7 Complete Document

This chapter presented various bits and pieces of XForms as a tool to help readers understand the design. Presented here is the entire XHTML+XForms,parallel to the opening example document, presented in one segment.

Note:

The DOCTYPE declration below is technically not valid, since XHTML 1.1 does not include XForms elements in any content models. The Working Group is developing a DOCTYPE declaration for the combination of XHTML and XForms.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xform="http://www.w3.org/2001/08/xforms"
      xmlns:pay="http://commerce.example.com/payment"
      xml:lang="en">
<head>
  <title>XForms in XHTML</title>

  <xform:xform>
    <xform:submitInfo action="http://example.com/submit"
      method="post"
      encType="xml"/>
    <xform:instance>
      <pay:payment as="credit">
        <pay:cc/>
        <pay:exp/>
      </pay:payment>
    </xform:instance>
    <xform:model href="payschema.xsd"/>
    <xform:bindings>
      <xform:bind ref="pay:payment/pay:cc"
        relevant="pay:payment/@as == 'credit'"
        required="true" type="pay:cc"/>
      <xform:bind ref="pay:payment/pay:exp"
        relevant="pay:payment/@as == 'credit'"
        required="true" type="xsd:gYearMonth"/>
    </xform:bindings>
  </xform:xform>
</head>
<body>
    ...
<xform:selectOne ref="pay:payment/@as">
  <xform:caption>Select Payment Method</xform:caption>
  <xform:choices>
    <xform:item value="cash"><xform:caption>Cash</xform:caption></xform:item>
    <xform:item value="credit"><xform:caption>Credit</xform:caption></xform:item>
  </xform:choices>
</xform:selectOne>
<xform:input ref="pay:payment/pay:cc">
  <xform:caption>Credit Card Number</xform:caption>
</xform:input>
<xform:input ref="pay:payment/pay:exp">
  <xform:caption>Expiration Date</xform:caption>
</xform:input>
<xform:submit>
  <xform:caption>Submit</xform:caption>
</xform:submit>
...
</body>
</html>

3 Terminology

binding

[Definition: The connection between a form control and a model item and an instance data node, represented as a binding expression.]

binding expression

[Definition: An XPath addressing expression used by the binding to connect form controls to other parts of XForms.]

computed expression

[Definition: An XPath expression used by model item properties such as relevant and calculate to include dynamic functionality in XForms.]

containing document

[Definition: A specific document, for example an XHTML document, in which one or more <xform> elements are found.]

datatype

[Definition: A 3-tuple, consisting of a) a set of distinct values, called its value space, b) a set of lexical representations, called its lexical space, and c) a set of facets that characterize properties of the value space, individual values or lexical items. This definition is taken from XML Schema [XML Schema part 2].]

facet

[Definition: A single defining aspect of a value space. Generally speaking, each facet characterizes a value space along independent axes or dimensions. This definition is taken from XML Schema [XML Schema part 2].]

form control

[Definition: An XForms user interface control that serves as a point of user interaction.]

instance data

[Definition: An internal tree representation of the values and state of all the instance data nodes associated with a particular form.]

instance data node

[Definition: An XPath node from the instance data.]

lexical space

[Definition: A lexical space is the set of valid literals for a datatype. This definition is taken from XML Schema [XML Schema part 2].]

model item

[Definition: An abstract unit of data-collection within the XForms Model, which consists of a XML Schema datatype and possibly other form-specific constraints on a single piece of collected data.]

model item property

[Definition: A single XForms-specific defining aspect of a model item.]

value space

[Definition: A set of values for a given datatype. Each value in the value space of a datatype is denoted by one or more literals in its lexical space. This definition is taken from XML Schema [XML Schema part 2].]

XForms Model

[Definition: The non-visible definition of an XML form as specified by XForms. The XForms Model defines the individual model items and constraints and other run-time aspects of XForms.]

XForms Processor

[Definition: A software application or program that implements and conforms to the XForms specification.]

4 Datatypes

4.1 XML Schema Datatypes

XForms includes all XML Schema datatypes, including the concepts of value space and lexical space, and all constraining facets, as specified in [XML Schema part 2]. These are further divided into two modules, called Basic and Full, and are as follows (the Basic module contains only those datatypes with an asterisk*):

Built-in primitive types:

duration *
dateTime *
time *
date *
gYearMonth *
gYear *
gMonthDay *
gDay *
gMonth *
string *
boolean *
base64Binary *
hexBinary
float
decimal *
double
anyURI *
QName
NOTATION

Built-in derived types:

normalizedString
token
language
Name
NCName
ID
IDREF
IDREFS
ENTITY
ENTITIES
integer *
nonPositiveInteger *
negativeInteger *
long *
int *
short *
byte *
nonNegativeInteger *
unsignedLong *
unsignedInt *
unsignedShort *
unsignedByte *
positiveInteger *

Issue (datatype-identifiers):

One requirement is for XForms to include unique identifiers for each datatype listed here. We believe the facilities in XML Schema are sufficient for this, but welcome feedback on this issue.

Issue (now-facet):

Previous Working Drafts of XForms specified "dynamic facets" that could be reevaluated at arbitrary times. One benefit of that approach was that a now() expression could be used as a constraining facet on date/time datatypes. What are our options for including similar functionality within the framework of XML Schema datatypes?

4.2 XForms Datatypes

The Schema for XForms derives the following types for use within forms:

4.2.1 tokenList

XForms includes form controls that produce simpleType list content. To prevent the need of authors to continuously redefine a derived-by-list datatype suitable for this case, one is included here. This datatype is suitable for XForms Basic or XForms Full.

  • Examples: The string "United States of America" represents a list of four tokens:

    "America", "of", States", and "United"

Note:

In most cases, it is advised to use markup to distinguish items in a list. See 9.4 Dynamic Selection Choices.

5 The XForms Model

5.1 Introduction

Chapter 4 Datatypes described how XForms adopts the XML Schema datatyping system, which can constrain the value space of datatypes that can be used in data collection. This chapter introduces an additional set of properties, called model item properties, which define XForms-specific behaviors and metadata useful for data collection.

5.2 Model Item Properties

Model item properties fall into two basic categories:

  • Computed expressions are XPath expressions that provide a value to the XForms Processor. The value is recomputed at certain times, according to the XForms Processing Model (see 11 Processing Model).

  • All other properties are fixed, static values that the XForms Processor evaluates only once.

The following properties are available for all model items, and their syntax is explained throughout this chapter. For each property the following information is provided:

Description
Computed Expression (yes or no)
Legal Values
Default Value
Additional descriptive text

5.2.1 type

Description: associates a Schema datatype.

Computed Expression: No

Legal Values: Any xsd:QName representing an in-scope Schema simpleType.

Default Value: xsd:anyType

The concept of typed data is important to forms. The assignment of a particular datatype to a model item affects validation of the data it can accept, as well as affecting which form controls to which it can bind.

5.2.2 readOnly

Description: describes whether the value is restricted from changing. The ability of form controls to have focus and appear in the navigation order is unaffected by this property.

Computed Expression: Yes

Legal Values: Any expression that is convertible to boolean

Default Value: false

When evaluating to true, this property indicates that the XForms Processor should not allow any changes to the bound instance data node.

In addition to restricting value changes, the readOnly property provides a hint to the XForms User Interface. Form controls bound to a model item with the readOnly property should indicate that entering or changing the value is not allowed. The hint provided has no effect on visibility, focus, or navigation order.

5.2.3 required

Description: describes whether a value is required before the instance data is submitted.

Computed Expression: Yes

Legal Values: Any expression that is convertible to boolean

Default Value: false

Often forms require certain values to be entered. This may be a static requirement, or may only be the case if some condition is satisfied. When evaluating to true, this property indicates that a non-empty instance data node is required before a submission of instance data can occur. Non-empty is defined as:

  1. If the bound instance data node is an element, the element must not have the xsi:nil attribute set to true.

  2. The value of the bound instance data node must be convertible to an XPath string with a length greater than zero.

Except as noted below, the required property does not provide a hint to the XForms User Interface regarding visibility, focus, or navigation order. XForms authors are strongly encouraged to make sure that form controls that accept required data are visible. An XForms Processor may provide a unique indication that a form control is required, and may provide immediate feedback, including limiting navigation, for required form controls.

The chapter 11 Processing Model contains details on how the XForms Processor enforces required values.

5.2.4 relevant

Description: indicates whether the model item is currently relevant to the rest of the XForms Model. XForms Processors would typically not render an associated form control, including children, when the value is false.

Computed Expression: Yes

Legal Values: Any expression that is convertible to boolean

Default Value: true

Many forms have fields dependent on other conditions. For example, a form might ask whether the respondent owns a car. It is only appropriate to ask for further information about their car if they have indicated that they own one.

When evaluating to true, this property indicates that the XForms Processor should render a form control, and conversely, when evaluating to false, indicates that the form control should not be rendered.

The relevant property provides hints to the XForms User Interface regarding visibility, focus, and navigation order. In general, when true, associated form controls should be made visible. When false, associated form controls should be made unavailable, removed from the navigation order, and not allowed focus.

The following table shows the user interface interaction between required and relevant.

required="true" required="false"
relevant="true" The form control (and any children) should be visible or available to the user. The XForms User Interface may indicate that a value is required. The form control (and any children) should be visible or available to the user. The XForms User Interface may indicate that a value is optional.
relevant="false" The form control (and any children) should be hidden or unavailable to the user. Entering a value or obtaining focus should not be allowed. The XForms User Interface may indicate that should the form control become relevant, a value would be required. The form control (and any children) should be hidden or unavailable to the user. Entering a value or obtaining focus should not be allowed.

5.2.5 calculate

Description: indicates that the instance data node associated with the model item is to be dynamically calculated.

Computed Expression: Yes

Legal Values: Any expression that is convertible to an XPath datatype compatible with the associated XML Schema datatype

Default Value: none

An XForms Model may include model items that are computed from the other values elsewhere. For example, the sum over line items for quantity times unit price, or the amount of tax to be paid on an order. The computed value can be represented as a computed expression using the values of other model items. The XForms Processing Model indicates how and when the calculation is recomputed.

5.2.6 isValid

Description: specifies the predicate that needs to be satisfied for the associated instance data node to be considered valid.

Computed Expression: Yes

Legal Values: Any expression that is convertible to boolean

Default Value: true

An XForms Model may include model items that need to be revalidated. When evaluating to true, indicates that the model item is considered valid. The chapter 11 Processing Model describes details such as immediate validation vs. validation upon submit.

Computed expressions used here are not restricted to examining the instance data node they are invoked on. XPath, plus the extensions in this specification, provide the means to traverse the instance data, as well as call-outs to external script, enabling potentially complex validations.

The XForms User Interface may indicate whether a form control is currently valid or invalid.

Issue (issue-cascade):

Will the isValid property be evaluated on all the parent or child model items whenever a value changes? We need to make sure that inter-model item constraints will get evaluated.MJD - Is this still an issue?

5.2.7 maxOccurs

Description: for repeating structures, indicates the maximum number of allowed child elements.

Computed Expression: No

Legal Values: xsd:integer or "unbounded"

Default Value: "unbounded"

For model item elements that are repeated, this optional property specifies a maximum number of allowed child elements. This only applies to element nodes selected as part of a repeat sequence (9.3 Repeating Structures).

5.2.8 minOccurs

Description: for repeating structures, indicates the minimum number of allowed child elements.

Computed Expression: No

Legal Values: xsd:integer

Default Value: 0.

For model item elements that are repeated, this optional property specifies a minimum number of allowed child elements. This only applies to element nodes selected as part of a repeat sequence (9.3 Repeating Structures).

5.3 Binding

Binding is the glue that connects the separate pieces of XForms--directly associating nodes in the instance data with model item properties.

Binding is specified through the use of binding expressions, which select nodes from the instance data. The syntax and details of binding expressions are based on XPath, and defined in the chapter 6 XPath Expressions in XForms. This section describes the wider topic of how binding expressions are used within XForms.

5.3.1 bind

The bind element represents a node-set selected from the instance data. A series of attributes on the element correspond to individual model item properties, which are applied to each node in the node-set.

Example: XML Representation: <bind>
<bind
  id = xsd:ID
  ref = binding-expression
  type = xsd:QName
  readOnly = model-item-property
  required = model-item-property
  relevant = model-item-property
  isValid = model-item-property
  calculate = model-item-property
  maxOccurs = xsd:nonNegativeInteger or "unbounded"
  minOccurs = xsd:nonNegativeInteger
>
  <!-- Content: (##empty) -->
</bind>

id = xsd:ID - Optional unique identifier.
ref = binding expression - A binding expression that selects which node or nodes have the associated properties applied
type = xsd:QName - reference to an in-scope Schema simpleType
readOnly = model-item-property
required = model-item-property
relevant = model-item-property
isValid = model-item-property
calculate = model-item-property
maxOccurs = xsd:nonNegativeInteger or "unbounded"
minOccurs = xsd:nonNegativeInteger

Each bind element selects a node-set from the instance data, and applies any model item properties. When additional nodes are added through the insert action, the newly added nodes are included in any node-sets matched by binding expressions.

5.3.2 Binding Constraints

Not every possible XPath expression is accepted as a binding expression. The following constraints are placed upon binding expressions:

  1. No dynamic predicates. Predicates are permitted, but any predicates used must not alter the returned node-set based on other form settings. For example:

    permitted: foo
    permitted: foo[1]
    premitted: foo[last()]
    permitted: foo[@id="zip"] ONLY if @id is not bound to a form control
    forbidden: foo[@bar=""] with @bar bound to a form control
  2. No dynamic variables. The XForms specification does not provide any variables.

  3. No invocation of any function that returns a node-set. Function calls are permitted, but not any that return a node-set.

  4. No invocation of any function with side-effects. All functions defined in the XForms specification are side-effect-free. Any extension functions should also be side-effect-free.

Upon detecting a binding expression that violates any of the above constraints, an exception will be thrown.

5.3.3 Binding References

References to node-sets are attached to form controls through binding references, described in 7.14.2 Single Node Binding Attributes and 7.14.3 Nodeset Binding Attributes. Different attribute names, ref vs. nodeset, distinguish between a single node, and a node-set, respectively. When a single-node binding expression selects a node-set of size > 1, the "first node" rule is applied, utilizing only the first node in the node-set. This has no effect on the individual nodes nor the set of nodes selected by any particular bind element.

Examples:

Example: XForms User Interface Markup with Binding Reference
<xform:input bind="id-of-bind-element">
   <xform:caption>Your first name</xform:caption>
</xform:input>

The bind attribute links the form control to the instance data and XForms Model declared elsewhere in the containing document.

Alternatively, an inline binding expression can be used with the ref and xform attributes.

Example: XForms User Interface Markup with Binding Expression
<xform:input xform="id-of-xform-element" ref="binding-expression">
   <xform:caption>Your first name</xform:caption>
</xform:input>

The ref attribute links the form control to the instance data and XForms Model declared elsewhere in the containing document. If the xform attribute were left out, the default (first) xform element would be referenced.

These attributes can also be used on non-XForms form controls, for instance XHTML:

Example: XHTML with Binding Attributes
<html:input type="text" name="..." xform:bind="id-of-bind-element"/>

Here the xform:bind attribute links an XHTML form control to the instance data and XForms Model contained elsewhere in the containing document. Note that when placed on form controls outside of XForms, the attribute must be appropriately namespace-qualified. Note also that the html: prefix is used here to represent the XHTML namespace.

5.3.4 Binding Example

Consider a document with the following XForms declarations:

<xform:instance xmlns="">
  <orderForm>
    <shipTo>
      <firstName>John</firstName>
    </shipTo>
  </orderForm>
</xform:instance>

and

<xform:bind ref="orderForm/shipTo/firstName"
  id="fn"
  type="xsd:string"
  required="true"/>

An input form control could be attached to the instance data directly, or indirectly:

<xform:input ref="orderForm/shipTo/firstName">...</xform:input>
<!-- or -->
<xform:input bind="fn">...</xform:input>

In this case, no xform attribute was required, as is the case when a containing document holds only one xform element.

5.4 Applying XML Schema Datatypes

Datatypes used in XForms are either those predefined in chapter4 Datatypes, or simpleTypes defined in an external Schema, as defined in [XML Schema part 2].

Editorial note 
Add discussion here about locating an external Schema, through xsi:schemaLocation or other means
Editorial note 
Add discussion here about allowed inline Schema

5.4.1 Atomic Datatype

The XForms Processing Model applies XML Schema facets as part of the validation process. At the simplest level, it is necessary to associate a set of facets (through a Schema datatype) with a model item. This has the effect of restricting the allowable values of the associated instance data node to valid representations of the lexical space of the datatype.

The set of facets may be associated with a model item in one of the following ways (only the first that applies is used):

  1. An xsi:type attribute (restricted to simpleTypes in XForms Basic) on the initial instance data.

  2. (XForms Full only) An XML Schema associated with the instance data.

  3. A type model item property.

  4. Otherwise, the datatype is treated as xsd:string (default to string rule).

Example Schema Syntax: declaring a datatype based on an xsd:string plus additional constraining facet would be accomplished by the following in an external Schema:

<xsd:simpleType name="restrictedString">
  <xsd:restriction base="xsd:string">
    <xsd:minLength value="1"/>
  </xsd:restriction>
</xsd:simpleType>

This new datatype would then be associated with one or more model items through one of the methods outlined above.

5.4.2 Closed Enumeration

Often it is necessary to restrict the allowable values of the associated instance data node to a closed list of alternatives.

Example Schema Syntax: declaring a datatype allowing enumerated values of an xsd:string would be accomplished with the following in an external Schema:

<xsd:simpleType>
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Mastercard"/>
    <xsd:enumeration value="Diner's Club"/>
    <xsd:enumeration value="American Express"/>
  </xsd:restriction>
</xsd:simpleType>

5.4.3 Open Enumeration

A special case of enumerated datatypes is the common form design pattern of a list, with an 'other, please specify' choice. This is referred to as an open enumeration.

Example Schema Syntax: declaring an open enumeration is possible through a combination of union and enumeration features, with the following in an external Schema:

<xsd:simpleType>
  <xsd:union memberTypes="xsd:string">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="Mastercard"/>
        <xsd:enumeration value="Diner's Club"/>
        <xsd:enumeration value="American Express"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:union>
</xsd:simpleType>

5.4.4 Union

It may be desirable for data collection purpose to allow an instance data item to be a valid lexical value of one among several datatypes. Unions are defined in XML Schema.

Example Schema Syntax: declaring a datatype allowing either a creditCardType or bonusProgramType value would be accomplished with the following in an external Schema:

<xsd:simpleType>
  <xsd:union memberTypes="creditCardType bonusProgramType"/>
</xsd:simpleType>

5.4.5 Multiple Selection

Some form controls, such as selectMany, have the notion of supporting more than one simpleType value at any given time. This corresponds with Schema list datatypes.

Example Schema Syntax: declaring a list-derived datatype would be accomplished with the following in an external Schema:

<xsd:simpleType name="listOfMyIntType">
  <xsd:list itemType="xsd:int"/>
</xsd:simpleType>

5.4.6 Repeating Line Items

It is common for certain types of forms, such as order forms, to contain repeating structures, typically line items.

Chapter 9 XForms User Interface contains details on representing this with XForms User Interface form controls, as well as details for how this relates to the instance data in chapter 11 Processing Model.

5.4.7 Alternate Representation

In some forms, alternate representations might be necessary for underlying instance data structures.

Example Schema Syntax: a Schema choice element is roughly analogous to this, although XForms uses a more dynamic version. Examples of this are found in 9 XForms User Interface

6 XPath Expressions in XForms

XPath is used within XForms to address instance data nodes, as well as to perform basic operations, such as declaratively stating when a form control needs to be filled out, or defining a computation over other values such as unit prices, quantities, discounts, and tax and shipping costs. This chapter describes how XForms uses XPath, and additional XForms functions for use in forms.

6.1 Datatypes

In general, XPath uses a smaller set of datatypes than XML Schema. XForms allows arbitrary Schema datatypes, including those defined in 4 Datatypes, while XPath datatypes are limited to boolean, string, number, and node-set. (For completeness, XPath additionally has external objects and result tree fragments, but there is no special treatment for these types in the XForms specification.)

Note:

Resource-limited XForms Processors may define implementation limits on the maximum size of a node-set.

The XForms specification is defined such that it is always clear whether XPath or XML Schema datatypes are used within a particular context. Binding expressions and computed expressions always use XPath datatypes, while everything else uses XML Schema datatypes.

Note:

A future version of XForms is expected to use XPath 2.0, which includes support for XML Schema datatypes, which will make the above distinction moot.

6.2 Instance Data

Every form has a current state, representing the values entered at any particular point in time. Within XForms, for each xform element, the XForms Processor must behave as if it internally maintains an XML data structure modeled as a tree to represent the state of the form. This data structure is called instance data and conforms to the XPath Data Model [XPath 1.0]. Additionally, each node in the tree contains a boolean "dirty" flag, which is referenced elsewhere by the XForms Processing Model. In this context, "dirty" indicates that the data value might need to be refreshed in the presentation.

Elements and attributes in the instance data may have namespace information associated with them, as defined in the XPath Data Model. Unless otherwise specified, all instance data elements and attributes are unqualified.

Issue (issue-instance-data-access):

Should there be specified a DOM form of access (perhaps a document fragment), that maps to the instance data? If so, should it be read-only or read-write access? What are possible security implications here?

The rules for defining the root and context nodes of the instance data are found in in the following section.

6.3 Evaluation Context

Applied to XForms, XPath references abstract instance data (using the "path" portion of XPath), instead of a discrete XML document. This reference is called a binding expression in this specification. Every XPath expression requires a context against which to be evaluated.

The following context is used for evaluating all binding expressions in XForms:

  1. The context node for outermost binding elements (such as XForms UI elements) is the XPath root (/). A "binding element" is any element that is explicitly allowed to have a binding expression attribute. An XForms element is "outermost" when the node-set returned by the XPath expression ancestor::* includes no binding element nodes.

    Note:

    The contents of the instance data below the XPath root node (/) are dependent on how the instance data was constructed, which is defined in 11.4.2 Instance Data Construction.

  2. The context node for non-outermost binding elements is determined by evaluating the binding expression of the immediately enclosing element. An element is "immediately enclosing" when it is the first binding element node in the node-set returned by the XPath expression ancestor::*. This is also referred to as "scoped resolution".

  3. The context size and position are both exactly 1.

  4. No variable bindings are in place.

  5. The available function library is defined below.

  6. Any namespace declarations in scope for the attribute that defines the expression are applied to the expression.

Example:

<group ref="element1/foo/bar">
  <selectOne ref="element2" ... />
  <selectOne ref="@attr" ... />
</group>

In this example, the group has a binding expression of element1/foo/bar. According to the rules above, this outermost element would have a context node of /, which is the root of the instance data, or the parent to the element1 element. Both of the selectOnes then inherit a context node from their parent, the context node being /element1/foo/bar. Based on this, the selectOne binding expressions evaluate respectively to /element1/foo/bar/element2 and /element1/foo/bar/@attr. Matching instance data follows:

<element1>
  <foo>
    <bar attr="xyz">
      <element2>xyz</element2>
    </bar>
  </foo>
</element1>

6.4 Canonical Binding Expressions

As with XPath, it is possible to construct many different binding expressions that end up returning the same node-set. That said, it is often useful to express a binding expression in a standard, compact representation, defined as a canonical binding expression.

Canonical binding expressions are represented as an AbsoluteLocationPath as defined in [XPath 1.0]. Additionally, canonical binding expressions use only default abbreviated axis-specifiers (for elements) or the '@' abbreviation (for attributes). Examples:

  • (canonical) /a/b/c

  • (canonical) /a/b/@c

  • (non-canonical) a/b/c (not an absolute path)

  • (non-canonical) child::a/child::b/child::c

  • (non-canonical) /a/b/c/d/ancestor::c

6.5 Forms Core Function Library

The XForms Core Function Library includes the entire [XPath 1.0] Core Function Library, including operations on node-sets, strings, numbers, and booleans.

This section defines a set of required functions for use within XForms.

Issue (xpath-core-lib):

Further input is required on the ability for resource-constrained devices to implement the complete XPath Core Function Library.

6.5.1 Boolean Methods

boolean boolean-from-string( string )

The boolean-from-string function returns true if the required string parameter is "true", or false if the string parameter is "false". This is useful when referencing a Schema xsd:boolean datatype in an XPath expression.

Editorial note 
We need to specify behavior if the string paramter is some other value.

6.5.2 Number Methods

number average( node-set )

The average function returns the arithmetic average value, for each node in the argument node-set, of the result of converting the string-values of each node to a number. The sum is computed with sum(), and divided with div by the value computed with count().

number min( node-set )

The min function returns the minimum value, for each node in the argument node-set, of the result of converting the string-values of the node to a number. "Minimum" is determined with the < operator.

number max( node-set )

The max function returns the maximum value, for each node in the argument node-set, of the result of converting the string-values of the node to a number. "Maximum" is determined with the < operator.

number count-non-empty( node-set )

The count-non-empty function returns the number of non-empty nodes in the argument node-set. A node is considered non-empty if it is convertible into a string with a greater-than zero length.

Note:

The following core functions are defined within [XPath 1.0] - number(), sum(), floor(), ceiling(), and round()

Note:

The following useful numeric and boolean operators are defined within [XPath 1.0] - "+", "-", "*", "div", "mod", unary "-" ,"=", "!=", "<", ">", "<=", ">=", "or", "and".

6.5.3 String Methods

string now()

The now function returns the current system time as a string value, in the canonical format defined within the XForms specification. If local time zone information is available, it is included in the string.

Note:

Note: the following are defined within [XPath 1.0] - string(), concat(), starts-with(), contains(), substring-before(), substring-after(), substring(), string-length(), normalize-space(), and translate().

6.5.4 Miscellaneous Methods

string xforms-property( string )

The xforms-property function accesses the XForms Property (defined in 11 Processing Model) named by the string parameter, and returns the value of the property.

6.6 Extensibility

XForms 1.0 allows extension functions, similar to [XSLT].

This version of XForms does not provide a mechanism for defining implementations of extensions. Therefore, a containing document that must be portable between XForms implementations cannot rely on particular extensions being available. XForms provides mechanisms that allow a containing document to determine whether the XForms processor by which it is being processed has implementations of particular extensions available, and to specify what should happen if those extensions are not available. If a containing document is careful to make use of these mechanisms, it is possible for it to take advantage of extensions and still work with any XForms implementation.

6.6.1 Extension Functions

If a FunctionName in a FunctionCall expression is not an NCName (i.e. if it contains a colon), then it is treated as a call to an extension function. The FunctionName is expanded to a name using the namespace declarations from the evaluation context.

If the XForms processor does not have an implementation of an extension function of a particular name available, then the function-available function must return false for that name. If such an extension function occurs in an expression and the extension function is actually called, the XForms processor must signal an error. An XForms processor must not signal an error merely because an expression contains an extension function for which no implementation is available.

If the XForms processor has an implementation of an extension function of a particular name available, then the function-available function must return true for that name. If such an extension is called, then the XForms processor must call the implementation passing it the function call arguments; the result returned by the implementation is returned as the result of the function call.

boolean function-available()

The function-available function returns true if an extension function of a particular name is available, otherwise false.

7 Form Controls

7.1 Introduction

XForms User Interface controls, also called form controls, are declared using markup elements, and their behavior refined via markup attributes. This markup may be further decorated with class attributes that can be set using CSS stylesheets to deliver a customized look and feel. Form controls defined here are bound to the underlying instance data using the binding attributes as defined in the chapter 5 The XForms Model.

Form controls enable accessibility by taking a uniform approach to such features as captions, help text, tabbing and keyboard shortcuts. Internationalization issues are addressed in conjunction with the Internationalization Working Group and are addressed by following the same design principles as within the rest of XHTML. All form controls defined here are suitable for implementation as Aural CSS (ACSS) form controls.

Form controls are as general and high-level as possible without sacrificing the ability to deliver real implementations. For instance, to select one or more items from a set, use the form controls selectOne or selectMany, respectively. Form controls distinguish the functional aspects of the underlying control, as well as presentational aspects (through class attributes) and behavior (through XForms Action elements). This separation enables the expression of the meaning of a particular form control--see [AUI97] for a definition of such high-level user interaction primitives.

This chapter includes non-normative graphical examples of many form controls. The CSS Working Group is providing assistance with creating default CSS rules for producing visual renderings of standard form controls. This specification will also include non-normative rules for how these same controls might be rendered to alternative access modalities.

For each form control, the following aspects sections describe:

Description
Examples
Data Binding Restrictions
Implementation Hints
XML Representation

The form controls defined here use common attributes and elements that are defined later in this chapter (7.14 Common Markup ).

7.2 input

Description: This form control enables free-form data entry.

Examples:

<input ref="order/shipTo/street" style="width:5cm; height:1.2cm">
  <caption>Street<caption>
  <hint>Please enter the number and street name</hint>
</input>

In the above, CSS style attributes (which are not defined in XForms but rather come from an external document type) specify the display size of the form control. Note that the constraints on how much text can be input are obtained from the underlying XForms Model definition and not from these display properties.

A graphical browser might render the above example as follows:

an average-looking text entry field. The title, 'street' has been automatically aligned to the left

Data Binding Restrictions: The entered value of the form control (after processing as described in 11 Processing Model) is treated as a lexical value. Schema facets bound to this form control will be treated as a restriction upon the allowed entered value.

Example: XML Representation: <input>
<input
  (single node binding attributes)
  (common attributes)
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</input>

(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
common attributes defined in 7.14.1 Common Attributes

7.3 textarea

Description: This form control enables free-form data entry and is intended for use in entering multiline content, e.g., the body of an email message.

Editorial note 
Control textarea has been added since we felt that the semantic distinction between single line entry from multiline entry e.g., entering an email address vs typing an email message was significant and amounted to more than just a presentational issue. We welcome comments on this approach.

Examples:

<textarea ref="message/body" style="width:8cm; height:5cm">
  <caption>Message Body:<caption>
  <hint>Enter the text of your message here</hint>
</textarea>

In the above, CSS style attributes (which are not defined in XForms but rather come from an external document type) specify the display size of the form control. Note that the constraints on how much text can be input are obtained from the underlying XForms Model definition and not from these display properties.

A graphical browser might render the above example as follows:

a larger-than-average text entry field. The title, 'Message Body:' provides an additional hint that large amounts of text are allowed here.

Data Binding Restrictions: The entered value of the form control (after processing as described in 11 Processing Model) is treated as a lexical value. Schema facets bound to this form control will be treated as a restriction upon the allowed entered value.

Example: XML Representation: <textarea>
<textarea
  (single node binding attributes)
  (common attributes)
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</textarea>

(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
common attributes defined in 7.14.1 Common Attributes

7.4 secret

Description: This form control is used for obtaining information that is considered sensitive, and thus not echoed to a visual or aural display as it is being entered, e.g., password entry.

Example:

<secret ref="/login/password">
  <caption>Please enter your password --it will not be visible as you type.<caption>
</secret>

A graphical browser might render this form control as follows:

an                 average-looking text entry field, with '*'                 characters where the text would be                 expected

Data Binding Restrictions: Identical to input.

Implementation Hints: In general, implementations, including accessibility aids, would render a "*" or similar character instead of the actual characters entered, and thus would not render the entered value of this form control. Note that this provides only a casual level of security; truly sensitive information will require additional security measures outside the scope of XForms.

Example: XML Representation <secret>
<secret
  (single node binding attributes)
  (common attributes)
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</secret>

(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
common attributes defined in 7.14.1 Common Attributes

7.5 output

Description: This form control renders a value from the instance data, but provides no means for entering or changing data. It is typically used to display values from the instance, and is treated as display:inline for purposes of layout.

Example:

I charged you
<output ref="order/totalPrice"/>
and here is why:

A graphical browser might render an output form control as follows:

average-looking text, reading 'I charged you                 100.0 - and here is why:'

Data Binding Restrictions: The lexical value of the datatype bound to this form control (or the result of theformatexpression, if present) is displayed, after processing as described in11 Processing Model.

Implementation Hints: An audio browser might apply properties to this form control to aurally highlight the displayed value to provide audio formatted output.

Example: XML Representation: <output>
<output
  id = xsd:ID
  (single node binding attributes)
  format = formatting-expression
>
  <!-- empty content -->
</output>

id = xsd:ID - Optional unique identifier used for linking.
(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
format = formatting-expression - Optional XPath format specifier

7.6 upload

Description: This form control enables the common feature found on Web sites to upload a file from the local file system, as well as accepting input from various devices including microphones, pens, and digital cameras.

Example:

<upload ref="mail/attach1" mediaType="image/*">
  <caption>Select image:</caption>
</upload>

A graphical browser might render this form control as follows:

A drop-down box; main display reads 'Select Image:' with a cutesey icon. The drop-down                 itself has three items: (icon)-From Scanner or Camera...; (icon)-Scribble...; Browse...

Data Binding Restrictions: This form control can only be bound to datatypes xsd:base64Binary or xsd:hexBinary, or types derived by restriction from these.

Implementation Hints:

  • Implementations with a file system SHOULD support "file upload"--selecting a specific file, for all mediaTypes. The types of files presented by default MUST reflect the mediaType specified in the XForms Model, for example defaulting to only audio file types in the file dialog when the mediaType is "audio/*". In XForms 1.0, there is a 1:1 binding between a upload form control and one of the xform:binary datatypes, although that single file may be compound (e.g. application/zip).

  • Implementations with specific pen/digitizer hardware SHOULD (and implementations with other pointing devices MAY) support "scribble"--allowing in-place creation of pen-based PNG image data, when the mediaType is "image/*" or "image/png". Other mediaTypes besides image/png MAY share this input method.

    Note:

    Commonly, people have trouble drawing recognizable figures or signatures with a conventional pointing device like a mouse or track ball. Hence, a reasonable implementation of XForms might not want this feature, hence the "MAY" here for generic pointing devices

  • Implementations with specific audio recording capabilities SHOULD support record--in-place recording of an audio clip, when the mediaType is "audio/*" or "audio/basic". Other mediaTypes besides "audio/basic" MAY share this input method.

  • Implementations with a digital camera/scanner interface SHOULD support send image--in-place upload of images from an attached device, when the mediaType is "image/*" or "image/jpeg". Other mediaTypes besides "image/jpeg" MAY share this input method.

  • Implementations with video recording capability SHOULD provide a "record" option for video/* mediaTypes.

  • Implementations with 3d capabilities SHOULD provide a 3d interface option for model/* mediaTypes.

  • Implementations MAY provide proprietary implementations (for example, a mediaType of text/rtf could invoke an edit window with a proprietary word processing application)

  • Implementations are encouraged to support other input devices not mentioned here.

Example: XML Representation: <upload>
<upload
  (single node binding attributes)
  (common attributes)
  mediaType = list of content types
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</upload>

(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
common attributes defined in 7.14.1 Common Attributes
mediaType = list of media types - list of suggested media types, used by the XForms Processor to determine which input methods apply.

7.7 range

Description: This form control allows selection from a continuous range of values.

Example:

<range ref="/stats/balance" start="-2.0" end="2.0" stepSize="0.5">
  <caption>Balance:</caption>
</range>

A graphical browser might render this as follows:

a slider control, from -2 to +2

Data Binding Restrictions: Only datatypes which represent a continuous range where it is possible to express a difference value can be bound to this form control. (For instance, xsd:decimal would be fine, while xsd:string would not). In terms of Schema datatypes, the datatype must be either 1) have a total order relationship, or 2) an overall partial order relationship, but totally ordered within the range specified between thestart and end attributes.

Issue (enum-range):

Should an enumeration be allowed to bind to this form control? If yes, how should it be ordered?

Implementation Hints: In graphical environments, this form control would typically be rendered as a "slider" or "volume control".

Notice that the attributes of this element encapsulate sufficient metadata that in conjunction with the type information available from the XForms Model proves sufficient to produce meaningful prompts when using modalities like speech, e.g., when using an accessibility aid. Thus, an Aural CSS enabled user agent might speak a prompt of the form Please pick a date in the range January 1, 2001 through December 31, 2001.

Example: XML Representation: <range>
<range
  (single node binding attributes)
  (common attributes)
  start = datavalue
  end = datavalue
  stepSize = datavalue-difference
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</range>

(single node binding attributes) - Selection of instance data node, defined at 7.14.2 Single Node Binding Attributes
common attributes defined in 7.14.1 Common Attributes
start = datavalue - Lexical starting bound for the range, of the same datatype bound to the form control
end = datavalue - Lexical ending bound for the range, of the same datatype bound to the form control
stepSize = datatype-difference - Prefered step-size to use for incrementing or decrementing the value within the form control, of a datatype that can express the difference between two values of the datatype bound to the form control

7.8 submit

Description: This form control submits all or part of the instance data to which it is bound.

Example:

<submit xform="timecard">
  <caption>Submit</caption>
</submit>

Implementation Hints: The default handling for this controls is equivalent to the submitInstance XForms Action.

Example: XML Representation: <submit>
<submit
  (nodeset binding attributes)
  (common attributes)
>
  <!-- unordered: (caption, help?, hint?, alert?, action?) -->
</submit>