1.1 --- a/docs/advice.html Sat Sep 08 16:53:18 2007 +0000
1.2 +++ b/docs/advice.html Sat Sep 08 16:53:34 2007 +0000
1.3 @@ -1,8 +1,8 @@
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: Recommendations and Advice</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.10 + <title>Creating Applications: Recommendations and Advice</title>
1.11 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.12 <body>
1.13 <h1>Creating Applications: Recommendations and Advice</h1>
1.14 @@ -15,14 +15,14 @@
1.15 multiple-choice elements like this:</p>
1.16 <pre><multi><br /> <multi-enum value="1"/><br /> <multi-enum value="2"/><br /> <multi-enum value="3"/><br /> <nested value="x"/><br /></multi></pre>
1.17 <p>The reason for this is that the number of multiple-choice values may
1.18 -vary within your application, and the nested elements will appear
1.19 +vary within your application, and the nested elements will appear
1.20 at a different position depending on how many such values have been
1.21 inserted. Whilst this might not affect some applications, at least not
1.22 to begin with, the usage of more advanced features (<a href="in-page-updates.html">in-page updates</a>, for example) will
1.23 probably expose
1.24 problems due to the way XSLForms reconstructs the XML document data
1.25 -from the input form data.</p><p>We can avoid the above mistake by specifying the first parameter in the <code>template:multiple-choice-field</code> and <code>template:multiple-choice-list-field</code> annotations. For example:</p><pre><select name="..." template:multiple-choice-field="multi,multi-enum,value"><br /> <option value="..." template:multiple-choice-value="multi-enum,value,selected"></option><br /></select></pre>
1.26 -<p>This effectively prevents us from inserting the <code>nested</code> element inside the <code>multi</code> element.<br /></p><h2>Beware of Adding Elements into Mixtures of Elements</h2>
1.27 +from the input form data.</p><p>We can avoid the above mistake by specifying the first parameter in the <code>template:multiple-choice-field</code> and <code>template:multiple-choice-list-field</code> annotations. For example:</p><pre><select name="..." template:multiple-choice-field="multi,multi-enum,value"><br /> <option value="..." template:multiple-choice-value="multi-enum,value,selected"></option><br /></select></pre>
1.28 +<p>This effectively prevents us from inserting the <code>nested</code> element inside the <code>multi</code> element.<br /></p><h2>Beware of Adding Elements into Mixtures of Elements</h2>
1.29 <p>Although we ignore this rule with the example in this documentation,
1.30 it is necessary to be aware of problems with adding and removing
1.31 elements where other elements may reside. Consider part of our form
1.32 @@ -30,12 +30,12 @@
1.33 <pre><item value="a"><br /> <type><br /> <type-enum value="1"/><br /> </type><br /> <subitem value="x"/><br /></item></pre>
1.34 <p>Provided that we control the process of adding and removing the
1.35 elements, making sure that they always reside at the end of the element
1.36 -collection inside the <code>item</code> element, and that they
1.37 +collection inside the <code>item</code> element, and that they
1.38 always follow a known number of elements, we can avoid issues with more
1.39 advanced features (<a href="in-page-updates.html">in-page updates</a>,
1.40 -for example), although using such features on the <code>subitem</code>
1.41 +for example), although using such features on the <code>subitem</code>
1.42 elements themselves may cause problems that may only be resolved by
1.43 -moving the <code>subitem</code> elements into a container element
1.44 +moving the <code>subitem</code> elements into a container element
1.45 of their own:</p>
1.46 <pre><item value="a"><br /> <type><br /> <type-enum value="1"/><br /> </type><br /> <subitems><br /> <subitem value="x"/><br /> </subitems><br /></item></pre>
1.47 <h2>Make Sure the Output Structure Agrees with the Template</h2>
1.48 @@ -51,14 +51,14 @@
1.49 page gives the user the opportunity to specify data that is missing.
1.50 Consider this section of an example template:</p>
1.51 <pre><p template:element="package"><br /> <p template:element="author"><br /> Name: <input template:attribute-field="name" name="..." type="text" value="..."/><br /> </p><br /></p></pre>
1.52 -<p>Here, if the <code>author</code> element is not found in the
1.53 +<p>Here, if the <code>author</code> element is not found in the
1.54 output structure, no field will be produced in the Web page, no
1.55 opportunity will be given for an author to be specified, and no author
1.56 information will subsequently be editable. One solution is to introduce
1.57 -the <code>author</code> element into the XML document when
1.58 -creating the <code>package</code> element - this should then
1.59 +the <code>author</code> element into the XML document when
1.60 +creating the <code>package</code> element - this should then
1.61 "bootstrap" the process and ensure that the author details will remain
1.62 -editable as long as the <code>package</code> element exists.</p><h3>Ensuring Element Structure with Document Initialisation</h3><p>Although it is not necessary to use <a href="multiple.html#DocumentInitialisation">document initialisation</a> in resources, the above case would be detected by an input/initialiser stylesheet, and the <code>package</code> and <code>author</code> elements would be added if no way of adding them was mentioned in the template. Typically, we would employ <a href="selectors.html">selectors</a> to provide the ability to add elements in templates, and the above example could be extended as follows:</p><pre><p template:element="package"><br /> <p template:element="author"><br /> Name: <input template:attribute-field="name" name="..." type="text" value="..."/><br /> </p><br /> <p><br /> <input name="..." template:selector-field="add-author,author" type="submit" value="Add author" /><br /> </p><br /></p></pre><p>With the newly-added selector, we can see that <code>author</code> elements could at least be added by users of the application, but <code>package</code>
1.63 +editable as long as the <code>package</code> element exists.</p><h3>Ensuring Element Structure with Document Initialisation</h3><p>Although it is not necessary to use <a href="multiple.html#DocumentInitialisation">document initialisation</a> in resources, the above case would be detected by an input/initialiser stylesheet, and the <code>package</code> and <code>author</code> elements would be added if no way of adding them was mentioned in the template. Typically, we would employ <a href="selectors.html">selectors</a> to provide the ability to add elements in templates, and the above example could be extended as follows:</p><pre><p template:element="package"><br /> <p template:element="author"><br /> Name: <input template:attribute-field="name" name="..." type="text" value="..."/><br /> </p><br /> <p><br /> <input name="..." template:selector-field="add-author,author" type="submit" value="Add author" /><br /> </p><br /></p></pre><p>With the newly-added selector, we can see that <code>author</code> elements could at least be added by users of the application, but <code>package</code>
1.64 elements would still be impossible to create in the user interface. The
1.65 document initialisation mechanism distinguishes between these two cases
1.66 by looking for selectors which mention element names; here, the <code>template:selector-field</code> attribute has two parts to its value:</p><ol><li>A name used to identify the selector.</li><li>The name of an element: <code>author</code></li></ol><p>Since the <code>author</code>
1.67 @@ -69,11 +69,11 @@
1.68 if such information is to be used with such updated data, noting that
1.69 any changes in the structure of the such data will cause the selectors
1.70 to refer to the wrong parts of documents. To make updated documents
1.71 -available to XSLForms, the following call can be made on the <code>form</code> object (the third parameter in the <code>respond_to_form</code> method):</p><pre>form.set_document(document_name, updated_document)</pre><p>The updated selectors can then be obtained as usual:</p><pre>selectors = form.get_selectors()</pre><p>Typically,
1.72 +available to XSLForms, the following call can be made on the <code>form</code> object (the third parameter in the <code>respond_to_form</code> method):</p><pre>form.set_document(document_name, updated_document)</pre><p>The updated selectors can then be obtained as usual:</p><pre>selectors = form.get_selectors()</pre><p>Typically,
1.73 selectors should be accessed and used before initialisation since they
1.74 -refer to information that must already exist and can therefore be
1.75 +refer to information that must already exist and can therefore be
1.76 manipulated without preparatory work being done on the documents
1.77 involved.</p>
1.78 <ol>
1.79 </ol>
1.80 -</body></html>
1.81 \ No newline at end of file
1.82 +</body></html>