Copyright © 2001 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use, and software licensing rules apply.
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 started work on developing an effective replacement. This document defines "XForms", W3C's name for the next generation of web forms.
Last Update: $Date: 2001/12/06 22:53:54 $
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 Mountain View 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.
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 Introduction to XForms
2.1 Purpose and Presentation
2.2 Current
Approach: HTML
2.3 Transition to
XForms
2.4 Providing
XML Instance Data
2.5 Constraining
Values
2.6 Multiple
Forms per Document
2.7 Complete
Document
3 Terminology
4 Document Structure
4.1 The
XForms Namespace
4.2 Horizontally
Applicable Markup
4.3 XForms Head
Elements
4.3.1 model
4.3.2 instance
4.3.3 schema
4.3.4 submitInfo
4.3.5 bind
4.3.6 privacy
4.3.7 action
4.3.8 extension
4.4 XForms and
XLink
4.4.1 XLink Conformance and
Examples
5 Datatypes
5.1 XML Schema
Built-in Datatypes
5.2 XForms
Datatypes
5.2.1 listItem
5.2.2 listItems
6 Constraints
6.1
XForms Constraints
6.1.1 type
6.1.2 readOnly
6.1.3 required
6.1.4 relevant
6.1.5 calculate
6.1.6 isValid
6.1.7 maxOccurs
6.1.8 minOccurs
6.2 Schema
Constraints
6.2.1 Atomic Datatype
6.3 Additional
Schema Examples
6.3.1 Closed Enumeration
6.3.2 Open Enumeration
6.3.3 Union
6.3.4 Lists
6.4 Binding
6.4.1 bind
6.4.2 Binding Constraints
6.4.3 Binding References
7 XPath Expressions in XForms
7.1
Datatypes
7.2 Instance
Data
7.3 Evaluation
Context
7.4 Forms Core Function
Library
7.4.1 Boolean Methods
7.4.1.1
boolean-from-string()
7.4.1.2
if()
7.4.2 Number Methods
7.4.2.1
avg()
7.4.2.2
min()
7.4.2.3
max()
7.4.2.4
count-non-empty()
7.4.2.5
cursor()
7.4.3 String Methods
7.4.3.1
property()
7.4.3.2
now()
8 Form Controls
8.1 input
8.2 textarea
8.3 secret
8.4 output
8.5 upload
8.6 range
8.7 button
8.8 submit
8.9
selectOne
8.10
selectMany
8.11 Common Markup
for selection controls
8.11.1 choices
8.11.2 item
8.11.3 itemset
8.11.4 value
8.11.5 itemref
8.12 Common
Markup
8.12.1 Common Attributes
8.12.2 Single Node Binding Attributes
8.12.3 Nodeset Binding Attributes
8.12.4 Common Child Elements
8.12.4.1
caption
8.12.4.2
help
8.12.4.3
hint
8.12.4.4
alert
8.12.4.5
extension
9 XForms Actions
9.1
dispatch
9.2
refresh
9.3
recalculate
9.4
revalidate
9.5
setFocus
9.6
loadURI
9.7
setValue
9.8
submitInstance
9.9
resetInstance
9.10
setRepeatCursor
9.11
insert
9.12
delete
9.13
toggle
9.14
script
9.15 message
9.16
action
10 XForms User Interface
10.1 Grouping Form
Controls
10.2 Conditional
Constructs For Dynamic User Interfaces
10.3 Repeating
Structures
10.3.1 Repeat Processing
10.3.2 User Interface Interaction
11 Processing Model
11.1 Events
Overview
11.2 Initialization
Events
11.2.1 xforms:modelConstruct
11.2.2 xforms:modelInitialize
11.2.3 xforms:initializeDone
11.2.4 xforms:UIInitialize
11.2.5 xforms:formControlInitialize
11.3 Interaction
Events
11.3.1 DOM Mutation Events
11.3.2 xforms:next and xforms:previous
11.3.3 xforms:focus and xforms:blur
11.3.4 xforms:activate
11.3.5 xforms:valueChanging
11.3.6 xforms:valueChanged
11.3.7 xforms:scrollFirst
11.3.8 xforms:scrollLast
11.3.9 xforms:insert and xforms:delete
11.3.10 xforms:select and xforms:deselect
11.3.11 xforms:help and xforms:hint
11.3.12 xforms:alert
11.3.13 xforms:valid
11.3.14 xforms:invalid
11.3.15 xforms:refresh
11.3.16 xforms:revalidate
11.3.17 xforms:recalculate
11.3.18 xforms:reset
11.4 XForms
Submit
11.4.1 xforms:submit
11.4.2 application/x-www-form-urlencoded
11.4.3 multipart/form-data
11.4.4 text/xml
11.4.4.1
Binary Content
11.5 Error
Indications
11.5.1 xforms:schemaConstraintsError
11.5.2 xforms:traversalError
11.5.3 xforms:invalidDatatypeError
12 Conformance
12.1 Conformance
Levels
12.1.1 XForms Basic
12.1.2 XForms Full
12.2 Conformance
Description
12.2.1 Conforming XForms Processors
12.2.2 Conforming XForms Containing
Documents
12.2.3 Conforming XForms Generators
A Schema for XForms
A.1 Schema for
XLink
A.2 Schema for XML
Events
B Input Modes
B.1 List of Possible
Input Modes
B.1.1 Questionable Values
B.1.2 Excluded Values
C References
C.1 Normative
References
C.2
Informative References
D Recalculation Sequence Algorithm
(Non-Normative)
D.1
Details on Creating the Master Dependency Directed Graph
D.2
Details on Creating the Pertinent Dependency Subgraph
D.3 Details on Computing Individual
Vertices
D.4 Example of Calculation
Processing
E Changelog (Non-Normative)
E.1 Changes to Chapter
Document Structure
E.2 Changes to Chapter
Datatypes
E.3 Changes to Chapter
Constraints
E.4 Changes to Chapter
XPath Expressions in XForms
E.5 Changes to Chapter
Form Controls
E.6 Changes to Chapter
XForms Actions
E.7 Changes to Chapter
XForms User Interface
E.8 Changes to Chapter
Processing Model
E.9 Changes to Chapter
Conformance
E.10 Changes to
Appendix Schema for XForms
F Acknowledgments (Non-Normative)
G Production Notes (Non-Normative)
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 HTML 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.
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.
This document uses the terms may, must, and should in accord with RFC 2119.
The specification is organized into the following chapters:
An introduction to XForms. The introduction includes a brief tutorial on XForms, and a discussion of design principles.
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 contain a normative description of XForms described in XML Schema, information on references, and other useful information.
The following highlighting and typography is used to present technical material in this document:
Throughout this document, the following namespace prefixes and corresponding namespace identifiers are used:
xforms: The XForms namespace 4.1 The XForms Namespace
html: The XHTML namespace [XHTML 1.0]
xsd: The XML Schema namespace [XML Schema part 1]
xsi: The XML Schema for instances namespace [XML Schema part 1]
xlink: The XLink namespace [XLink]
ev: The XML Events namespace [XML Events]
my: Any user defined namespace
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><example count = xsd:integer size = (small | medium | large) : medium > <!-- Content: (allowed-content) --> </example>
count - description of this attribute
size - description of this attribute
Certain common attributes 4.2 Horizontally Applicable Markup are not shown in the syntax representations except when special attention needs to be called to their presence.
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.
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-Name
A specific issue to which input from readers is requested, not intended for final publication.
For diff-marked formatted text, note that newly added text appears like this, changed text appears like this, and deleted text appears like this.
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.
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 HTML forms didn't separate the purpose of a form from its presentation; additionally, they only offered a restricted representation for data captured through the form.
Here is a summary of the primary benefits of using XForms:
Submitted data is strongly typed and can be checked using off-the-shelf tools. Type validation rules help client-side validation.
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.
This enables the XForms author 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.
This obviates the need for custom server-side logic to marshall the submitted data to the application back-end. The received XML instance document can be directly validated and processed by the application back-end.
Using XML 1.0 ensures that the submitted data is internationalized.
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.
The high-level nature of the user interface controls, and the consequent intent-based authoring of the user interface makes it possible to re-purpose the user interaction to different devices.
By defining XML-based declarative event handlers such as
setFocus, message, and setValue
that cover common use cases, the majority of XForms documents
remain statically analyzable as opposed to imperative program
code.
Consider a simple eCommerce form authored in HTML:
<html>
<head>
<title>eCommerce Form</title>
</head>
<body>
<form action="http://example.com/submit" method="post">
<table summary="Payment method selector">
<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:
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. The XForms standard greatly
improve the expressive capabilities of electronic forms.
| Editorial note: T. V. Raman | |
|
Note that
xforms:xform from the
previous draft is now renamed to xforms:model; the
earlier xforms:model is now named
xforms:schema |
|
With 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. The only presentation option defined in the XForms 1.0 specification is the XForms User Interface, which is a device-independent, platform-neutral set of form controls suitable for general-purpose use. This flexible architecture, however, allows others to attach user interfaces to an XForms Model, as illustrated here:
The simplest case involves authoring the new XForms form
controls, leaving out the other sections of the form. To convert
the previous form into XForms this way, a model
element is needed in the head section of the
document:
<xforms:model> <xforms:submitInfo action="http://examples.com/submit" id="submit"/> </xforms:model>
With these changes to the containing document, the previous example could be rewritten like this (note that we have intentionally defaulted the XForms namespace prefix in this example):
<selectOne ref="as">
<caption>Select Payment Method</caption>
<choices>
<item>
<caption>Cash</caption>
<value>cash</value>
</item>
<item>
<caption>Credit</caption>
<value>credit</value>
</item>
</choices>
</selectOne>
<input ref="cc">
<caption>Credit Card Number</caption>
</input>
<input ref="exp">
<caption>Expiration Date</caption>
</input>
<submit>
<caption>Submit</caption>
</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—this is a key feature designed to enhance the accessibility of forms.
There is no need for an enclosing form element, as
in HTML. See (See 2.6 Multiple
Forms per Document for details on how to author multiple
forms per page)
Markup for specifying form controls has been simplified
Data gets 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
specified in each form control via attribute ref. In
this example, the submitted data would look like this:
<instanceData> <as>Credit</as> <cc>1235467789012345</cc> <exp>2001-08</exp> </instanceData>
Authors will often desire greater control over exact construction of the submitted instance data. XForms allows data to be checked for validity interactively as the form is being filled. One common case might be submitting 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 in the form of a skeleton XML instance,
including namespace information. The instance data starts off with
any initial values for the form, is updated as the user fills the
form, and eventually is serialized and submitted. The initial
instance data is defined in the instance element
inside the model element, as follows:
<xforms:model>
<xforms:instance>
<payment as="credit" xmlns="http://commerce.example.com/payment">
<cc/>
<exp/>
</payment>
</xforms:instance>
<xforms:submitInfo action="http://example.com/submit" method="post"/>
</xforms:model>
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 that a wrapper element of the author's choosing wraps the instance data.
Empty elements cc and 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, the
ref attributes on the form controls need to point to the
proper part of the instance data, using binding
expressions:
.. xmlns:my="http://commerce.example.com/payment"...
<xforms:selectOne ref="my:payment/@as">
...
<xforms:input ref="my:payment/my:cc">
...
<xforms:input ref="my:payment/my:exp">
Binding expressions are based on XPath
[XPath 1.0], including the use of the @ character
to refer to attributes, as seen here.
Referring to the earlier HTML form in 2.2 Current Approach: HTML, 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 form controls cc and
exp are only relevant if the "credit" option is chosen
in the as form control.
The credit card information form controls cc and
exp should be required when the "credit" option is
chosen in the as form control.
The form control cc should accept digits only, and
should have between 14 and 18 digits.
The form control exp should accept only valid
month/date combinations.
By specifying an additional component,
model item constraints, authors can include rich
declarative datatype and validation information in forms, taken from XML Schema datatypes and also
XForms-specific constraints, such as
relevant.
XForms constraints appear on bind elements, while
Schema
constraints are expressed in an XML Schema fragment, either
inline or external. For example:
... xmlns:my="http://commerce.example.com/payment"...
<xforms:bind ref="my:payment/my:cc"
relevant="my:payment/[@as == 'credit']"
required="true"
type="my:cc"/>
<xforms:bind ref="my:payment/my:exp"
relevant="my:payment/[@as == 'credit']"
required="true"
type="xsd:gYearMonth"/>
<xforms:schema>
<xsd:schema ...>
...
<xsd:simpleType name="cc">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{14,18}"/>
</xsd:restriction>
</xsd:simpleType>
...
</xsd:schema>
</xforms:schema>
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
model elements are needed. The first model
element may omit a unique id attribute (as have all
the examples above), but subsequent model 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 model element
contains the instance data to which they bind. This is accomplished
through a model attribute alongside the
ref attribute. this. The default for the model
attribute is to refer to the first model element 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 document:
<xforms:model>
<xforms:instance>
...payment instance data...
</xforms:instance>
<xforms:submitInfo action="http://example.com/submit" method="post"/>
</xforms:model>
<xforms:model id="poll">
<xforms:submitInfo .../>
</xforms:model>
Additionally, the following markup would appear in the body section of the document:
<xforms:selectOne ref="pollOption" model="poll">
<xforms:caption>How useful is this page to you?</xforms:caption>
<xforms:choices>
<xforms:item>
<xforms:caption>Not at all helpful</xforms:caption>
<xforms:value>0</xforms:value>
</xforms:item>
<xforms:item>
<xforms:caption>Barely helpful</xforms:caption>
<xforms:value>1</xforms:value>
</xforms:item>
<xforms:item>
<xforms:caption>Somewhat helpful</xforms:caption>
<xforms:value>2</xforms:value>
</xforms:item>
<xforms:item>
<xforms:caption>Very helpful</xforms:caption>
<xforms:value>3</xforms:value>
</xforms:item>
</xforms:choices>
</xforms:selectOne>
<xforms:submit submitInfo="poll">
<xforms:caption>Submit</xforms:caption>
</xforms:submit>
The main difference to note here is the use of
model="poll", which identifies which form the form control
binds to.
This chapter has presented various bits and pieces of XForms as a tool to help readers understand the design. For convenience, the entire document is given here in one piece..
Note:
The DOCTYPE declaration 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.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2001/12/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:my="http://commerce.example.com/payment"
xml:lang="en">
<head>
<title>XForms in XHTML</title>
<xforms:model>
<xforms:instance>
<payment as="credit" xmlns="http://commerce.example.com/payment">
<cc/>
<exp/>
</payment>
</xforms:instance>
<xforms:schema xlink:href="payschema.xsd"/>
<xforms:submitInfo action="http://example.com/submit" method="post"/>
<xforms:bind ref="my:payment/my:cc"
relevant="my:payment/@as == 'credit'"
required="true" type="my:cc"/>
<xforms:bind ref="my:payment/my:exp"
relevant="my:payment/@as == 'credit'"
required="true" type="xsd:gYearMonth"/>
</xforms:model>
</head>
<body>
...
<group xmlns="http://www.w3.org/2001/12/xforms" ref="my:payment">
<selectOne ref="@as">
<caption>Select Payment Method</caption>
<choices>
<item>
<caption>Cash</caption>
<value>cash</value>
</item>
<item>
<caption>Credit</caption>
<value>credit</value>
</item>
</choices>
</selectOne>
<input ref="my:cc">
<caption>Credit Card Number</caption>
</input>
<input ref="my:exp">
<caption>Expiration Date</caption>
</input>
<submit>
<caption>Submit Form</caption>
</submit>
</group>
...
</body>
</html>
[Definition: A "binding" connects an instance data node to a form control or to a model item constraint by using a binding expression as a locator. ]
[Definition: An XPath LocationPath expression used in a binding. ]
[Definition: An XPath expression used by model item properties such as relevant and calculate to include dynamic functionality in XForms.]
[Definition: A specific document, for example an XHTML document, in which one or more <model> elements are found.]
[Definition: From XML Schema [XML Schema part 2]: 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.]
[Definition: From XML Schema [XML Schema part 2]: A single defining aspect of a value space. Generally speaking, each facet characterizes a value space along independent axes or dimensions.]
[Definition: An XForms user interface control that serves as a point of user interaction.]
[Definition: An internal tree representation of the values and state of all the instance data nodes associated with a particular form.]
[Definition: An XPath node from the instance data.]
[Definition: From XML Schema [XML Schema part 2]: A lexical space is the set of valid literals for a datatype.]
[Definition: An instance data node with associated constraints. ]
[Definition: Either a Schema constraint or an XForms constraint. ]
[Definition: A restriction, applied to form data, based on XML Schema datatypes. ]
[Definition: From XML Schema [XML Schema part 2]: 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.]
[Definition: A restriction, applied to form data, based on XForms-specific expressions. ]
[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.]
[Definition: A software application or program that implements and conforms to the XForms specification.]
The XForms specification is an application of XML [XML 1.0], and has been designed for use within other XML vocabularies, in particular XHTML [XHTML 1.0]. This chapter discusses the structure and high-level features of XForms that allow this specification to be used with other document types.
The XForms namespace has the URI:
http://www.w3.org/2001/12/xforms. Any future Working Drafts are expected to use a different
identifier, though a final identifier will
be allocated before XForms becomes a W3C Recommendation.
XForms Processors must use the XML namespaces mechanism [XML Names] to recognize elements and attributes from this namespace.
For cases when a particular element needs to be referred to from
another context, every element in the XForms namespace has declared
an attribute id of type xsd:ID in the
Schema for XForms.
Foreign-namespaced attributes are allowed on any XForms element. The XForms Processor must ignore any foreign-namespaced elements or attributes that are unrecognized.
Except where specifically allowed by the Schema for XForms, foreign-namespaced elements are not allowed as content of elements in the XForms namespace.
Element model is used
as a container for other XForms elements,
and can serve as the root element of a standalone document or
be embedded in the head section
of other document types such as XHTML. A single containing
document may contain any number of model
elements.
| Editorial note | |
|
under discussion are XLink attributes on the
model element. These are:
xlink:type="extended" and
xlink:role="http://www.w3.org/2001/12/xforms" - and they
should be defaulted or even fixed in the Schema/DTD. |
|
model><model id = xsd:ID > <!-- Content: instance?, schema?, (privacy|submitInfo|bind|action|extension)* --> </model>
id = xsd:ID - Optional unique identifier used to refer to this particular
modelelement.
For example:
<model xmlns="http://www.w3.org/2001/12/xforms" id="Person"> <instance xlink:href="http://example.com/cgi-bin/get-instance" /> <schema xlink:href="Schema-Questionnaire.xsd" /> ... </model>
Element instance is used to define initial instance
data. The instance data may be defined inline or obtained from a
external URI.
instance><instance xlink:href = xsd:anyURI > <!-- Content: (##other) --> </instance>
xlink:href = xsd:anyURI - Optional link to externally defined instance data
The content of the instance element is arbitrary
XML in any namespace other than the XForms namespace. Authors must
ensure that proper namespace declarations are used for content
within the instance element.
| Editorial note | |
|
As above, we need to find a place to discuss
the defaulted attributes. Here they are
xlink:role="http://www.w3.org/2001/12/xforms-instance"
xlink:type="locator" |
|
Element schema is
used to define the schema portion of the
XForms Model. The schema
information may be defined inline or obtained from an
external URI.
schema><schema xlink:href = xsd:anyURI > <!-- Content: ##other (though typically <xsd:schema>) --> </schema>
xlink:href = xsd:anyURI - Optional link to an externally defined XForms Model.
| Editorial note | |
|
As above, we need to find a place to discuss
the defaulted attributes. Here they are
xlink:role="http://www.w3.org/2001/12/xforms-model"
xlink:type="locator" |
|
Element submitInfo provides information on how,
where and what to submit .
submitInfo><submitInfo (single node binding attributes) action = xsd:anyURI mediaTypeExtension = "none" | qname-but-not-ncname : "none" method = "post" | "get" | qname-but-not-ncname : "post" version = xsd:NMTOKEN indent = xsd:boolean encoding = xsd:string mediaType = xsd:string omitXMLDeclaration = xsd:boolean standalone = xsd:boolean CDATASectionElements = list of xsd:QName replace = "all" | "instance" | "none" | qname-but-not-ncname : "all" > <!-- Content: (##empty) --> </submitInfo>
single node binding attributes - optional selector enabling submission of a portion of the instance data
action - Required destination for submitted instance data.
mediaTypeExtension- Optional information, additional to the mediaType, describing the serialization format.
method - Optional indicator as to the protocol to be used to deliver the serialized instance data.
version - corresponds to theversionattribute ofxsl:output
indent - corresponds to theindentattribute ofxsl:output
encoding - corresponds to theencodingattribute ofxsl:output
mediaType - corresponds to themedia-typeattribute ofxsl:output
omitXMLDeclaration - corresponds to theomit-xml-declarationattribute ofxsl:output
standalone - corresponds to thestandaloneattribute ofxsl:output
CDATASectionElements - corresponds to thecdata-section-elementsattribute ofxsl:output
replace- specifier for how the information returned after submit should be applied.
Note:
Many of these attributes correspond to XSLT attributes [XSLT]. Note that the XSLT attributes
doctype-system and doctype-public are not
supported in XForms processing.
Note:
Note also that attribute mediaTypeExtension is
useful in cases where a media type alone is not sufficiently
precise. For instance, a SOAP envelope would not be adequately
described simply by "text/xml", additional information would be
required.
Element bind is defined at 6
Constraints.
The bindings element is a container for
bind elements.
bindings><bindings > <!-- Content: (bind+) --> </bindings>
Additional details, including the definition of the <bind> element are found in the chapter .
| Editorial note | |
|
As above, we need to find a place to discuss
the defaulted XLink attributes.
|
|
Element privacy is used to associate a P3P [P3P 1.0] policy reference with a particular
form.
privacy><privacy xlink:href = xsd:anyURI > <!-- Content: (##empty) --> </privacy>
xlink:href = xsd:anyURI - Optional link to an externally defined P3P policyref file (not an actual policy).
| Editorial note | |
|
As above, we need to find a place to discuss
the defaulted XLink attributes.
|
|
Defined at 9.16 action.
Defined at 8.12.4.5 extension.
XForms use XLink [XLink] features for linking, or defining an explicit relationship between resources (or portions of resources), which may be either local or remote.
To that end, the XForms schema
references the XLink namespace with
the majority of the sensible defaults., including those based on XLink roles defined
later. Other than
xlink:href attributes, form authors in most cases will not
be required to explicitly write XLink-specific elements or
attributes. To emphasize this design, the
unprefixed attribute href is explicitly
prohibited.
All XLinks in XForms are simple links. For further details, see 4.4.1 XLink Conformance and Examples.
XLink allows users to provide arc-type elements to specify
traversal rules. The integration of arc-type elements in XForms
would require additional elements in the model element
that are otherwise not necessary. Hence, for children of the
model element, the traversal rule is to traverse
xlink:from the current document xlink:to the
document pointed to by the external resource. The processor should
behave as if xlink:actuate="onLoad" was specified. The
xlink:show attribute is meaningless in this context,
anyway.
An XForms processor is not required to implement full
XLink—correct behavior of the xlink:href
attribute (as defined in this chapter) is sufficient. For example,
an XForms Processor must accept and correctly process the schema in
both of the following:
<xforms:model> <xforms:schema xlink:href="URI-to-remote-schema.xsd" /> </xforms:model>
<xforms:model>
<xforms:schema>
<xsd:schema ...>
<!-- Content: ... -->
</xsd:schema>
</xforms:schema>
</xforms:model>
This second example is unusual in that the
xforms:schema element defaults an attribute
xlink:type="simple" but lacks an xlink:href
attribute to make the link meaningful. In this situation, the
XForms Processor should switch from simple mode to
none mode for the element lacking attribute
xlink:href. For compatibility with XLink, the second example
should be explicitly authored as follows:
xlink:type
<xforms:model>
<xforms:schema xlink:type="none">
<xsd:schema...>
<!-- Content: ... -->
</xsd:schema>
</xforms:schema>
</xforms:model>
Manual override of the xlink:type attribute.
It is permissible to construct the additional information from the semantics of the elements. An XForms Processor can not be XForms compliant, however, if it attempts to implement XLink and the implementation does not conform to XLink specification with respect to the attributes used by XForms.
Note that the XLink support uses a
well-defined XLink failure mode: If an XLink attribute is not
provided, the element looses its XLink specific meaning. We use
this feature in order to allow application developers to either
provide the model and instance via an external reference (via an
xlink:href attribute) or to provide the data inline
without the attribute. In the latter case, the XLink-specific
meaning of the element is lost and the inline content used.
If both inline content and external reference is provided, a
processor must use the external reference and ignore the inline
content.
For the purposes of XForms, we suggest that XLink aware
processors switch from the xlink:type="locator" mode
to the xlink:type="resource" mode. This should be
specified in the document by setting
xlink:type="resource", though a processing agent may not
depend on it. In other words, the first two of the following
examples must be treated identically:
This chapter defines the datatypes used in XForms, both built-in and defined for XForms.
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. Base types included in module basic are marked with an asterisk *. Datatypes derived by restriction and derived by list from these base types are included in both Basic and Full modules.
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
NMTOKEN
NMTOKENS
integer *
nonPositiveInteger *
negativeInteger *
long *
int *
short *
byte *
nonNegativeInteger *
unsignedLong *
unsignedInt *
unsignedShort *
unsignedByte *
positiveInteger *
Previous Working Drafts of XForms specified "dynamic facets"
that could be re-evaluated 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?
The Schema for XForms derives the following types for use within forms:
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. The value space for listItems is defined by list-derivation from listItem. This datatype is suitable for XForms Basic or XForms Full.
Example:
x vanilla grün
Note:
In most cases, it is better to use markup to distinguish items in a list. See 8.11.3 itemset.
This chapter discusses constraints that can be bound to form data. The combination of these constraints with an instance data node is called a model item. Overall, the constraints are called model item constraints. The term Schema constraint refers only to XML Schema datatype constraints, while the term XForms constraint refers to XForms-specific constraints defined in the following section.
XForms constraints, which occur as attributes on element
bind in XForms 1.0, fall into two 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 constraints are fixed, static values that the XForms Processor evaluates only once.
The following constraints are available for all model items, using syntax explained throughout this section. For each constraint the following information is provided:
Description
Computed Expression (yes or no)
Applies to children (instance data child elements and attributes)
Legal Values
Default Value
Additional descriptive text
Description: associates a Schema datatype.
Computed Expression: No
Applies to children: No
Legal Values: Any xsd:QName representing an
in-scope datatype.
Default Value: xsd:string
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.
The meaning of this constraint is the same as placing an
xsi:type attribute on the instance data.
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 constraint.
Computed Expression: Yes
Applies to children: Yes
Legal Values: Any expression that is convertible to
boolean
Default Value: false
When evaluating to true, this constraint indicates
that the XForms Processor should not allow any changes to the bound
instance data node.
In addition to restricting value changes, the
readOnly constraint provides a hint to the XForms User
Interface. Form controls bound to instance data with the
readOnly constraint should indicate that entering or
changing the value is not allowed. This
specification does not define any effect on visibility, focus, or
navigation order.
Description: describes whether a value is required before the instance data is submitted.
Computed Expression: Yes
Applies to children: 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 constraint
indicates that a non-empty instance data node is required before a
submission of instance data can occur. Non-empty is defined as:
If the bound instance data node is an element, the element must
not have the xsi:nil attribute set to
true.
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 constraint 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.
The chapter 11 Processing Model contains details on how the XForms Processor enforces required values.
Description: indicates whether the model item is currently
relevant to the rest of the XForms Model. Instance data nodes with
relevant=false, are not serialized for
submission.
Computed Expression: Yes
Applies to children: Yes
Legal Values: Any expression that is convertible to
boolean
Default Value: true
Many forms have data entry 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 constraint indicates
that the XForms Processor should render a form control, and
conversely, when evaluating to false, indicates that
the form control should be rendered specially (grayed out, hidden,
etc.).
The relevant constraint 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. |
Description: supplies an expression used to calculate the value of the associated instance data node.
Computed Expression: Yes
Applies to children: No
Legal Values: Any XPath 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.
Description: specifies a predicate that needs to be satisfied for the associated instance data node to be considered valid.
Computed Expression: Yes
Applies to children: No
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 false, the associated model item is not
valid; the converse is not necessarily true. Chapter 11 Processing Model describes details such
as immediate validation versus 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.
Description: for repeating structures, indicates the maximum number of allowed child elements.
Computed Expression: No
Applies to children: No
Legal Values: xsd:integer or
"unbounded"
Default Value: "unbounded"
For model item elements that are repeated, this optional
constraint specifies a maximum number of allowed child elements.
This only applies to element nodes selected as part of a
repeat sequence (10.3 Repeating
Structures).
Description: for repeating structures, indicates the minimum number of allowed child elements.
Computed Expression: No
Applies to children: No
Legal Values: xsd:integer
Default Value: 0.
For model item elements that are repeated, this optional
constraint specifies a minimum number of allowed child elements.
This only applies to element nodes selected as part of a
repeat sequence (10.3 Repeating
Structures).
Chapter 5 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 section draws the connection between Schema features and Schema Constraints, which can occur directly via a schema or indirectly by annotating an instance with instance-specific type constraints.
Datatypes used in XForms are either those predefined in chapter 5 Datatypes, or simpleTypes defined in a Schema.
Attributes xsi:schemaLocation and
xsi:noNamespaceSchemaLocation are ignored for purposes for
locating a Schema.
XForms Basic processors have restricted Schema processing requirements; full details are at 12.1.1 XForms Basic.
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, and if multiple datatypes apply to the same node, the first definition in document order is used):
An XML Schema xsi:type attribute (restricted to simpleTypes in XForms Basic) in
the instance data.
(XForms Full only) An XML Schema associated with the instance data.
An XForms type constraint associated with the
instance data node.
Otherwise, the datatype is treated as xsd:string
(default to string rule).
Example Schema Syntax: declaring a datatype based on an
xsd:string plus an additional constraining facet would be
accomplished by the following in a Schema:
<xsd:simpleType name="nonEmptyString">
<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 here:
<!-- Datatype through Schema xsi:type --> <my:first-name xsi:type="nonEmptyString"/>
The above shows element <first-name>
annotated with type
xsi:type="nonEmptyString"—this specifies that the
element first-name is of type
nonEmptyString.
<!-- Datatype through XForms constraint --> <instance> <my:first-name /> </instance> <bind type="nonEmptyString" ref="/my:first-name"/>
Here, element first-name has attached type
information via element bind. This enables the XForms
author annotate and extend external Schemas that she does not have
the ability to change.
The following non-normative sections illustrate mapping between Schema concepts and data structures commonly used in form authoring.
Often it is necessary to restrict the allowable values of the associated instance data node to a closed list of alternatives.
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="Mustercard"/>
<xsd:enumeration value="Donor's Club"/>
<xsd:enumeration value="World Express"/>
</xsd:restriction>
</xsd:simpleType>
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.
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="Mustercard"/>
<xsd:enumeration value="Donor's Club"/>
<xsd:enumeration value="World Express"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
It may be desirable for data collection purposes 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 a Schema:
<xsd:simpleType> <xsd:union memberTypes="creditCardType bonusProgramType"/> </xsd:simpleType>
Some form controls, such as selectMany, have the
notion of collecting more than one value at any given time. This
corresponds to Schema list datatypes.
Declaring a list-derived datatype would be accomplished with the following in a Schema:
<xsd:simpleType name="listOfMyIntType"> <xsd:list itemType="xsd:int"/> </xsd:simpleType>
Note:
The pre-defined datatype xforms:listItems can also
be used.
Binding is the glue that connects the separate pieces of XForms—directly associating nodes in the instance data with model item constraints.
Binding is specified via 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 7 XPath Expressions in XForms. This section describes the wider topic of how binding expressions are used within XForms.
The bind element represents a node-set selected
from the instance data. A series of attributes on the element
correspond to individual XForms constraints to be applied to each
node in the node-set.
bind><bind ref = binding-expression type = xsd:QName readOnly = model-item-constraint required = model-item-constraint relevant = model-item-constraint isValid = model-item-constraint calculate = model-item-constraint maxOccurs = xsd:nonNegativeInteger or "unbounded" minOccurs = xsd:nonNegativeInteger > <!-- Content: (##empty) --> </bind>
ref - A binding expression that selects which node or nodes have the associated constraints applied
type - reference to an in-scope Schema simpleType
readOnly - model item constraint
required - model item constraint
relevant - model item constraint
isValid - model item constraint
calculate - model item constraint
maxOccurs - model item constraint
minOccurs - model item constraint
Each bind element selects a node-set from the instance data, and
applies the specified constraints. When additional nodes are added
through the insert action, the newly added nodes are
included in any node-sets matched by binding expressions.
Not every possible XPath expression is acceptable as a binding expression. The following constraints are placed upon binding expressions:
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: elem permitted: elem[1] permitted: elem[last()] permitted: elem[@id="zip"] if @id is not bound to a form control forbidden: elem[@attr="xy"] if @attr is bound to a form control
No dynamic variables. The XForms specification does not provide any variables.
No invocation of any function that returns a node-set. Function calls are permitted, but not any that return a node-set.
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 form processing terminates with a fatal error.
References to node-sets are attached to form controls through
binding references, described in 8.12.2
Single Node Binding Attributes and 8.12.3 Nodeset Binding Attributes.
Different attribute names, ref vs.
nodeset, distinguish between a single node and a node-set
respectively.
First node rule: When a single-node binding expression
selects a node-set of size > 1, the first node in the node-set
is used. This has no effect on the individual nodes nor the set of
nodes selected by any particular bind element.
Consider a document with the following XForms declarations:
<xforms:model id="orders">
<xforms:instance xmlns="">
<orderForm>
<shipTo>
<firstName>John</firstName>
</shipTo>
</orderForm>
</xforms:instance>
<xforms:bind ref="/orderForm/shipTo/firstName"
id="fn" type="xsd:string"
required="true"/>
</xforms:model>
The following examples show three ways of binding user interface
control xforms:input to instance element
firstName declared in the model shown above.
ref<xforms:input ref="/orderForm/shipTo/firstName">...
bind<xforms:input bind="fn">...
<xforms:input model="orders" ref="/orderForm/shipTo/firstName">...
The XForms binding mechanism allows other XML vocabularies to
bind user interface controls to an XForms model using any of the
techniques shown here. As an example, XForms binding attribute
bind might be used within legacy HTML user interface
controls as shown below.
<html:input type="text" name="..." xforms:bind="fn"/>
XForms uses XPath to address instance data nodes in binding expressions, to express constraints, and to specify calculations.
XPath data types are used only in Binding expressions and
computed expressions. XForms uses XPath datatypes
boolean, string, number and
node-set. A future version of XForms is expected to use
XPath 2.0, which includes support for XML Schema datatypes.
For each model element, the XForms processor
maintains the state in an internal structure called instance data that
conforms to the XPath Data Model [XPath
1.0]. 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. In addition,
XForms processors must provide DOM access to this instance data via
the interface defined below.
interface XFormsModelElement : org.w3c.dom.Element
The method getInstanceDocument returns a DOM Document that corresponds to the instance data associated with this XForms Model.
Return value: org.w3c.dom.Document
raises (DOMException); if there is no model with the specified model-id.
Within XForms, XPath expressions reference abstract instance data (using the "path" portion of XPath), instead of a concrete XML document. This reference is called a binding expression in this specification. Every XPath expression requires an evaluation context. The following rules are used in determining evaluation context when evaluating binding expressions in XForms:
The context node for outermost form
control elements (such as XForms UI
elements) is the XPath root (/). A " form control element" is any element
other than bind that is
explicitly allowed to have a binding expression attribute. A form
control element is "outermost" when the node-set returned by
the XPath expression ancestor::* includes no form
control element nodes.
The context node for non-outermost form
control elements is the first node
of the binding expression of the immediately enclosing
element. An element is "immediately enclosing" when it is
the first form control element node in the node-set returned by the
XPath expression ancestor::*. This is also referred to
as "scoped resolution".
The context node for the ref attribute on
bind is the XPath root. The context node for other
attributes of bind is the first node of the node-set
returned from the binding expression in the sibling
ref attribute.
The context size and position are both exactly 1.
No variable bindings are in place.
The available function library is defined below.
Any namespace declarations in scope for the attribute that defines the expression are applied to the expression.
<group ref="level1/level2/level3"> <selectOne ref="elem" ... /> <selectOne ref="@attr" ... /> </group>
In this example, the group has a binding expression
of level1/level2/level3. 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
elem element. Both of the selectOnes then
inherit a context node from their parent, the context node being
/level1/level2/level3. Based on this, the
selectOne binding expressions evaluate respectively to
/level1/level2/level3/elem and
/level1/level2/level3/@attr. Matching instance data
follows:
<level1>
<level2>
<level3 attr="xyz">
<elem>xyz</elem>
</level3>
</level2>
</level1>
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.
boolean boolean-from-string(string)
Function boolean-from-string returns
true if the required parameter string is
"true", or false if parameter string is
"false". This is useful when referencing a Schema
xsd:boolean datatype in an XPath expression. If the parameter string matches neither "true" nor
"false", according to a case-insensitive comparison, processing
stops with a fatal error.
Note:
The XPath number datatype and associated methods and operators use IEEE specified representations. XForms Basic Processors are not required to use IEEE, and thus might yield slightly different results.
number avg(node-set)
Function avg returns the arithmetic average of the
result of converting the string-values of each node in the argument
node-set to a number. The sum is computed with sum(),
and divided with div by the value computed with
count().
number min(node-set)
Function min returns the minimum value of the
result of converting the string-values of of each node in argument
node-set to a number. "Minimum" is determined with the
< operator. If the parameter
is an empty node set, the return value is NaN.
number max(node-set)
Function max returns the maximum value of the
result of converting the string-values of each node in argument
node-set to a number. "Maximum" is determined with the
< operator. If the parameter
is an empty node set, the return value is NaN.
number count-non-empty(node-set)
Function count-non-empty returns the number of
non-empty nodes in argument node-set. A node is
considered non-empty if it is convertible into a string with a
greater-than zero length.
number cursor( string )
Function cursor takes a string argument that is the
idref of a repeat and returns the current
position of the repeat cursor for the identified
repeat—see 10.3 Repeating
Structures for details on repeat and its
associated repeat cursor. If the specified argument does not
identify a repeat, this function throws an error.
<xforms:button>
<xforms:caption>Add to Shopping Cart</xforms:caption>
<xforms:insert ev:event="ev:activate" position="after"
nodeset="items/item" at="cursor('cartUI')"/>
</xforms:button>
property()string property(string)
Function property returns the XForms Property named
by the string parameter.
The following properties are available for reading (but not modification).
version is defined as the string "1.0"
for XForms 1.0
conformance-level strings are defined in 12 Conformance.
<xforms:instance>
...
<xforms:bind ref="info/xforms-version" calculate="property('version')"/>
...
</xforms:instance>
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 used in CSS stylesheets to
deliver a customized look and feel. XForms user interface controls
are bound to the underlying instance data using binding attributes as defined in the
chapter 6 Constraints.
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 in XHTML. All form controls are suitable for styling using Aural CSS (ACSS) style properties.
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, form
controls selectOne and selectMany, are
provided. Form controls distinguish the functional aspects of the
underlying control, from the presentational aspects (through
class attributes) and behavior (through XForms Action
elements). This separation enables the expression of the intent
underlying a particular form control—see [AUI97] for a definition of such
high-level user interaction primitives.
For each form control, the following sections describe:
Description
Examples
Data Binding Restrictions
Implementation Requirements
XML Representation
XForms user interface controls use common attributes and elements that are defined later in this chapter (8.12 Common Markup ).
Description: This form control enables free-form data entry.
<input ref="order/shipTo/street" class="streetAddress"> <caption>Street</caption> <hint>Please enter the number and street name</hint> </input>
In the above, the class attribute (which are not defined in XForms but come from an
external document type) can be used by a stylesheet to
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:
Data Binding Restrictions: Binds to any simpleContent (except
xsd:base64Binary, xsd:hexBinary or any
datatype derived from those).
Implementation Requirements: Must allow entry of a lexical value
for the bound datatype. Implementations should provide the most
convenient means possible for entry of datatypes and take into
account localization and internationalization issues such as
representation of numbers. For example, an input bound
to an instance data node of type Date might provide a
calendar control to enter dates; similarly, an input control bound
to data instance of type boolean might be rendered as
a simple checkbox.
input><input (single node binding attributes) (common attributes) inputMode = xsd:string > <!-- caption, (help|hint|alert|action|extension)* --> </input>
(single node binding attributes) - Selection of instance data node, defined at 8.12.2 Single Node Binding Attributes
common attributes defined in 8.12.1 Common Attributes
inputMode - this form control accepts an input mode hint. B Input Modes
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.
<textarea ref="message/body" class="messageBody"> <caption>Message Body</caption> <hint>Enter the text of your message here</hint> </textarea>
In the above, the class attribute can be used by a
stylesheet to 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:
Data Binding Restrictions: Binds to xsd:string or
any derived simpleContent.
Implementation Requirements: Must allow entry of a lexical value for the bound datatype, including multiple lines of text.
textarea><textarea (single node binding attributes) (common attributes) inputMode = xsd:string > <!-- caption, (help|hint|alert|action|extension)* --> </textarea>
(single node binding attributes) - Selection of instance data node, defined at 8.12.2 Single Node Binding Attributes
common attributes defined in 8.12.1 Common Attributes
inputMode - this form control accepts an input mode hint. B Input Modes
Description: This form control is used for entering information that is considered sensitive, and thus not echoed to a visual or aural display as it is being entered, e.g., password entry.
<secret ref="/login/password">
<caption>Password</caption>
<hint>Please enter your password --it will not
be visible as you type.</hint>
</secret>
A graphical browser might render this form control as follows:
Data Binding Restrictions: Identical to input.
Implementation Requirements: In general, implementations, including accessibility aids, must render a "*" or similar character instead of the actual characters entered, and thus must 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.
secret><secret (single node binding attributes) (common attributes) inputMode = xsd:string > <!-- caption, (help|hint|alert|action|extension)* --> </secret>
(single node binding attributes) - Selection of instance data node, defined at 8.12.2 Single Node Binding Attributes
common attributes defined in 8.12.1 Common Attributes
inputMode - this form control accepts an input mode hint. B Input Modes
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.
I charged you <output ref="order/totalPrice"/> and here is why:
A graphical browser might render an output form control as follows:
Data Binding Restrictions: Binds to any simpleContent.
Implementation Requirements: Must allow display of a lexical value for the bound datatype. Implementations should provide the most convenient means possible for display of datatypes and take into account localization and internationalization issues such as representation of numbers.
output><output (single node binding attributes) > <!-- empty content --> </output>
(single node binding attributes) - Selection of instance data node, defined at 8.12.2 Single Node Binding Attributes
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.
<upload ref="mail/attach1" mediaType="image/*"> <caption>Select image:</caption> </upload>
A graphical browser might render this form control as follows:
Data Binding Restriction