1.1 --- a/docs/multivalue.html Sat Sep 08 16:53:18 2007 +0000
1.2 +++ b/docs/multivalue.html Sat Sep 08 16:53:34 2007 +0000
1.3 @@ -1,15 +1,15 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1"?>
1.5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.6 <html xmlns="http://www.w3.org/1999/xhtml"><head>
1.7 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
1.8 -
1.9 - <title>Creating Applications: Adding Multivalued Fields</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.10 + <title>Creating Applications: Adding Multivalued Fields</title>
1.11 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.12 <body>
1.13 <h1>Creating Applications: Adding Multivalued Fields</h1>
1.14 <p>Although some applications only require multiple-choice fields where
1.15 only a single value may be chosen, in many situations it is desirable
1.16 to be able to choose an arbitrary number of values for a particular
1.17 -field. However, up to this point, we have been content to
1.18 +field. However, up to this point, we have been content to
1.19 represent form data using a single attribute on a single element to
1.20 represent any given field value. With multivalued fields, we must
1.21 choose a different strategy in using XML to represent such information.</p>
1.22 @@ -23,31 +23,31 @@
1.23 users to select one
1.24 or many values presented in a list or menu.</p>
1.25
1.26 - <p>Some item: <input name="value" value="some value" /><input name="remove" value="Remove" type="submit" /></p>
1.27 + <p>Some item: <input name="value" value="some value" /><input name="remove" value="Remove" type="submit" /></p>
1.28 <p>Item type:
1.29 <select multiple="multiple" name="type"><option>(Not selected)</option><option>Important</option><option>Not important</option><option>Personal</option></select>
1.30 </p>
1.31 <p>Itself containing more items:</p>
1.32 <p>Sub-item: <input name="subvalue" value="some other value" /><input name="remove2" value="Remove" type="submit" /></p>
1.33
1.34 -From the item type list many value may now be selected.
1.35 -<p>Taking the example HTML code from before, we can add a
1.36 +From the item type list many value may now be selected.
1.37 +<p>Taking the example HTML code from before, we can add a
1.38 definition of this new list to the template to produce something
1.39 like this:</p>
1.40 <pre><html xmlns="http://www.w3.org/1999/xhtml"<br /> xmlns:template="http://www.boddie.org.uk/ns/xmltools/template"><br /><head><br /> <title>Example</title><br /></head><br /><body template:element="structure"><br /><form action="" method="post"><br /><br /><!-- Template text between the start and the interesting part. --><br /><br /><div template:element="item"><br /> <p><br /> Some item: <input template:attribute-field="value" name="..." type="text" value="..." /><br /> <input name="..." template:selector-field="remove" type="submit" value="Remove" /><br /> </p><br /> <p><br /> Item type:<br /> <select name="..." <span style="font-weight: bold;">template:multiple-choice-list-field="type,type-enum,value"</span> <span style="font-weight: bold;">multiple="multiple"</span>><br /> <option <span style="font-weight: bold;"><span style="font-family: monospace;">template:multiple-choice-list-value="type-enum,value,selected"</span></span> value="..." /><br /> </select><br /> </p><br /> <p><br /> Itself containing more items:<br /> </p><br /> <p template:element="subitem"><br /> Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." /><br /> <input name="..." template:selector-field="remove2" type="submit" value="Remove" /><br /> </p><br /> <p><br /> <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" /><br /> </p><br /></div><br /><p><br /> <input name="..." template:selector-field="add,item" type="submit" value="Add item" /><br /></p><span style="font-weight: bold;"><br /><br /></span><!-- Template text between the interesting part and the end. --><br /><br /></form><br /></body><br /></html></pre>
1.41 <p>From the previous <a href="multiple.html">single-valued case</a>,
1.42 some crucial changes have been made:</p>
1.43 <ol>
1.44 - <li>The <code>select</code> element remains mapped onto the <code>type</code>
1.45 -element in the form data structure. However, we use a different attribute, <code>template:multiple-choice-list-field</code>, to indicate that a <code>type</code>
1.46 -element is created when the form data is submitted, but instead of a single value being added to the <code>value</code> attribute of that one element, a separate <code>type-enum</code>
1.47 -element is created within the <code>type</code>
1.48 -element with a value in its <code>value</code> attribute <span style="font-style: italic;">for each value submitted</span>. This means that many <code>type-enum</code>
1.49 -elements may be created within the <code>type</code>
1.50 + <li>The <code>select</code> element remains mapped onto the <code>type</code>
1.51 +element in the form data structure. However, we use a different attribute, <code>template:multiple-choice-list-field</code>, to indicate that a <code>type</code>
1.52 +element is created when the form data is submitted, but instead of a single value being added to the <code>value</code> attribute of that one element, a separate <code>type-enum</code>
1.53 +element is created within the <code>type</code>
1.54 +element with a value in its <code>value</code> attribute <span style="font-style: italic;">for each value submitted</span>. This means that many <code>type-enum</code>
1.55 +elements may be created within the <code>type</code>
1.56 element, and each one of them will have a different <code>value</code> attribute.</li>
1.57 - <li>Of course, the <code>select</code> element now has a <code>multiple</code>
1.58 + <li>Of course, the <code>select</code> element now has a <code>multiple</code>
1.59 attribute defined to permit multiple value selections.</li>
1.60 - <li>Inside the <code>select</code> element, the <code>option</code>
1.61 + <li>Inside the <code>select</code> element, the <code>option</code>
1.62 element now employs the <code>template:multiple-choice-list-value</code> annotation.</li>
1.63 </ol>
1.64 <h2>Output Structures</h2>
1.65 @@ -56,7 +56,7 @@
1.66 template. Indeed, the subtle differences cannot be represented in our
1.67 simplistic presentation of the structure:</p>
1.68 <pre><?xml version="1.0"?><br /><structure><br /> <item value="some value"><br /> <type><br /> <type-enum value="some type"/><br /> <type-enum value="some other type"/><br /> </type><br /> <subitem subvalue="some other value"/><br /> </item><br /></structure></pre>
1.69 -<p>In fact, the principal difference arises through the number of <code>type-enum</code>
1.70 +<p>In fact, the principal difference arises through the number of <code>type-enum</code>
1.71 elements that occur in the input, representing the values selected by
1.72 the user, and the number that occur in the output, representing the
1.73 complete range of values available for selection.
1.74 @@ -64,29 +64,29 @@
1.75 <h3>Presenting the Extra Values</h3>
1.76 <p>In most respects, the presentation of the extra values is the same
1.77 as in the single-valued case. The result of the presentation of the
1.78 -extra values is that the <code>type</code> element in the
1.79 -this example structure fragment...</p>
1.80 +extra values is that the <code>type</code> element in the
1.81 +this example structure fragment...</p>
1.82 <pre><type><br /> <type-enum value="(Not selected)"/><br /> <type-enum value="Important" value-is-set="true"/><br /> <type-enum value="Not important" value-is-set="true"/><br /> <type-enum value="Personal"/><br /></type><br /></pre>
1.83 <p>...is transformed into something resembling this HTML code:</p>
1.84 <pre><select name="..." multiple="multiple"><br /> <option value="(Not selected)">(Not selected)</option><br /> <option value="Important" selected="selected">Important</option><br /> <option value="Not important" selected="selected">Not important</option><br /> <option value="Personal">Personal</option><br /></select><br /></pre>
1.85 -<p>Above, the special <code>value-is-set</code>
1.86 +<p>Above, the special <code>value-is-set</code>
1.87 attribute is an XSLForms mechanism to remember which values were set.
1.88 Fortunately, the document initialisation mechanism automatically
1.89 distinguishes between different multiple-choice field types and
1.90 understands where the above approach needs to be employed.</p>
1.91 <ul>
1.92 </ul><h3>Updating the Web Resource</h3>
1.93 -<p>To update the special WebStack resource, we
1.94 +<p>To update the special WebStack resource, we
1.95 now need to modify a few of the class attributes and to add a few
1.96 others:</p>
1.97 <pre> template_resources = {<br /> "structure" : ("structure_multivalue_template.xhtml", "structure_output.xsl")<br /> }<br /></pre>
1.98 <p>With these adjustments, it should now be possible to manipulate the
1.99 items and subitems whilst specifying multiple type values on each item.
1.100 Note that it may be necessary to remove the old stylesheet for
1.101 -producing output, <code>structure_output.xsl</code>, so that the
1.102 +producing output, <code>structure_output.xsl</code>, so that the
1.103 multivalue version of the template is taken into use.</p>
1.104 <h2>Improving the Presented Values</h2>
1.105 -<p>In the application we have been developing, we have been content to show the multiple-choice values as they are known in the application - that is, the application refers to values like <code>Personal</code>
1.106 +<p>In the application we have been developing, we have been content to show the multiple-choice values as they are known in the application - that is, the application refers to values like <code>Personal</code>
1.107 and the same text is shown to users of the application. However, there
1.108 are various situations where this is not desirable, and the <a href="labels.html">usage of separate labels</a> is described in the next section of the development <a href="overview.html">process</a>.</p>
1.109 -</body></html>
1.110 \ No newline at end of file
1.111 +</body></html>