W3C

XForms 1.1

W3C Candidate Recommendation 24 April 2008

This version:
http://www.w3.org/TR/2008/CR-xforms11-20080424/
Latest version:
http://www.w3.org/TR/xforms11/
Previous version:
http://www.w3.org/TR/2007/CR-xforms11-20071129/

Editor:
John M. Boyer, IBM

This document is also available in these non-normative formats: diff-marked HTML .

The English version of this specification is the only normative version. Non-normative translations may also be available.


Abstract

XForms is an XML application that represents the next generation of forms for the Web. XForms is not a free-standing document type, but is intended to be integrated into other markup languages, such as XHTML, ODF or SVG. An XForms-based web form gathers and processes XML data using an architecture that separates presentation, purpose and content. The underlying data of a form is organized into instances of data schema (though formal schema definitions are not required). An XForm allows processing of data to occur using three mechanisms:

Thus, XForms accommodates form component reuse, fosters strong data type validation, eliminates unnecessary round-trips to the server, offers device independence and reduces the need for scripting.

XForms 1.1 refines the XML processing platform introduced by [XForms 1.0] by adding several new submission capabilities, action handlers, utility functions, user interface improvements, and helpful datatypes as well as a more powerful action processing facility, including conditional, iterated and background execution, the ability to manipulate data arbitrarily and to access event context information.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document was developed by the W3C Forms Working Group as part of the Forms Activity within the W3C Interaction Domain.

This document is a W3C Candidate Recommendation. W3C publishes a Candidate Recommendation to indicate that the document is believed to be stable and to encourage implementation by the developer community. The W3C Forms Working Group expects to request that the Director advance this document to Proposed Recommendation once the Working Group has provided a test suite and an implementation report to demonstrate at least two interoperable implementations for each test of a required feature and at least one implementation for each test of a feature. The working group does not plan to request to advance to Proposed Recommendation prior to 14 February 2008 and expects sufficient implementation data will be available by 15 May 2008. Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

The results of the public last call review of XForms 1.1 are presented in this last call comments report. There are no features at risk. The working group has prepared a preliminary implementation report to outline present and expected implementations of XForms 1.1. Also note that XForms 1.1 is based on XForms 1.0, which is widely implemented and deployed. For a description of the differences between XForms 1.1 and 1.0, see Section 1.5 Differences between XForms 1.1 and XForms 1.0.

Please send comments about this document to www-forms-editor@w3.org. (with public archive). Please send discussion email to www-forms@w3.org.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Table of Contents

1 About the XForms Specification
    1.1 Background
    1.2 Reading the Specification
    1.3 How the Specification is Organized
    1.4 Documentation Conventions
    1.5 Differences between XForms 1.1 and XForms 1.0
        1.5.1 Model and Instance
        1.5.2 Enhanced Submissions
        1.5.3 Datatypes and Model Item Properties
        1.5.4 Functions and XPath Expressions
        1.5.5 User Interface
        1.5.6 Actions and Events
2 Introduction to XForms
    2.1 An Example
    2.2 Providing XML Instance Data
    2.3 Constraining Values
    2.4 Multiple Forms per Document
3 Document Structure
    3.1 Namespace for XForms
    3.2 XForms Core Attribute Collections
        3.2.1 Common Attributes
        3.2.2 Linking Attributes
        3.2.3 Single-Node Binding Attributes
        3.2.4 Node-Set Binding Attributes
        3.2.5 Model Item Property Attributes
    3.3 The XForms Core Module
        3.3.1 The model Element
        3.3.2 The instance Element
        3.3.3 The submission Element
        3.3.4 The bind Element
    3.4 The XForms Extension Module
        3.4.1 The extension Element
    3.5 The XForms MustUnderstand Module
4 Processing Model
    4.1 Events Overview
    4.2 Initialization Events
        4.2.1 The xforms-model-construct Event
        4.2.2 The xforms-model-construct-done Event
        4.2.3 The xforms-ready Event
        4.2.4 The xforms-model-destruct Event
    4.3 Interaction Events
        4.3.1 The xforms-rebuild Event
        4.3.2 The xforms-recalculate Event
        4.3.3 The xforms-revalidate Event
        4.3.4 The xforms-refresh Event
        4.3.5 The xforms-reset Event
        4.3.6 The xforms-next and xforms-previous Events
        4.3.7 The xforms-focus Event
        4.3.8 The xforms-help and xforms-hint Events
        4.3.9 The xforms-submit Event
        4.3.10 The xforms-submit-serialize Event
    4.4 Notification Events
        4.4.1 The xforms-insert Event
        4.4.2 The xforms-delete Event
        4.4.3 The xforms-value-changed Event
        4.4.4 The xforms-valid Event
        4.4.5 The xforms-invalid Event
        4.4.6 The xforms-readonly Event
        4.4.7 The xforms-readwrite Event
        4.4.8 The xforms-required Event
        4.4.9 The xforms-optional Event
        4.4.10 The xforms-enabled Event
        4.4.11 The xforms-disabled Event
        4.4.12 The DOMActivate Event
        4.4.13 The DOMFocusIn Event
        4.4.14 The DOMFocusOut Event
        4.4.15 The xforms-select and xforms-deselect Events
        4.4.16 The xforms-in-range Event
        4.4.17 The xforms-out-of-range Event
        4.4.18 The xforms-scroll-first and xforms-scroll-last Events
        4.4.19 The xforms-submit-done Event
    4.5 Error Indications
        4.5.1 The xforms-binding-exception Event
        4.5.2 The xforms-compute-exception Event
        4.5.3 The xforms-link-error Event
        4.5.4 The xforms-link-exception Event
        4.5.5 The xforms-output-error Event
        4.5.6 The xforms-submit-error Event
        4.5.7 The xforms-version-exception Event
    4.6 Event Sequencing
        4.6.1 For input, secret, textarea, range, or upload Controls
        4.6.2 For output Controls
        4.6.3 For select or select1 Controls
        4.6.4 For trigger Controls
        4.6.5 For submit Controls
        4.6.6 Sequence: Selection Without Value Change
        4.6.7 Sequence: Value Change
        4.6.8 Sequence: Activating a Trigger
        4.6.9 Sequence: Submission
    4.7 Resolving ID References in XForms
        4.7.1 References to Elements within a repeat Element
        4.7.2 References to Elements within a bind Element
    4.8 DOM Interface for Access to Instance Data
        4.8.1 The getInstanceDocument() Method
        4.8.2 The rebuild() Method
        4.8.3 The recalculate() Method
        4.8.4 The revalidate() Method
        4.8.5 The refresh() Method
    4.9 Feature string for the hasFeature method call
5 Datatypes
    5.1 XML Schema Built-in Datatypes
    5.2 XForms Datatypes
        5.2.1 Additional XForms Datatypes to Allow Empty Content
        5.2.2 xforms:listItem
        5.2.3 xforms:listItems
        5.2.4 xforms:dayTimeDuration
        5.2.5 xforms:yearMonthDuration
        5.2.6 xforms:email
        5.2.7 xforms:card-number
6 Model Item Properties
    6.1 Model Item Property Definitions
        6.1.1 The type Property
        6.1.2 The readonly Property
        6.1.3 The required Property
        6.1.4 The relevant Property
        6.1.5 The calculate Property
        6.1.6 The constraint Property
        6.1.7 The p3ptype Property
    6.2 Schema Constraints
        6.2.1 Atomic Datatype
