Repeating Line Items
One of the most sorely missed features in HTML forms comes by many names: tables, grid controls, or line items. The basic concept is that many forms in common use don’t fit in well with a flat list of form controls. Figure 6-11 shows one embodiment of this, rendered in the X-Smiles browser.
Figure 6-11. Repeating line items in X-Smiles
Another common scenario is a purchase order, with repeating lines, each containing quantity, description, price, and computed extended price.
repeat
The primary means of accomplishing this in XForms is the
repeat
element, which operates over homogeneous
collections, the same as itemset
, described
earlier. The
nodeset
attribute
of repeat
selects a number of nodes, and the
contents of the element, both from XForms and from the host language,
are effectively repeated once for each resulting node. One way to
think of this is to “unroll” the
repeat, so that the following:
<repeat nodeset="item"> <input ref="@quantity" .../> </repeat>
has a similar effect, when the nodeset returns three item nodes, to:
<input ref="item[1]/@quantity" .../> <input ref="item[2]/@quantity" .../> <input ref="item[3]/@quantity" .../>
The main difference between a repeat element and unrolled syntax
(besides convenience) is how the result is presented to the user. The
repeat
version makes it possible to show more items in a limited space, as in the case of scroll ...
Get XForms Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.