6.2 Interaction with Instance Data

Form controls transform the user input into either a string of characters (called simpleContent) or child elements. In XML, character data can occur in many ways, including attributes, element content, comments, processing instructions, and so on. For the most part, XForms interacts intuitively with XML.

When bound to an attribute or an element with text-only content, the mapping is straightforward: it uses the attribute value or the text child node of the attribute:

ref="/element" <element>form data</element> ref="/element/text(  )" <element>form data</element> (equivalent to direct element reference) ref="/element/@attribute" <element attribute="form data"/>

For these purposes, an empty element (<element/>) is treated as a zero-length string.

Comments and processing instructions are straightforward: don't do it. To encourage authors to keep important form data in elements and attributes, XForms leaves the binding undefined for comments and processing instructions (if these exist in the initial instance data, they will be passed through unchanged, so this admonition applies only to their use in storing form data).

It gets more complicated when mixed content enters the picture. When confronted with this situation, a new text node will be created as the first child of the target element, which usually isn't the intended effect. Thus, mixed content isn't supported in off-the-shelf XForms 1.0, though some proposed extensions enable the common case of XHTML.

Generally, elements that contain other elements or a combination of text and elements shouldn't be used as an endpoint for form data.

6.2.1 Incremental

The remaining question concerns when the update happens. Does an input form control cause a change in the instance data, with the associated flurry of recalculation activity, on a per-keystroke basis? Or does no update happen until the user navigates away, as is the case in current HTML forms?

The answer is that an attribute, named incremental, controls this behavior. A setting of false causes the update, with the xforms-value-changed notification event, to occur only when the user navigates away. This is the default setting for input, secret, textarea, range, and upload. However, when the attribute value is true, updates and additional xforms-value-changed events happen more frequently, although the specification doesn't go as far as saying "per keystroke." In fact, having a keyboard isn't a requirement to run XForms. More frequent updates are the default for select and select1.



XForms Essentials
Xforms Essentials
ISBN: 0596003692
EAN: 2147483647
Year: 2005
Pages: 117
Authors: Micah Dubinko

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net