7 XPath Expressions in XForms
    7.1 XPath Datatypes
    7.2 Evaluation Context
    7.3 References, Dependencies, and Dynamic Dependencies
    7.4 Expression Categories
        7.4.1 Model Binding Expressions and Computed Expressions
        7.4.2 Expressions in Actions and Submissions
        7.4.3 UI Expressions
        7.4.4 UI Binding in other XML vocabularies
        7.4.5 Binding Examples
    7.5 The XForms Function Library
    7.6 Boolean Functions
        7.6.1 The boolean-from-string() Function
        7.6.2 The is-card-number() Function
    7.7 Number Functions
        7.7.1 The avg() Function
        7.7.2 The min() Function
        7.7.3 The max() Function
        7.7.4 The count-non-empty() Function
        7.7.5 The index() Function
        7.7.6 The power() Function
        7.7.7 The random() Function
        7.7.8 The compare() Function
    7.8 String Functions
        7.8.1 The if() Function
        7.8.2 The property() Function
        7.8.3 The digest() Function
        7.8.4 The hmac() Function
    7.9 Date and Time Functions
        7.9.1 The local-date() Function
        7.9.2 The local-dateTime() Function
        7.9.3 The now() Function
        7.9.4 The days-from-date() Function
        7.9.5 The days-to-date() Function
        7.9.6 The seconds-from-dateTime() Function
        7.9.7 The seconds-to-dateTime() Function
        7.9.8 The adjust-dateTime-to-timezone() Function
        7.9.9 The seconds() Function
        7.9.10 The months() Function
    7.10 Node-set Functions
        7.10.1 The instance() Function
        7.10.2 The current() Function
        7.10.3 The id() Function
        7.10.4 The context() Function
    7.11 Object Functions
        7.11.1 The choose() Function
        7.11.2 The event() Function
    7.12 Extension Functions
8 Core Form Controls
    8.1 The XForms Core Form Controls Module
        8.1.1 Implementation Requirements Common to All Form Controls
        8.1.2 The input Element
        8.1.3 The secret Element
        8.1.4 The textarea Element
        8.1.5 The output Element
            8.1.5.1 The mediatype Element (for output)
        8.1.6 The upload Element
            8.1.6.1 The filename Element
            8.1.6.2 The mediatype Element (for upload)
        8.1.7 The range Element
        8.1.8 The trigger Element
        8.1.9 The submit Element
        8.1.10 The select Element
        8.1.11 The select1 Element
    8.2 Common Support Elements
        8.2.1 The label Element
        8.2.2 The help Element
        8.2.3 The hint Element
        8.2.4 The alert Element
    8.3 Common Markup for Selection Controls
        8.3.1 The choices Element
        8.3.2 The item Element
        8.3.3 The value Element
9 Container Form Controls
    9.1 The XForms Group Module
        9.1.1 The group Element
    9.2 The XForms Switch Module
        9.2.1 The switch Element
        9.2.2 The case Element
    9.3 The XForms Repeat Module
        9.3.1 The repeat Element
        9.3.2 Nested Repeats
        9.3.3 Repeat Processing
        9.3.4 User Interface Interaction
        9.3.5 Creating Repeating Structures Via Attributes
        9.3.6 The itemset Element
        9.3.7 The copy Element
10 XForms Actions
    10.1 The action Element
    10.2 The setvalue Element
    10.3 The insert Element
    10.4 The delete Element
    10.5 The setindex Element
    10.6 The toggle Element
        10.6.1 The case Element Child of the toggle Element
    10.7 The setfocus Element
        10.7.1 The control Element Child of the setfocus Element
    10.8 The dispatch Element
        10.8.1 The name Child Element
        10.8.2 The target Child Element
        10.8.3 The delay Child Element
    10.9 The rebuild Element
    10.10 The recalculate Element
    10.11 The revalidate Element
    10.12 The refresh Element
    10.13 The reset Element
    10.14 The load Element
        10.14.1 The resource Element child of load
    10.15 The send Element
    10.16 The message Element
    10.17 Conditional Execution of XForms Actions
    10.18 Iteration of XForms Actions
    10.19 Actions from Other Modules
11 The XForms Submission Module
    11.1 The submission Element
    11.2 The xforms-submit Event
    11.3 The xforms-submit-serialize Event
    11.4 The xforms-submit-done Event
    11.5 The xforms-submit-error Event
    11.6 The Submission Resource
        11.6.1 The resource Element
    11.7 The Submission Method
        11.7.1 The method Element
    11.8 The header Element
        11.8.1 The name Element
        11.8.2 The value Element
    11.9 Submission Options
        11.9.1 The get Submission Method
        11.9.2 The post, multipart-post, form-data-post, and urlencoded-post Submission Methods
        11.9.3 The put Submission Method
        11.9.4 The delete Submission Method
        11.9.5 Serialization as application/xml
        11.9.6 Serialization as multipart/related
        11.9.7 Serialization as multipart/form-data
        11.9.8 Serialization as application/x-www-form-urlencoded
    11.10 Replacing Data with the Submission Response
    11.11 Integration with SOAP
        11.11.1 Representation of SOAP Envelope
        11.11.2 Indicating a SOAP submission
        11.11.3 SOAP HTTP Binding
        11.11.4 Handling the SOAP Response
12 Conformance
    12.1 Conforming XForms Documents
    12.2 Conforming XForms Generators
    12.3 Base Technologies for XForms Processors
    12.4 Conformance Levels
        12.4.1 XForms Model
        12.4.2 XForms Full
13 Glossary Of Terms

Appendices

A References
    A.1 Normative References
    A.2 Informative References
B Insert and Delete Action Patterns for Data Mutations
    B.1 Prepend Element Copy
    B.2 Append Element Copy
    B.3 Duplicate Element
    B.4 Set Attribute
    B.5 Remove Element
    B.6 Remove Attribute
    B.7 Remove Nodeset
    B.8 Copy Nodeset
    B.9 Copy Attribute List
    B.10 Replace Element
    B.11 Replace Attribute
    B.12 Replace Instance with Insert
    B.13 Move Element
    B.14 Move Attribute
    B.15 Insert Element into Non-Contiguous, Heterogeneous Nodeset
C Recalculation Sequence Algorithm
    C.1 Details on Creating the Master Dependency Directed Graph
    C.2 Details on Creating the Pertinent Dependency Subgraph
    C.3 Details on Computing Individual Vertices
    C.4 Example of Calculation Processing
D Privacy Considerations
    D.1 Using P3P with XForms
E Input Modes (Non-Normative)
    E.1 inputmode Attribute Value Syntax
    E.2 User Agent Behavior
    E.3 List of Tokens
        E.3.1 Script Tokens
        E.3.2 Modifier Tokens
    E.4 Relationship to XML Schema pattern facets
    E.5 Examples
F Schema for XForms (Non-Normative)
    F.1 Schema for XML Events
G XForms and Styling (Non-Normative)
    G.1 Pseudo-classes
    G.2 Pseudo-elements
    G.3 Examples
H Complete XForms Examples (Non-Normative)
    H.1 XForms in XHTML
    H.2 Editing Hierarchical Bookmarks Using XForms
    H.3 Survey Using XForms and SVG
