1.1 --- a/docs/selectors.html Sun Jul 17 22:33:17 2005 +0000
1.2 +++ b/docs/selectors.html Sun Jul 17 22:34:52 2005 +0000
1.3 @@ -2,52 +2,25 @@
1.4 <html xmlns="http://www.w3.org/1999/xhtml">
1.5 <head>
1.6
1.7 -
1.8 -
1.9 -
1.10 -
1.11 -
1.12 -
1.13 -
1.14 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
1.15 -
1.16 -
1.17 + <title>Creating Applications: Add Selectors</title>
1.18
1.19
1.20 -
1.21 -
1.22 -
1.23 -
1.24 -
1.25 -
1.26 -
1.27 -
1.28 - <title>Creating Applications: Add Selectors</title>
1.29 <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.30
1.31 -
1.32 -
1.33 + <link href="styles.css" rel="stylesheet" type="text/css" />
1.34
1.35 -
1.36 -
1.37 -
1.38 -
1.39 - <link href="styles.css" rel="stylesheet" type="text/css" />
1.40 </head>
1.41
1.42
1.43 <body>
1.44
1.45 -
1.46 -
1.47 -
1.48 <h1>Creating Applications: Add Selectors</h1>
1.49
1.50 -
1.51 -
1.52 -
1.53 -<p>In the previous activity we annotated the template with
1.54 -structural information, and these annotations should be sufficient in
1.55 +<p>In the previous activity we annotated the template
1.56 +with
1.57 +<a href="structure.html">structural information</a>,
1.58 +and these annotations should be sufficient in
1.59 presenting XML documents as Web pages for users to interact with.
1.60 However, in our design, we also wanted to be able to add and remove
1.61 list items from the example hierarchy:</p>
1.62 @@ -56,150 +29,174 @@
1.63
1.64 <li>A list of editable items, each containing...<br />
1.65
1.66 -
1.67 -
1.68 -
1.69 -
1.70 -
1.71 <ul>
1.72
1.73 -
1.74 -
1.75 <li>A list of editable items.</li>
1.76
1.77 -
1.78 -
1.79 -
1.80 -
1.81 -
1.82 </ul>
1.83
1.84 -
1.85 -
1.86 </li>
1.87
1.88 -
1.89 -
1.90 </ul>
1.91
1.92 -<p>What we want to do is to have buttons beside each list item
1.93 +<p>What we want to do is to have buttons beside each
1.94 +list item
1.95 (and subitem) which remove only that particular item. In addition, we
1.96 also want buttons which add items only to the particular list each
1.97 button appears beneath.<br />
1.98
1.99 -
1.100 -
1.101 </p>
1.102
1.103 -
1.104 -
1.105 <h2>Introducing Selectors</h2>
1.106
1.107 -
1.108 -
1.109 -<p>Taking the HTML example from before, we add some additional annotations to the template to produce something like this:</p>
1.110 +<p>So, we need to add buttons to the Web form which,
1.111 +upon being pressed, provide information about their context to
1.112 +the XSLForms framework and subsequently to the application, so that we
1.113 +know which part of the form is to be altered. To make sure that such
1.114 +contextual information is available in the Web form, we must include
1.115 +such references in the descriptions of these buttons in the template.</p>
1.116
1.117 -
1.118 +<p>The concept of a "selector" is a reference which is expressed
1.119 +in a special notation in the template, converted to concrete references
1.120 +in the final output, and can be interpreted when a user submits a form
1.121 +such that the associated section of the XML document version of the
1.122 +form data can be identified in connection with an action. In other
1.123 +words, we write a special value into the definition of a button in a
1.124 +Web form which can automatically be used to refer to other form data
1.125 +when the form is submitted.</p>
1.126
1.127 -<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 /><br /><!-- Template text between the start and the interesting part. --><br /><br /><div template:element="item"><br /> <p><br /> Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" /><br /> <input name="remove={template:this-position()}" type="submit" value="Remove" /><br /> </p><br /> <p><br /> Itself containing more items:<br /> </p><br /> <p template:element="subitem"><br /> Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" /><br /> <input name="remove2={template:this-position()}" type="submit" value="Remove" /><br /> </p><br /> <p><br /> <input name="add2={template:this-position()} type="submit" value="Add subitem" /><br /> </p><br /></div><br /><p><br /> <input name="add={template:this-position()} type="submit" value="Add item" /><br /></p><br /><br /><!-- Template text between the interesting part and the end. --><br /><br /></body><br /></html></pre>
1.128 +<p>Taking the HTML example from before, we add some
1.129 +additional annotations to the template to produce something
1.130 +like this:</p>
1.131 +
1.132 +<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><span style="font-weight: bold;"></span><br /> <span template:attribute="value"><br /> Some item: <input name="{template:field-name()}" type="text" value="{$this-value}" /><br /> </span><br /> <span style="font-weight: bold;"> <input name="remove={template:this-position()}" type="submit" value="Remove" /></span><br /> </p><br /> <p><br /> Itself containing more items:<br /> </p><br /> <p template:element="subitem"><br /> <span template:attribute="subvalue"><br /> Sub-item: <input name="{template:field-name()}" type="text" value="{$this-value}" /><br /> </span><br /> <span style="font-weight: bold;"> <input name="remove2={template:this-position()}" type="submit" value="Remove" /></span><br /> </p><br /> <span style="font-weight: bold;"> <p></span><br style="font-weight: bold;" /><span style="font-weight: bold;"> <input name="add2={template:this-position()}" type="submit" value="Add subitem" /></span><br style="font-weight: bold;" /><span style="font-weight: bold;"> </p></span><br /></div><br /><span style="font-weight: bold;"><p></span><br style="font-weight: bold;" /><span style="font-weight: bold;"> <input name="add={template:this-position()}" type="submit" value="Add item" /></span><br style="font-weight: bold;" /><span style="font-weight: bold;"></p></span><br /><br /><!-- Template text between the interesting part and the end. --><br /><br /></form><br /></body><br /></html></pre>
1.133
1.134 <h3>The Remove Buttons</h3>
1.135 -<p>Some of the attributes in the original HTML code have been changed:</p>
1.136
1.137 -
1.138 +<p>Some of the attributes in the original HTML code have been
1.139 +changed:</p>
1.140
1.141 <ul>
1.142
1.143 -
1.144 -
1.145 - <li>The <code>input</code> element for the first <code>Remove</code> button (mapping to <code>item</code> elements in the XML document) has a modified <code>name</code> attribute, containing the special <code>remove={template:this-position()}</code> value.</li>
1.146 + <li>The <code>input</code> element for the
1.147 +first <code>Remove</code> button (mapping
1.148 +to <code>item</code> elements in the XML document)
1.149 +has a modified <code>name</code> attribute,
1.150 +containing the special <code>remove={template:this-position()}</code>
1.151 +value.</li>
1.152
1.153 - <li>The <code>input</code> element for the second <code>Remove</code> button (mapping to <code>subitem</code> elements in the XML document) has a modified <code>name</code> attribute, containing the special <code>remove2={template:this-position()}</code> value.</li>
1.154 -
1.155 -
1.156 -
1.157 -
1.158 + <li>The <code>input</code> element for the second <code>Remove</code>
1.159 +button (mapping to <code>subitem</code> elements in the
1.160 +XML document) has a modified <code>name</code>
1.161 +attribute, containing the special <code>remove2={template:this-position()}</code>
1.162 +value.</li>
1.163
1.164 </ul>
1.165
1.166 -
1.167 -
1.168 -<p>What these amendments provide is a means for the XSLForms framework
1.169 +<p>What these amendments provide is a means for the XSLForms
1.170 +framework
1.171 to connect together the usage of a button in the Web form with an XML
1.172 document element.</p>
1.173
1.174 <ul>
1.175
1.176 - <li>The first <code>Remove</code> button appears within the <code>p</code> element which is annotated as mapping onto the <code>item</code>
1.177 + <li>The first <code>Remove</code> button
1.178 +appears within the <code>p</code> element which is
1.179 +annotated as mapping onto the <code>item</code>
1.180 element in the XML document. This means that the special value added
1.181 above will, in the final output, refer to that specific list item from
1.182 the XML document.</li>
1.183
1.184 - <li>The second <code>Remove</code> button appears within the <code>p</code> element which is annotated as mapping onto the <code>subitem</code>
1.185 + <li>The second <code>Remove</code> button appears
1.186 +within the <code>p</code> element which is
1.187 +annotated as mapping onto the <code>subitem</code>
1.188 element in the XML document. This means that the special value added
1.189 -above will, in the final output, refer to that specific list (sub)item from
1.190 +above will, in the final output, refer to that specific list (sub)item
1.191 +from
1.192 the XML document.</li>
1.193
1.194 </ul>
1.195
1.196 <h3>The Add Buttons</h3>
1.197 -<p>Some additional sections have been added to the original HTML code:</p>
1.198 +
1.199 +<p>Some additional sections have been added to the original HTML
1.200 +code:</p>
1.201
1.202 <ul>
1.203
1.204 - <li>An extra paragraph appears below the <code>subitem</code> paragraph, containing an <code>input</code> element which employs the special <code>add2={template:this-position()}</code> value in the <code>name</code> attribute to represent an <code>Add subitem</code> button.</li>
1.205 + <li>An extra paragraph appears below the <code>subitem</code>
1.206 +paragraph, containing an <code>input</code>
1.207 +element which employs the special <code>add2={template:this-position()}</code>
1.208 +value in the <code>name</code> attribute to
1.209 +represent an <code>Add subitem</code> button.</li>
1.210
1.211 - <li>An extra paragraph appears below the <code>item</code> section, containing an <code>input</code> element which employs the special <code>add={template:this-position()}</code> value in the <code>name</code> attribute to represent an <code>Add item</code> button.</li>
1.212 + <li>An extra paragraph appears below the <code>item</code>
1.213 +section, containing an <code>input</code> element
1.214 +which employs the special <code>add={template:this-position()}</code>
1.215 +value in the <code>name</code> attribute to
1.216 +represent an <code>Add item</code> button.</li>
1.217
1.218 </ul>
1.219
1.220 -<p>What these amendments provide is also a means for the XSLForms framework to connect these buttons to parts of the XML document.</p>
1.221 +<p>What these amendments provide is also a means for the XSLForms
1.222 +framework to connect these buttons to parts of the XML document.</p>
1.223
1.224 <ul>
1.225
1.226 - <li>The <code>Add subitem</code> button appears outside the <code>p</code> element mapping onto the <code>subitem</code> element in the XML document. Instead, it appears within the <code>p</code> element mapping onto the <code>item</code>
1.227 + <li>The <code>Add subitem</code> button appears
1.228 +outside the <code>p</code> element mapping onto
1.229 +the <code>subitem</code> element in the XML
1.230 +document. Instead, it appears within the <code>p</code>
1.231 +element mapping onto the <code>item</code>
1.232 element in the XML document. This means that the special value added
1.233 -above will, in the final output, refer to a specific <code>item</code> from
1.234 -the XML document, and the consequence of adding a <code>subitem</code> will be the extension of that list of <code>subitem</code> elements within that <code>item</code> element.</li>
1.235 +above will, in the final output, refer to a specific <code>item</code>
1.236 +from
1.237 +the XML document, and the consequence of adding a <code>subitem</code>
1.238 +will be the extension of that list of <code>subitem</code>
1.239 +elements within that <code>item</code> element.</li>
1.240
1.241 - <li>The <code>Add item</code> button appears outside the <code>p</code> element mapping onto the <code>item</code>
1.242 -element in the XML document. Instead, it appears within the <code>body</code> element mapping onto the top-level <code>structure</code>
1.243 + <li>The <code>Add item</code> button
1.244 +appears outside the <code>p</code>
1.245 +element mapping onto the <code>item</code>
1.246 +element in the XML document. Instead, it appears within the <code>body</code>
1.247 +element mapping onto the top-level <code>structure</code>
1.248 element in the XML document. This means that the special value added
1.249 above will, in the final output, refer to the top-level <code>structure</code>
1.250 element in
1.251 -the XML document, and the consequence of adding an <code>item</code> will be the extension of the main list of <code>item</code> elements.</li>
1.252 +the XML document, and the consequence of adding an <code>item</code> will
1.253 +be the extension of the main list of <code>item</code>
1.254 +elements.</li>
1.255
1.256 </ul>
1.257 +
1.258 <div class="WebStack">
1.259 <h3>Selector Annotation</h3>
1.260
1.261 -
1.262 -
1.263 -<p>Special values of the following form can be used to connect parts of
1.264 -the template with elements in the XML document representation of a form:</p>
1.265 -
1.266 -
1.267 +<p>Special values of the following form can be used to connect
1.268 +parts of the template with elements in the XML document representation
1.269 +of a form:</p>
1.270
1.271 <dl>
1.272 +
1.273 <dt><code>selector={template:this-position()}</code></dt>
1.274
1.275 -
1.276 -
1.277 - <dd>Given a selector name (<code>selector</code> in this example),
1.278 -this special value produces a reference to an XML document element (or
1.279 -attribute) in the final output. The referenced element or attribute is
1.280 -defined by those <code>template:element</code> and <code>template:attribute</code> annotations on template elements which surround the template element within which this special value is used.</dd>
1.281 -
1.282 -
1.283 + <dd>Given a selector name (<code>selector</code> in
1.284 +this example), this special value produces a reference to an XML
1.285 +document element (or attribute) in the final output. The referenced
1.286 +element or attribute is defined by those <code>template:element</code>
1.287 +and <code>template:attribute</code> annotations on
1.288 +template elements which surround the template element within
1.289 +which this special value is used.</dd>
1.290
1.291 </dl>
1.292
1.293 -
1.294 -
1.295 -<p>The <a href="reference.html">reference guide</a> provides a complete list of special values for use in template annotations.</p>
1.296 -
1.297 -
1.298 +<p>The <a href="reference.html">reference guide</a>
1.299 +provides a complete list of special values for use in template
1.300 +annotations.</p>
1.301
1.302 </div>
1.303 +
1.304 +<p>Whilst many forms consist only of text fields and action buttons, other types of data are very likely to also be used. <a href="multiple.html">Multiple-choice or enumerated value fields</a> in forms are covered in the next activity in the development <a href="overview.html">process</a>.</p>
1.305 +
1.306 </body>
1.307 </html>