This chapter is normative.
The XForms Reference Processing Model is a normative explanation of the components, predictive behavior, and mechanisms of XForms Processors. It is not intended to constrain implementations. XForms Processors may be implemented in any manner, so long as the end results are identical to that described in this chapter.
This chapter uses the terms may, must, and should (when rendered as in this paragraph) in accord with RFC 2119.
[Editor's Feedback Request 10.1.processing: This chapter is still at an early phase and may contain errors or omissions. Feedback on this chapter is especially appreciated.]
The Reference Processing Model set out in this chapter will:
For each <xform>
element, the XForms Processor maintains
a set of properties, as described here.
version
conformance-level
locale
timezone
immediate-refresh
immediate-revalidate
immediate-recalculate
use-nulls
version
(readonly) is defined as the string "1.0" for
XForms 1.0
conformance-level
(readonly) strings are TBD
locale
(readonly) strings are TBD, as is the process for determining
the locale
timezone
(readonly) strings are signed integers representing the
number of minutes offset from GMT
immediate-refresh
(read-write) controls whether changes in the
instance data are immediately updated in the UI
immediate-revalidate
(read-write) controls whether changes in
the instance data immediately trigger a validation
immedate-recalculate
(read-write) controls whether changes in
the instance data immediately trigger a recalculation
use-nulls
(read-write) controls whether XML Schema Instance nulls
are placed in the instance data
The Working Group is currently discussing the syntax for accessing these properties from the Dynamic Constraints Language.
XForms uses an events system as defined in [DOM2 Events], with a Capture phase, arrival at the Event Target, and then a Bubbling Phase.
Events fall into different groupings. One class of events indicates that some processing is about to happen. That processing may be halted by the event handler:
xforms-submit
xforms-reset
xforms-value-changing
xforms-interactive-value-changing
xforms-instance-changed
Another class of events indicates that some processing has already happened or is in progress. Such processing can not be halted by the event hander:
xforms-construct
xforms-destruct
xforms-suspend
xforms-resume
xforms-exception
Finally, certain events are used by the author or the XForms Processor to cause processing to happen:
xforms-recalculate
xforms-refresh
Unless otherwise noted, the target node for all events is the <xform>
element. When a containing document has multiple <xform>
elements, the binding is used to determine which <xform>
element is used.
The Working Group is considering syntax proposals for event handlers, mainly based on [XHTML Events].
For each containing document, an XForms Processor must behave as if it internally
maintains a set of instance data, called virtual instance data. In this document,
this is represented as a virtual <instance>
element, which
contains and maintains all instance data associated with an <xform>
element.
It is not allowed for elements in the virtual instance data to be in the XForms namespace (for example if the XML data to be submitted itself consisted of XForms elements).
Representation of virtual instance data
<instance> ... instance data goes here ... </instance>This is an example of virtual instance data as used by the XForms Reference Processing Model.
[Editor's Feedback Request 10.4.dom: Should virtual instance data be mapped to the DOM of the containing document, or should it exist in a separate document space?]
[Editor's Feedback Request 10.4.access: From the DOM, should virtual instance data be read-only or read-write? What are possible security implications here?]
Additionally, for purposes of the Reference Processing Model, virtual instance data keeps track of which instance data items (whether elements, attributes, complex types, etc.) are "dirty", or in need of update.
The following describes the initialization process for XForms. Initialization
must occur before any other processing. For each <xform>
element in the containing document, in document order, the following processing
occurs:
xforms-construct
event is fired; this is the place for
authors to handle any initialization tasks.<model>
element contains a reference to a non-local
XForms Model, it is retrieved by traversing the link to it. An XForms Model
that is unretrievable for any reason must be regarded as
a fatal error, preventing the form from being filled.<instance>
element contains a reference to non-local
instance data, it is retrieved by traversing the link to it. Instance
data that is unretrievable for any reason is ignored, in which case an
XForms Processor may issue a warning.<xform>
element currently being processed 1) contains
no <instance>
child, and 2) contains no <model>
child, the following processing occurs:
<xform>
element currently being processed is visited
in document order. Each form control's
binding expression is
evaluated.use-nulls
property is true, populated with a null value (in whatever representation
Schema finalizes upon). Note that the way Schema specifies things, only
elements can hold null values. The form
control receives a default blank value. The algorithm for creating
instance data items is
as follows: For each location step in the canonical binding
expression, left to right, where no matching node exists in the virtual
instance data, a new node is
inserted.xforms-resume
event is fired.Navigation is determined on a document-wide basis. The navigation sequence is determined as follows:
navindex
and assign a positive
value to it are navigated first. Navigation proceeds from the form control
with the lowest navindex
value to the form control with the highest
value. Values need not be sequential nor must they begin with any particular
value. Form controls that have identical
navindex
values should be navigated in document order.navindex
or supply
a value of "0" are navigated next. These form controls are navigated in document
order.relevant
subtree are assigned a relative order in the overall sequence but do not participate
as navigable controls.XForms provides similar processing to the HTML onChange
event.
As users indicate completion of a form control by navigating away the following
occurs:
xforms-value-changing
event is fired. If the
display value hasn't changed, processing for this event ends.
preventDefault()
method), which will end event
processing immediately after the Capture and Bubbling phases. Alternatively,
a listener may perform a custom translation from display value to canonical
value. Any listener may have side-effects that modify any instance
data item, in which case the modified parts must be marked "dirty".immediate-revalidate
property is true, all validations
bound to the form control are run. Note that validation is performed against
the canonical value, not the display value.
immediate-recalculate
property is true, a recalculate
occurs to perform any defined calculations.immediate-refresh
property is true, a refresh
occurs to update any form controls that might be dependent on this newly changed
value.Certain form controls allow interactive response without finalizing on a value. Examples of this include edit boxes (users can type various characters before "tabbing out") and slider controls (users can be continuously adjusting the value before releasing at a certain value). Interactive temporary values such as this are expressly allowed to be "invalid", that is outside the permissible value space. This is because incomplete data may be present while the user is entering transitional values.
Example: A partially entered currency value of "U" is not valid because it doesn't (yet) have 3 characters. This is permitted temporarily, as long as the user remains on the form control. XForms Processors with sufficient processing resources would typically update/refresh on every character. Resource-constrained XForms Processors would typically only update/refresh on the final value.
xforms-interactive-value-changing
event is fired. Resource-constrained
XForms Processor implementations may choose to ignore all
xforms-interactive-value-changing
events.
immediate-revalidate
setting.
If all validations on the form control are successful, the instance data item is updated, and marked "dirty". If any validations fail (indicating
a transitional value) all form controls bound to the same instance data item may be directly updated with the display value. Otherwise,
the following occurs:immediate-recalculate
property is true, a recalculation
occurs to perform any defined calculations.immediate-refresh
property is true, a refresh
occurs to update any form controls that might be dependent on this newly
changed value.Typical implementations that choose to respond xforms-interactive-value-changing
are expected optimize processing (for instance not flashing the entire screen
for each character entered, etc.).
XForms Processors are free (and encouraged) to skip or change any steps in
this algorithm, as long as the end result is the same. Each form control may
have a model item property priority
value, which is the main factor
in determining calculation order.
Following is the default handling for an xforms-recalculate
event:
calculate
model item property is visited in
calculation order, which is defined as follows:
priority
and assign
a positive integer to it are computed first. Computation proceeds from the
model item with the lowest bound priority
to the model item
with the highest bound priority
. Values need not be sequential
nor must they begin with any particular value. Model
items with the same bound priority
value are computed in
document order.calculate
model item property is evaluated. Any instance data item changes as a result of
this are marked with a "dirty" flag.calculate
expression, and the "dirty" flag is set.Following is the default handling for an xforms-refresh
event:
xforms-refresh
event is used.relevant
constraint is evaluated,
which might result in the form control being disabled/hidden/etc. as specified
in the XForms Model chapter. xforms-instance-changed
event is fired.xforms-instance-changed
event are free to
compute a new display value.xforms-instance-changed
event are prohibited
from directly updating any form controls present.xforms-instance-changed
event are prohibited
from altering any portion of the virtual innate data. To attempt to do so
results in an xforms-exception
being fired.xforms-instance-changed
event.Editor's Note: Still to be addressed is the processing when a datatype facet or model item property are changed--what gets marked "dirty"?; what gets recalculated?; what gets revalidated?; what gets refreshed?
Revalildation always occurs within the scope of a context form control. Following is the revalidation process:
validate
model item property is bound to the context
form control, the expression within is evaluated. If it evaluates to false,
the context form control is considered invalid.The form filling experience ends with submitting the form, saving it for later, or starting over. The XForms processing for these events are covered here.
The following sections describe how to instance data is prepared for submission.
In response to an xforms-submit
event, the following takes place:
In response to an xforms-suspend
event, the following takes place:
In response to an xforms-reset
event, the following takes place:
This format is intended to facilitate the integration of XForms into HTML forms processing environments, and represents an extension of the [XHTML 1.0] form content type of the same name that expresses the hierarchical nature of instance data.
This format is not suitable for the persistence of binary content. Therefore, it is recommended that XForms capable of containing binary content use either the multipart/form-data or text/xml formats.
[Editor's Feedback Request 10.6.4.urlencoding: The urlencoding technique given here does not exactly match how legacy implementations produce urlencoded data. (In particular, we are adding contextual information with slashes and multiple location-steps) Will this approach interfere with legacy urlencoding parsers?]
[Editor's Feedback Request 10.6.4.utf8: Under discussion is the intent to have the data be UTF8 encoded; however, this is dependent upon IETF developments. Would UTF8 meet the needs of the forms community?]
The steps for building this persistence format is as follows:
application/x-www-form-urlencoded
/PersonName/@title=Mr&/PersonName/FirstName=RolandThis format consists of sets of a canonical binding expression paired with a value.
Corresponding Instance Data
<PersonName title="Mr"> <FirstName>Roland</FirstName> </PersonName>Here is the instance data for the above example.
This format is intended to facilitate the integration of XForms into HTML forms processing environments, and represents an extension of the [XHTML 1.0] form content type of the same name that expresses the hierarchical nature of instance data. Unlike the application/x-www-form-urlencoded format, this format is suitable for the persistence of binary content.
This format follows the rules of all multipart MIME data streams as outlined in [RFC 2045]. Each part is expected to contain:
multipart/form-data
Content-Type: multipart/form-data; boundary=AaB03x--AaB03x Content-Disposition: form-data; name="/PersonName/@title" Mr --AaB03x Content-Disposition: form-data; name="/PersonName/FirstName" Roland --AaB03x ...Possibly more data... --AaB03x-This format consists of sets of a canonical binding expression paired with a value.
Corresponding Instance Data
<PersonName title="Mr"> <FirstName>Roland</FirstName> </PersonName>Here is the instance data for the above example.
Each part may be encoded and the "Content-Transfer-Encoding" header supplied if the value of that part does not conform to the default (7 bit) encoding.
Where a value within the instance data represents binary content, the value should be identified by the appropriate content type (e.g., "application/octet-stream"). If multiple values of binary content are to be returned as the result of a single model item, they should be returned as "multipart/mixed" embedded within the "multipart/form-data".
The XForms Processor may wish to supply a file name for each value of binary content. The file name may be specified with the "filename" parameter of the 'Content-Disposition: form-data' header, or in the case of multiple values of binary content, in a 'Content-Disposition: file' header of the subpart. If the file name of the client's operating system is not in US-ASCII, the file name might be approximated or encoded using the method of [RFC 2045]. This is convenient for those cases where, for example, the uploaded files might contain references to each other (e.g., a TeX file and its ".sty" auxiliary style description).
This format permits the expression of the instance data as an XML-based format that is straightforward to process with off-the-shelf XML processing tools. In addition, this format is suitable for the persistence of binary content.
The steps for building this persistence format is as follows:
<instance>
node.Handling of binary content will likely be based on the ongoing work in the XML Protocol Working Group.
[Editor's Feedback Request 10.6.5.metadata: Where a value
within the instance data represents
binary content, can we store meta-information with an xform:mediaType
attribute reflecting the appropriate content type (e.g., "image/jpg")?]
XForms have been designed for use among a wide variety of XForms Processors, of varying size and resource constraints. Because of this, multiple conformance levels are being discussed. This chapter will be updated in the future with more details.