I Acknowledgements (Non-Normative)
J Production Notes (Non-Normative)


1 About the XForms Specification

1.1 Background

Forms are an important part of the Web, and they continue to be the primary means for enabling interactive Web applications. Web applications and electronic commerce solutions have sparked the demand for better Web forms with richer interactions. XForms is the response to this demand, and provides a new platform-independent markup language for online interaction between a person (through an XForms Processor) and another, usually remote, agent. XForms are the successor to HTML forms, and benefit from the lessons learned from HTML forms.

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 before specifying the technical details of the various XForms components.

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.

This document uses the terms must, must not, required, shall, shall not, recommended, should, should not, may, and optional in accord with [RFC 2119].

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 outlines the design principles and includes a brief tutorial on 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 an XML Schema description of XForms, references, examples, and other useful information.

1.4 Documentation Conventions

Throughout this document, the following namespace prefixes and corresponding namespace identifiers are used:

xforms: The XForms namespace, e.g. http://www.w3.org/2002/xforms (see 3.1 Namespace for XForms)
html: An XHTML namespace, e.g. http://www.w3.org/1999/xhtml (see [XHTML 1.0])
xs: The XML Schema namespace http://www.w3.org/2001/XMLSchema (see [XML Schema part 1])
xsd: The XML Schema namespace http://www.w3.org/2001/XMLSchema (see [XML Schema part 2])
xsi: The XML Schema for instances namespace http://www.w3.org/2001/XMLSchema-instance (see [XML Schema part 1])
ev: The XML Events namespace http://www.w3.org/2001/xml-events (see [XML Events])
my: Any user defined namespace

This is only a convention; any namespace prefix may be used in practice.

The following typographical conventions are used to present technical material in this document.

Official terms are defined in the following manner: [Definition: You can find most terms in chapter 13 Glossary Of Terms]. Links to terms may be specially highlighted where necessary.

The XML representations of various elements within XForms are presented using the syntax for Abstract Modules in XHTML Modularization [XHTML Modularization].

Examples are set off typographically:

Example item
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 typesetting convention is used for additional commentary:

Note:

A gentle explanation to readers.

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

Issue (sample-implementation-issue):

Issue-Name

A specific issue for which input from implementors is requested, for example as part of the Candidate Recommendation phase.

Resolution:

None recorded.

1.5 Differences between XForms 1.1 and XForms 1.0

This informative section provides an overview of the new features and changed behaviors available in XForms 1.1.

1.5.1 Model and Instance

The model element now must support a version attribute to help authors bridge the transition between XForms 1.0 to XForms 1.1.

The instance element now has a resource attribute that allows instance data to be obtained from a URI only if the instance does not already contain data. By contrast, the src attribute overrides the inline content in an instance. The resource attribute is more useful in systems that must support save and reload of XForms-based documents.

1.5.2 Enhanced Submissions

The submission element offers many new features that allow significantly improved data communications capabilities for XForms, including:

  • Access to SOAP-based web services, RESTful services, ATOM-based services, and non-XML services

  • Improved control over submission processing and serialization

  • Ability to control the submission URI and headers with instance data

  • Targetted instance data replacement capabilities

The submission element now has a resource attribute and resource child element that allow the instance data to dynamically control the submission URI. As a result, the action attribute is deprecated, though still supported in XForms 1.1.

In XForms 1.0, submissions were already more capable than AJAX, based on the ability to automatically update a form with results from HTTP and HTTPS services, including RSS feeds. In XForms 1.1, the method attribute now supports delete as well as any other QName. The method child element also allows the method to be dynamically controlled by instance data. Submission headers can now be added, and even dynamically controlled by instance data, using the header child element. These features complete the capabilities needed for ATOM and RESTful services. XForms 1.1 also offers special submission header behavior through the mediatype attribute to allow communications with SOAP 1.1 and 1.2 web services.

The submission element now supports attributes relevant and validate, which allow form authors to turn off instance data relevance pruning and validity checking. This allows submission to be used to save and reload unfinished data on a server or the local file system.

The submission element now supports the target attribute, which allows partial instance replacement by identifying a node to be replaced with the submission result. The replace attribute also now supports a text setting, which allows the content of the target node, rather than the target node itself, to be replaced with a non-XML (text) submission result.

The submission element now also supports the xforms-submit-serialize event, which allows the form author to provide a custom serialization, such as plain text or the full XForms document, as the submission data. The serialization attribute also provides increased control over the submission data serialization, including the setting none, which allows submission to be used for simple URI activation.

The xforms-submit-done and xforms-submit-error events now have event context information available that provide more information about both successful and failed submissions, such as the response headers of successful submissions and the reason code for failed submissions.

Finally, over a dozen new examples have been added to illustrate submission usage.

1.5.3 Datatypes and Model Item Properties

XForms 1.1 now offers email and card-number datatypes so form authors can easily validate email address and credit card number input values.

To further simplify authoring, XForms 1.1 now also provides its own definitions of the XML Schema datatypes, except the XForms versions permit the empty string. Allowing empty string means that input like an age or a birthdate can be collected without being required input for validity (an empty string is not in the lexical space of XML schema datatypes like xsd:positiveInteger and xsd:date). If an input is required, the form author can still use the XForms versions of the datatypes in combination with the required model item property. The XForms datatypes also aid authoring by allowing type definitions to omit namespace qualification, e.g. type="date" rather than type="xsd:date", if the default namespace of the model is set to XForms.

The readonly model item property was defined to be an inviolate property of the data model. This means it cannot be violated by anything outside of the model item property system, including not just form controls but also XForms actions and instance data access from the DOM interface.

1.5.4 Functions and XPath Expressions

XForms 1.1 now contains many new functions that can be used in calculate and other XPath expressions to enable numerous features, including:

  • basic date math and working with local dates and times: local-date(), local-dateTime(), days-to-date(), seconds-to-dateTime(), and adjust-dateTime-to-timezone()

  • working with tabular data and parallel lists: current(), choose() and context()

  • basic security capabilities: digest(), hmac(), and random()

  • improved numeric and string processing: power(), is-card-number(), and compare()

  • search across instances of a model: two parameter id() function

  • access to context information added to many XForms events: event()

The specification now provides a better classification of binding expression types as well as a more rigorous definition for dynamic dependencies. These definitions ensure that XPath expressions in form controls and actions which use the index() are automatically re-evaluated when appropriate.

Due to the addition of the choose() function, the if() function is still supported but deprecated as futureproofing against the conflict with the if keyword in XPath 2.0.

1.5.5 User Interface

The behavioral description common to all form controls has been improved to indicate default layout styling and rendering requirements for required data.

The output form control has been improved to render non-text mediatypes, particularly images, obtained from instance data.

An example was added to show the use of a DOMActivate handler on an input to automatically initiate a submission once a user enters and commits input, such as a search query.

The processing model and implementation requirements on selection controls were elaborated upon to ensure consistency of behavior between selection data expressed as textual lists versus element lists.

The ability to create wizard-like interfaces with dynamically available form controls has been improved. Details are in the description of improvements to actions.

The specification provides more rigorous definitions and classifications of form controls, which have been applied throughout the specification to ensure proper support of varied features related to form controls, such as events, applicability of model item properties, and focusability.

The XForms repeat has been made more powerful and flexible. The specification now provides rigorous definitions and processing model descriptions for repeated content, including creation, destruction, IDREF resolution and event flow between repeated content and the containing content (which may itself be repeated). The repeat is now capable of operating over any nodeset, not just an homogeneous collection. A formal processing model for repeat index handling has been defined.

1.5.6 Actions and Events

The insert and delete actions have been converted from specialized actions associated with repeat to generalized data insertion and deletion operations. An entire appendix of 15 examples was added to illustrate this additional capability in detail.

All XForms actions, as well as sets of actions, can be executed conditionally or iteratively. Combined with the generalized insert and delete, this means that the information processing power of XForms 1.1 is Turing-complete.

The dispatch action now allows the event name and target to be specified by instance data. A new attribute, delay, has also been added to allow an event to be scheduled for dispatch at a later time. Since the event handler for the event can schedule same event for later dispatch, it is possible in XForms 1.1 to create background daemon tasks.

The setfocus and toggle have been improved to help with creating wizard interfaces and handling dynamically available content. The control to focus and the case to select can now be specified by instance data. These actions have also been improved relative to the recalculation processing model. They now perform deferred updates before their regular processing to ensure the user interface is automatically refreshed.

As part of the improvement to repeat index management, the setindex action now behaves more like setvalue, which means it now sets the flags for automatic recalculation, revalidation and user interface refresh. As well, this action now als performs deferred updates before its regular processing to ensure the user interface is up to date.

Finally, the setvalue action has been improved due to the addition of the context() function. Now it is possible to express the value attribute in terms of the same context node used to evaluate the single node binding. This improves the ability to use setvalue inside of a repeat to set values of instance nodes that are outside of the repeat nodeset based on values that are within the repeat nodeset.

2 Introduction to XForms

XForms has been designed on the basis of several years' experience with HTML forms. HTML forms have formed the backbone of the e-commerce revolution, and having shown their worth, have also indicated numerous ways they could be improved.

The primary difference when comparing XForms with HTML forms, apart from XForms being in XML, is the separation of the data being collected from the markup of the controls collecting the individual values. By doing this, it not only makes XForms more tractable by making it clear what is being submitted where, it also eases reuse of forms, since the underlying essential part of a Form is no longer irretrievably bound to the page it is used in.

A second major difference is that XForms, while designed to be integrated into XHTML, is no longer restricted only to be a part of that language, but may be integrated into any suitable markup language.

XForms has striven to improve authoring, reuse, internationalization, accessibility, usability, and device independence. Here is a summary of the primary benefits of using XForms:

Strong typing

Submitted data is strongly typed and can be checked using off-the-shelf tools. This speeds up form filling since it reduces the need for round trips to the server for validation.

XML submission

This obviates the need for custom server-side logic to marshal the submitted data to the application back-end. The received XML instance document can be directly validated and processed by the application back-end.

Existing schema re-use

This obviates duplication, and ensures that updating the validation rules as a result of a change in the underlying business logic does not require re-authoring validation constraints within the XForms application.

External schema augmentation

This enables the XForms author to go beyond the basic set of constraints available from the back-end. Providing such additional constraints as part of the XForms Model enhances the overall usability of the resulting Web application.

Internationalization

Using XML 1.0 for instance data ensures that the submitted data is internationalization ready.

Enhanced accessibility

XForms separates content and presentation. User interface controls encapsulate all relevant metadata such as labels, thereby enhancing accessibility of the application when using different modalities. XForms user interface controls are generic and suited for device-independence.

Multiple device support

The high-level nature of the user interface controls, and the consequent intent-based authoring of the user interface makes it possible to re-target the user interaction to different devices.

Less use of scripting

By defining XML-based declarative event handlers that cover common use cases, the majority of XForms documents can be statically analyzed, reducing the need for imperative scripts for event handlers.

2.1 An Example

In the XForms approach, forms are comprised of a section that describes what the form does, called the XForms Model, and another section that describes how the form is to be presented.

Consider a simple electronic commerce form that might be rendered as follows:

screen shot of a graphic rendering

It is clear that we are collecting a value that represents whether cash or a credit card is being used, and if a credit card, its number and expiration date.

This can be represented in the XForms model element, which in XHTML would typically be contained within the head section:

<xforms:model>
  <xforms:instance>
    <ecommerce xmlns="">
      <method/>
      <number/>
      <expiry/>
    </ecommerce>
  </xforms:instance>
  <xforms:submission action="http://example.com/submit" method="post" id="submit" includenamespaceprefixes=""/>
</xforms:model>

This simply says that we are collecting three pieces of information (note that we have as yet not said anything about their types), and that they will be submitted using the URL in the action attribute.

XForms defines a device-neutral, platform-independent set of form controls suitable for general-purpose use. The controls are bound to the XForms Model via the XForms binding mechanism, in this simple case using the ref attribute on the controls. In XHTML, this markup would typically appear within the body section (note that we have intentionally defaulted the XForms namespace prefix here):

<select1 ref="method">
  <label>Select Payment Method:</label>
  <item>
    <label>Cash</label>
    <value>cash</value>
  </item>
  <item>
    <label>Credit</label>
    <value>cc</value>
  </item>
</select1>
<input ref="number">
  <label>Credit Card Number:</label>
</input>
<input ref="expiry">
  <label>Expiration Date:</label>
</input>
<submit submission="submit">
  <label>Submit</label>
</submit>

Notice the following features of this design:

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

  • Core form controls always have labels directly associated with them as child elements— this is a key feature designed to enhance accessibility.

  • There is no need for an enclosing form element, as in HTML. (See 2.4 Multiple Forms per Document for details on how to author multiple forms per document)

  • Markup for specifying form controls has been simplified in comparison with HTML forms.

The fact that you can bind form controls to the model like this simplifies integrating XForms into other host languages, since any form control markup may be used to bind to the model.

2.2 Providing XML Instance Data

The XForms Processor can directly submit the data collected as XML. In the example, the submitted data would look like this:

Submitted Data
<ecommerce>
  <method>cc</method>
  <number>1235467789012345</number>
  <expiry>2001-08</expiry>
</ecommerce>

XForms processing keeps track of the state of the partially filled form through this instance data. Initial values for the instance data may be provided or left empty as in the example. Element instance essentially holds a skeleton XML document that gets updated as the user fills out the form. It gives the author full control on the structure of the submitted XML data, including namespace information. When the form is submitted, the instance data is serialized as an XML document. Here is an alternative version of the earlier example:

Model
<xforms:model>
  <xforms:instance>
    <payment method="cc" xmlns="http://commerce.example.com/payment">
      <number/>
      <expiry/>
    </payment>
  </xforms:instance>
  <xforms:submission action="http://example.com/submit" method="post" includenamespaceprefixes="#default"/>
</xforms:model>

In this case the submitted data would look like this:

Submitted Data
<payment method="cc" xmlns="http://commerce.example.com/payment">
  <number>1235467789012345</number>
  <expiry>2001-08</expiry>
</payment>

This design has features worth calling out:

  • There is complete flexibility in the structure of the XML instance data, including the use of attributes. Notice that XML namespaces are used, and that a wrapper element of the author's choosing contains the instance data.

  • Empty elements number and expiry serve as place-holders in the XML structure, and will be filled in with form data provided by the user.

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

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

Binding Form Controls to Instance Nodes with ref
... xmlns:my="http://commerce.example.com/payment"
  ...
  <xforms:select1 ref="@method">...</xforms:select1>
  ...
  <xforms:input ref="my:number">...</xforms:input>
  ...
  <xforms:input ref="/my:payment/my:expiry">...</xforms:input>

Binding expressions are based on XPath [XPath 1.0], including the use of the @ character to refer to attributes, as seen here. Note that for illustrative purposes, the first two expressions make use of the XPath context node, which defaults to the top-level element (here my:payment). The third expression shows an absolute path.

2.3 Constraining Values

XForms allows data to be checked for validity as the form is being filled. In the absence of specific information about the types of values being collected, all values are returned as strings, but it is possible to assign types to values in the instance data. In this example, number should accept digits only, and should have between 14 and 18 digits and expiry should accept only valid month/date combinations.

Furthermore, the credit card information form controls for number and expiry are only relevant if the "cc" option is chosen for method, but are required in that case.

By specifying an additional component, model item properties, authors can include rich declarative validation information in forms. Such information can be taken from XML Schemas as well as XForms-specific additions, such as relevant. Such properties appear on bind elements, while Schema constraints are expressed in an XML Schema fragment, either inline or external. For example:

Declarative Validation with Model Item Properties
... xmlns:my="http://commerce.example.com/payment"...
        
  <xforms:model>
    ...
    <xforms:bind nodeset="/my:payment/my:number"
		 relevant="/my:payment/@method = 'cc'"
		 required="true()"
		 type="my:ccnumber"/>

    <xforms:bind nodeset="/my:payment/my:expiry"
		 relevant="/my:payment/@method = 'cc'"
		 required="true()"
		 type="xsd:gYearMonth"/>

    <xs:schema ...>
      ...
      <xs:simpleType name="ccnumber">
	<xs:restriction base="xsd:string">
	  <xs:pattern value="\d{14,18}"/>
	</xs:restriction>
      </xs:simpleType>
      ...
    </xs:schema>
  </xforms:model>

Note:

In the above example, the relevant expression uses absolute XPath notation (beginning with /) because the evaluation context nodes for computed expressions are determined by the binding expression (see 7.2 Evaluation Context), and so any relative node path in the first bind relevant above would be relative to /my:payment/my:number

2.4 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 a single document contains multiple forms, each form needs a separate model element, each with an id attribute so that they can be referenced from elsewhere in the containing document.

In addition, form controls should specify which model element contains the instance data to which they bind. This is accomplished through a model attribute that is part of the binding attributes. If no model attribute is specified on the binding element, the nearest ancestor binding element's model attribute is used, and failing that, the first XForms Model in document order is used. This technique is called 'scoped resolution', and is used frequently in XForms.

The next example adds an opinion poll to our electronic commerce form.

Adding a poll model
<xforms:model>
  <xforms:instance>
    ...payment instance data...
  </xforms:instance>
  <xforms:submission action="http://example.com/submit" method="post"/>
</xforms:model>
        
<xforms:model id="poll">
  <xforms:instance>
    <helpful/>
  </xforms:instance>
  <xforms:submission id="pollsubmit" .../>
</xforms:model>

Additionally, the following markup would appear in the body section of the document:

Form Controls for poll model
<xforms:select1 ref="/helpful" model="poll">
  <xforms:label>How useful is this page to you?</xforms:label>
  <xforms:item>
    <xforms:label>Not at all helpful</xforms:label>
    <xforms:value>0</xforms:value>
  </xforms:item>
  <xforms:item>
    <xforms:label>Barely helpful</xforms:label>
    <xforms:value>1</xforms:value>
  </xforms:item>
  <xforms:item>
    <xforms:label>Somewhat helpful</xforms:label>
    <xforms:value>2</xforms:value>
  </xforms:item>
  <xforms:item>
    <xforms:label>Very helpful</xforms:label>
    <xforms:value>3</xforms:value>
  </xforms:item>
</xforms:select1>
        
<xforms:submit submission="pollsubmit">
  <xforms:label>Submit</xforms:label>
</xforms:submit>

The main difference here is the use of model="poll", which identifies the instance. Note that submit refers to the submission element by ID and does not require binding attributes.

More XForms examples can be found in H Complete XForms Examples.

3 Document Structure

XForms is an application of XML [XML 1.0] and has been designed for use within other XML vocabularies—in particular within a future version of XHTML [XHTML 1.0]. XForms always requires such a host language. This chapter discusses the structure of XForms that allow XForms to be used with other document types.

3.1 Namespace for XForms

The namespace URI for XForms is http://www.w3.org/2002/xforms. The XForms schema has the target namespace specified and as such is compatible with the XForms 1.0 definition.

XForms used in combination with XHTML 1.0
<switch xmlns="http://www.w3.org/2002/xforms">
  <case id="in" selected="true">
    <input ref="yourname">
      <label>Please tell me your name</label>
      <toggle ev:event="DOMActivate" case="out"/>
    </input>
  </case>
  <case id="out" selected="false">
    <html:p>Hello <output ref="yourname" />
      <trigger id="editButton">
        <label>Edit</label>
        <toggle ev:event="DOMActivate" case="in"/>
      </trigger>
    </html:p>
  </case>
</switch>

The above example is unchanged from the specification in XForms 1.0 (in the example, the prefixes html and ev are defined by an ancestor of the switch element).

3.2 XForms Core Attribute Collections

3.2.1 Common Attributes

The Common Attribute Collection applies to every element in the XForms namespace.

anyAttribute

Foreign attributes are allowed on all XForms elements.

id

The optional id attribute of type xsd:ID assigns an identity to the containing element.

Note:

Elements can be identified using any attribute of type ID (such as xml:id), not just the id attribute defined above.

3.2.2 Linking Attributes

The host language may permit a Linking Attributes Collection to be applied to XForms elements as an alternate means of obtaining content related to the element. An example is the src attribute from [XHTML 1.0]. The schedule by which link traversal occurs is defined by the host language. If the link traversal fails, the host language may dispatch xforms-link-exception or xforms-link-error to the model associated with the in-scope evaluation context node of the element that bears the Linking Attributes Collection for the failed link.

Note:

Section 3.3.2 The instance Element defines attribute src for the instance element.

3.2.3 Single-Node Binding Attributes

The following attributes can be used to define a binding between an XForms element such as a form control or an action and an instance data node defined by an XPath expression.

ref

Binding expression interpreted as XPath. This attribute has no meaning when a bind attribute is present.

model

Optional XForms Model selector. Specifies the ID of an XForms Model to be associated with this binding element. This attribute has no meaning for the current binding element when a bind attribute is present. Rules for determining the context XForms Model are located at 7.2 Evaluation Context.

bind

Reference to a bind element.

In this specification, when an XForms element is declared to have a Single-Node Binding, then the Single-Node Binding is required unless the element explicitly states that it is optional.

In some cases, an XForms element may allow a Single-Node Binding, but one or more attributes in the Single-Node Binding attribute group are inappropriate for that XForms element. In such cases, the exact attributes are listed for the XForms element, but those attributes still express a Single-Node Binding if they appear in the element. For example, the submission element forbids the model attribute because the model is defined to be the one containing the submission, so the attributes ref and bind are listed for submission rather than referring to the Single-Node Binding attribute group, but if a ref or bind attribute is used on a submission, it does express a Single-Node Binding.

When the Single-Node Binding is required, one of ref or bind is required. When bind is used, the node is determined by the referenced bind. See 4.7.2 References to Elements within a bind Element for details on selecting an identified bind that is iterated by one or more containing bind elements. When ref is used, the node is determined by evaluating the XPath expression with the evaluation context described in Section 7.2 Evaluation Context.

First-node rule: When a Single-Node Binding attribute selects a node-set of size > 1, the first node in the node-set, based on document order, is used.

It is an exception (4.5.1 The xforms-binding-exception Event) if the XForms Processor encounters a model attribute IDREF value that refers to an ID not on a model element, or a bind attribute IDREF value that refers to an ID not on a bind element.

3.2.4 Node-Set Binding Attributes

The following attributes define a binding between an XForms element such as a form control or an action and a node-set defined by the XPath expression.

nodeset

Binding expression interpreted as XPath. This attribute has no meaning when a bind attribute is present.

model

Optional XForms Model selector. Specifies the ID of an XForms Model to be associated with this binding element. This attribute has no meaning for the current binding element when a bind attribute is present. Rules for determining the context XForms Model are located at 7.2 Evaluation Context.

bind

Reference to a bind element.

In this specification, when an XForms element is declared to have a Node-Set Binding, then the Node-Set Binding is required unless the element explicitly states that it is optional.

In some cases, an XForms element may allow a Node-Set Binding, but one or more attributes in the Node-Set Binding attribute group are inappropriate for that XForms element. In such cases, the exact attributes are listed for the XForms element, but those attributes still express a Node-Set Binding if they appear in the element. For example, the bind element only allows the nodeset attribute. The model and bind attributes are not allowed on a bind element, but if the nodeset attribute appears on a bind element, it does express a Node-Set Binding.

When the Node-Set Binding is required, one of nodeset or bind is required. When bind is used, the node-set is determined by the referenced bind. See 4.7.2 References to Elements within a bind Element for details on selecting an identified bind that is iterated by one or more containing bind elements. When nodeset is used, the node-set is determined by evaluating the XPath expression with the evaluation context described in Section 7.2 Evaluation Context.

It is an exception (4.5.1 The xforms-binding-exception Event) if the XForms Processor encounters a model attribute IDREF value that refers to an ID not on a model element, or a bind attribute IDREF value that refers to an ID not on a bind element.

3.2.5 Model Item Property Attributes

This collection contains one attribute for each model item property, with an attribute name exactly matching the name of the model item property, as defined in 6.1 Model Item Property Definitions.

3.3 The XForms Core Module

The XForms Core Module defines the major structural elements of XForms, intended for inclusion in a containing document. The elements and attributes included in this module are:

ElementAttributesMinimal Content Model
modelCommon, Events, functions (QNameList), schema (list of xsd:anyURI), version (xforms:versionList)(instance|xs:schema| submission|bind|Action)*
instanceCommon, src (xsd:anyURI), resource (xsd:anyURI)(ANY)
submission

Common
ref (binding-expression)
bind (xsd:IDREF)
resource (xsd:anyURI)
action (xsd:anyURI) [deprecated]
mode ("asynchronous"|"synchronous")
method ("post"|"get"|"put"|"delete"|"multipart-post"|"form-data-post"|"urlencoded-post"|Any other NCName|QNameButNotNCName)
validate (xsd:boolean)
relevant (xsd:boolean)
serialization ("application/xml"|"application/x-www-form-urlencoded"|"multipart/related"|"multipart/form-data"|"none")
version (xsd:NMTOKEN)
indent (xsd:boolean)
mediatype (xsd:string)
encoding (xsd:string)
omit-xml-declaration (xsd:boolean)
standalone (xsd:boolean)
cdata-section-elements (QNameList)
replace ("all"|"instance"|"text"|"none" | QNameButNotNCName)
instance (xsd:IDREF)
target (nodeset XPath Expression)
separator (';' | '&')
includenamespaceprefixes (xsd:NMTOKENS)

(resource | method | header)*, Action*
bindCommon, Model Item Properties, nodeset (model-binding-expression)(bind)*

Elements defined in the XForms Actions module, when that module is included, are also allowed in the content model of model and submission, as shown above.

Within the containing document, these structural elements are typically not rendered.

The XForms Processor must ignore any foreign-namespaced attributes that are unrecognized.

Note that the presence of foreign namespaced elements is subject to the definition of the containing or compound document profile.

3.3.1 The model Element

This element represents a form definition and is used as a container for elements that define the XForms Model. No restriction is placed on how many model elements may exist within a containing document.

Common Attributes: Common, Events

Attributes from XML Events are allowed on this element to facilitate creating observers. This element is not an XForms Action.

Special Attributes:

functions

Optional space-separated list of XPath extension functions (represented by QNames) required by this XForms Model. Guidance on the use of this attribute is at 7.12 Extension Functions.

schema

Optional list of xsd:anyURI links to XML Schema documents outside this model element. The XForms Processor must process all Schemas listed in this attribute. Within each XForms Model, there is a limit of one Schema per namespace declaration, including inline and linked Schemas.

The schema definitions for a namespace are determined to be applicable to instance nodes based on an instance schema validation episode initialized to lax processing. When an element lacks a schema declaration, the XML Schema specification defines the recursive checking of children and attributes as optional. For this specification, this recursive checking is required. Schema processing for a node with matching schema declarations is governed by its content processing definition, which is strict by default.

Note:

The schema list may include URI fragments referring to elements located outside the current model elsewhere in the containing document; e.g. "#myschema". xs:schema elements located inside the current model need not be listed.

version

Optional attribute with a default value of empty string and legal values defined by the datatype xforms:versionList. Examples are "1.0" and "1.0 1.1". If one or more versions are indicated by this attribute on the default model, then an XForms Processor must support at least one of the listed language versions of XForms. Otherwise, the XForms Processor must terminate processing after dispatching the event xforms-version-exception to the default model. If the XForms Processor supports more than one language version indicated by the version setting on the default model or if the version setting on the default model is empty string (whether specified or by default), then the XForms Processor may execute the XForms content using any language conformance level available to it. If any non-default model has a version setting that is incompatible with the language version selected by the XForms Processor, then the XForms Processor must terminate processing after dispatching the event xforms-version-exception to the default model.

Examples:

This example shows a simple usage of model, with the XForms namespace defaulted:
<model id="Person" schema="MySchema.xsd">
  <instance resource="http://example.com/cgi-bin/get-instance" />
  ...
</model>
Handler for xforms-version-exception
<model>
  <message level="modal" ev:event="xforms-version-exception" ref="event('errorinformation')"/>
  ...
</model>
...
<model id="m2" version="1.1">
  ...
</model>

Since the version attribute is not specified on the model, the XForms Processor may choose any language conformance level, which may be incompatible with the version setting of the second model. Therefore, the message action occurs during initialization of the second model due to its version incompatibility with the default model.

An Example of Differing but Compatible Version Settings
<model version="1.0 1.1">
  ...
</model>
...
<model id="m2">
  ...
</model>

Since the version attribute is not specified on the second model, it is compatible with any choice made based on the version setting on the default model.

3.3.2 The instance Element

This optional element contains or references initial instance data.

Common Attributes: Common

Special Attributes:

src

Optional link to externally defined initial instance data. If the link traversal fails, it is treated as an exception (4.5.4 The xforms-link-exception Event).

resource

Optional link to externally defined initial instance data. If the link is traversed and the traversal fails, it is treated as an exception (4.5.4 The xforms-link-exception Event).

If the src attribute is given, then it takes precedence over inline content and the resource attribute, and the XML data for the instance is obtained from the link. If the src attribute is omitted, then the data for the instance is obtained from inline content if it is given or the resource attribute otherwise. If both the resource attribute and inline content are provided, the inline content takes precedence.

If the initial instance data is given by a link (from src or resource), then the instance data is formed by creating an XPath data model of the linked resource. If the link cannot be traversed, then processing halts after dispatching an xforms-link-exception with a resource-uri of the link that failed.

If the initial instance data is given by inline content, then instance data is obtained by first creating a detached copy of the inline content (including namespaces inherited from the enveloping ancestors), then creating an XPath data model over the detached copy. The detached copy must consist of content that would be well-formed XML if it existed in a separate document. Note that this restricts the element content of instance to a single child element.

If creation of the XPath data model for the instance data fails due to an XML error, then processing halts after dispatching an xforms-link-exception with a resource-uri indicating either the URI for an external instance, a fragment identifier URI reference (including the leading # mark) for an identified internal instance, or empty string for an unidentified internal instance. This exception could happen, for example, if the content had no top-level element or more than one top-level element, neither of which is permitted by the grammar of XML.

Note:

All data relevant to the XPath data model must be preserved during processing and as input to submission serialization, including processing instructions, comment nodes and all whitespace.

Note:

XForms authors who need additional control over the serialization of namespace nodes can use the includenamespaceprefixes attribute on the submission element.

3.3.3 The submission Element

Details about the submission element and its processing are described in 11 The XForms Submission Module.

3.3.4 The bind Element

Element bind selects a node-set from the instance data with either a model binding expression in the nodeset attribute or the default of the in-scope evaluation context node. Other attributes on element bind encode model item properties to be applied to each node in the node-set. When bind has an attribute of type xsd:ID, the bind then associates that identifier with the selected node-set.

Common Attributes: Common, Model Item Properties (Optional)

Special Attributes:

nodeset

An optional attribute containing a model binding expression that selects the set of nodes on which this bind operates. If the attribute is omitted, the default is the in-scope evaluation context node.

See 6 Model Item Properties for details on model item properties.

See 7.2 Evaluation Context for details on how the evaluation context is determined for each attribute of the bind element.

3.4 The XForms Extension Module

There are many different ways a host language might include XForms. One approach uses only well-formed processing, disregarding validation. Another case uses strict validation, for example XHTML 1.0, in which only predefined elements are allowed. Another common approach is to allow unregulated content in a few select places. A host language that chooses this option can use the Extension module.

ElementAttributesMinimal Content Model
extensionCommon ANY

3.4.1 The extension Element

Optional element extension is a container for application-specific extension elements from any namespace other than the XForms namespace. This specification does not define the processing of this element.

Common Attributes: Common

For example, RDF metadata could be attached to an individual form control as follows:

<input ref="dataset/user/email" id="email-input">
  <label>Enter your email address</label>
  <extension>
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about="#email-input">
        <my:addressBook>personal</my:addressBook>
      </rdf:Description>
    </rdf:RDF>
  </extension>
</input>

3.5 The XForms MustUnderstand Module

This section is deleted.

4 Processing Model

This chapter defines the XForms Processing Model declaratively by enumerating the various states attained by an XForms Processor and the possible state transitions that exist in each of these states. The chapter enumerates the pre-conditions and post-conditions that must be satisfied in each of these states. XForms Processors may be implemented in any manner, so long as the end results are identical to that described in this chapter.

State transitions are in general initiated by sending events to parts of the XForms tree. The XForms Processing Model consists of events in the following categories:

4.1 Events Overview

XForms processing is defined in terms of events, event handlers, and event responses. XForms uses the events system defined in [DOM2 Events][XML Events], with an event capture phase, arrival of the event at its Target, and finally the event bubbling phase.

Event nameCancelable?Bubbles?Target element
4.2 Initialization Events
xforms-model-constructNoYes model
xforms-model-construct-doneNoYes model
xforms-readyNoYes model
xforms-model-destructNoYes model
4.3 Interaction Events
xforms-rebuildYesYes model
xforms-recalculateYesYes model
xforms-revalidateYesYesmodel
xforms-refreshYesYes model
xforms-resetYesYes model
xforms-previousYesNoCore Form Controls
xforms-nextYesNoCore Form Controls
xforms-focusYesNoCore Form Controls|group|switch|repeat
xforms-helpYesYesCore Form Controls
xforms-hintYesYesCore Form Controls
xforms-submitYesYes submission
xforms-submit-serializeNoYessubmission
4.4 Notification Events
xforms-insertNoYesinstance
xforms-deleteNoYesinstance
xforms-value-changedNoYesCore Form Controls
xforms-validNoYesCore Form Controls|group|switch
xforms-invalidNoYesCore Form Controls|group|switch
xforms-readonlyNoYesCore Form Controls|group|switch
xforms-readwriteNoYesCore Form Controls|group|switch
xforms-requiredNoYesCore Form Controls|group|switch
xforms-optionalNoYesCore Form Controls|group|switch
xforms-enabledNoYesCore Form Controls|group|switch
xforms-disabledNoYesCore Form Controls|group|switch
DOMActivateYesYesCore Form Controls
DOMFocusInNoYesCore Form Controls|group|switch|repeat
DOMFocusOutNoYesCore Form Controls|group|switch|repeat
xforms-selectNoYesitem or case
xforms-deselectNoYesitem or case
xforms-in-rangeNoYesCore Form Controls
xforms-out-of-rangeNoYesCore Form Controls
xforms-scroll-firstNoYes repeat
xforms-scroll-lastNoYes repeat
xforms-submit-doneNoYessubmission
4.5 Error Indications
xforms-binding-exceptionNoYesany element that can contain a binding expression
xforms-compute-exceptionNoYesmodel
xforms-link-errorNoYesmodel
xforms-link-exceptionNoYesmodel
xforms-output-errorNoYesoutput
xforms-submit-errorNoYessubmission
xforms-version-exceptionNoYesThe default model

4.2 Initialization Events

This section defines the various stages of the initialization phase. The processor begins initialization by dispatching an event xforms-model-construct to each XForms Model in the containing document. How the XForms Processor itself is requested to initialize is implementation dependent.

4.2.1 The xforms-model-construct Event

Dispatched to each XForms model by the XForms processor.

Target: model

Bubbles: Yes

Cancelable: No

Context Info: None

The default action for this event results in the following:

  1. All XML Schemas are loaded. If an error occurs while attempting to access or process a remote document, processing halts with an exception (4.5.4 The xforms-link-exception Event).

  2. For each instance element, an XPath data model [7 XPath Expressions in XForms] is constructed from it as described in Section 3.3.2 The instance Element. If there are no instance elements, the data model is not constructed in this phase, but during user interface construction (4.2.2 The xforms-model-construct-done Event).

  3. If applicable, P3P initialization occurs. [P3P 1.0]

  4. Perform the behaviors of xforms-rebuild, xforms-recalculate, and xforms-revalidate in sequence on this model element without dispatching events to invoke the behaviors. The notification event markings for these operations are discarded, and the xforms-refresh behavior is not performed since the user interface has not yet been initialized.

After all XForms Models have been initialized, an xforms-model-construct-done event is dispatched to each model element.

4.2.2 The xforms-model-construct-done Event

Dispatched after the completion of xforms-model-construct processing.

Target: model

Bubbles: Yes

Cancelable: No

Context Info: None

The default action for this event happens once, no matter how many XForms Models are present in the containing document, and results in the following, for each form control:

Processing can proceed in one of two different ways depending on whether an instance in a model exists when the first form control is processed.

If the instance referenced on the form control existed when the first form control was processed:

  1. The single node binding expression is evaluated, if it exists on the form control, to ensure that it points to a node that exists. If this is not the case then the form control should behave in the same manner as if it had bound to a model item with the relevant model item property resolved to false.

  2. Otherwise, the user interface for the form control is created and initialized.

If the instance referenced on the form control did not exist when the first form control for the same instance was processed:

  1. For the first reference to an instance a default instance is created by following the rules described below.

    1. A root instanceData element is created.

    2. An instance data element node will be created using the binding expression from the user interface control as the name. If the name is not a valid QName, processing halts with an exception (4.5.1 The xforms-binding-exception Event).

  2. For the second and subsequent references to an instance which was automatically created the following processing is performed:

    1. If a matching instance data node is found, the user interface control will be connected to that element.

    2. If a matching instance data node is not found, an instance data node will be created using the binding expression from the user interface control as the name. If the name is not a valid QName, processing halts with an exception (4.5.1 The xforms-binding-exception Event).

The above steps comprise the default processing of xforms-model-construct-done.

After all form controls have been initialized and all xforms-model-construct-done events have been processed, an xforms-ready event is dispatched to each model element.

4.2.3 The xforms-ready Event

Dispatched as part of xforms-model-construct-done processing.

Target: model

Bubbles: Yes

Cancelable: No

Context Info: None

The default action for this event results in the following: None; notification event only.

4.2.4 The xforms-model-destruct Event

Dispatched by the processor to advise of imminent shutdown of the XForms Processor, which can occur from user action, or from the load XForms Action, or as a result of form submission.

Target: model

Bubbles: No

Cancelable: No

Context Info: None

The default action for this event results in the following: None; notification event only.

4.3 Interaction Events

4.3.1 The xforms-rebuild Event

Dispatched in response to: a request to rebuild the internal data structures that track computational dependencies within a particular XForms Model.

Target: model

Bubbles: Yes

Cancelable: Yes

Context Info: None

The default action for this event results in the following:

All model item properties are initialized by processing all bind elements in document order. For each bind:

  1. If the attribute nodeset is attached to the bind, it is evaluated to select an XPath node-set. Otherwise, if the bind does not have a nodeset attribute, then the selected XPath node-set consists of the in-scope evaluation context.

  2. For each node in the selected XPath node-set, model item properties are applied according to the remaining attributes on the bind element (for details on the model item properties, see 6 Model Item Properties). If a node already contains a model item property of the same name due to the processing of prior bind elements, then XForms processing for the containing document halts with an exception (4.5.1 The xforms-binding-exception Event).

  3. For each node in the selected XPath node-set, any child bind elements are recursively processed as described in the three points of this list.

After initial processing of the bind elements, the computational dependency data structures are rebuilt, and then the change list L is set to contain references to all instance nodes that have an associated computational expression so that a full recalculation is performed the next time the behavior of xforms-recalculate is invoked.

4.3.2 The xforms-recalculate Event

Dispatched in response to: a request to recalculate all calculations associated with a particular XForms Model.

Target: model

Bubbles: Yes

Cancelable: Yes

Context Info: None

The default action for this event results in the following:

The values of all instance data items match their associated 'calculate' constraints, if any. All model item properties that can contain computed expressions are resolved. In addition to contributing further node value changes that will cause xforms-value-changed notifications in xforms-refresh, the model item properties that change are marked to help xforms-refresh to determine the notification events to dispatch.

  • If the required model item property changes, then either the xforms-required event must be marked for dispatch if required is true or the xforms-optional event must be marked for dispatch if required is false. Marking one of these events for dispatch unmarks the other.

  • If the readonly model item property changes, then either the xforms-readonly event must be marked for dispatch if readonly is true or the xforms-readwrite event must be marked for dispatch if readonly is false. Marking one of these events for dispatch unmarks the other.

  • If the relevant model item property changes, then either the xforms-enabled event must be marked for dispatch if relevant is true or the xforms-disabled event must be marked for dispatch if relevant is false. Marking one of these events for dispatch unmarks the other.

An XPath expression is bound either to the value or to a model item property (e.g., required, relevant) of one or more instance nodes. The combination of an XPath expression with a single instance node's value or model item property is considered as a single computational unit, a compute, for the purposes of recalculation.

When it is time to recalculate a model item property, the XPath expression is evaluated. The evaluation context is determined from the model binding expression that applied the model item property, as defined for computed expressions in 7.2 Evaluation Context. The XPath expression may reference or refer to another instance node, in which case the value of the instance node is referenced. Each referenced instance node has as dependents those computes which directly refer to the instance node. References to the current node's value in calculate expressions are explicitly ignored, i.e., if an expression associated with a compute refers to the instance node associated with the compute, then the instance node does not take itself as a dependent. A compute is computationally dependent on an instance node (whose value may or may not be computed) if there is a path of dependents leading from the instance node through zero or more other instance nodes to the compute. A compute is part of a circular dependency if it is computationally dependent on itself.

Note:

Referring to a node's value in a calculate on the node, as in the following example, may have effects that vary by implementation: <bind nodeset="x" calculate=".+1"/>. Model item properties other than calculate, such as required or readonly are well-defined in the presence of self-references.

Note:

An example of a calculate formula that contains a self-reference (i.e. that refers to the node it calculates) appears in Section 6.1.2 The readonly Property. The example enforces a default value for a node and, as mentioned above, does not create a circular dependency. An example of a circular dependency is <bind nodeset="A|B" calculate="../A + ../B"/>. In this example, node A depends in part on B, and node B depends in part on A.

When a recalculation event begins, there will be a list L of one or more instance nodes whose values may have been changed, e.g., by user input being propagated to the instance or by a setvalue action.

  1. An XForms Processor must recalculate computes for nodes in L, if any, and nodes that are computationally dependent on nodes in L.

  2. An XForms Processor must perform only a single recalculation of each compute that is computationally dependent on one or more of the elements in L.

  3. An XForms Processor must recalculate a compute C after recalculating all computes of instance nodes on which C is computationally dependent. (Equivalently, an XForms Processor must recalculate a compute C before recalculating any compute that is computationally dependent on the instance node associated with C.)

  4. Finally, if a compute is part of a circular dependency and also computationally dependent on an element in L, then an XForms processor must report an exception (4.5.2 The xforms-compute-exception Event).

C Recalculation Sequence Algorithm describes one possible method for achieving the required recalculation behavior.

4.3.3 The xforms-revalidate Event

Dispatched in response to: a request to revalidate a particular XForms Model.

Target: model

Bubbles: Yes

Cancelable: Yes

Context Info: None</p