# HG changeset patch # User paulb # Date 1128720805 0 # Node ID 3407234fdf370d54dd8d77b89ab6031a6c1ce727 # Parent e5c46935aa8e6c69b00e8c23a6169a83539c6824 [project @ 2005-10-07 21:33:25 by paulb] Added notes about the set_document method and obtaining (with caution) updated selectors. diff -r e5c46935aa8e -r 3407234fdf37 docs/advice.html --- a/docs/advice.html Fri Oct 07 21:32:45 2005 +0000 +++ b/docs/advice.html Fri Oct 07 21:33:25 2005 +0000 @@ -4,7 +4,6 @@
package
element exists.Although it is not necessary to use document initialisation in resources, the above case would be detected by an input/initialiser stylesheet, and the package
and author
elements would be added if no way of adding them was mentioned in the template. Typically, we would employ selectors to provide the ability to add elements in templates, and the above example could be extended as follows:
<p template:element="package">
<p template:element="author">
Name: <input template:attribute-field="name" name="..." type="text" value="..."/>
</p>
<p>
<input name="..." template:selector-field="add-author,author" type="submit" value="Add author" />
</p>
</p>
With the newly-added selector, we can see that author
elements could at least be added by users of the application, but package
elements would still be impossible to create in the user interface. The
document initialisation mechanism distinguishes between these two cases
-by looking for selectors which mention element names; here, the template:selector-field
attribute has two parts to its value:
author
Since the author
element is mentioned, the mechanism knows not to create such elements automatically. However, since no such selector exists for package
elements, those elements are created automatically.
template:selector-field
attribute has two parts to its value:author
Since the author
+element is mentioned, the mechanism knows not to create such elements
+automatically. However, since no such selector exists for package
elements, those elements are created automatically.
After
+document initialisation or any other transformation, it is necessary to
+re-evaluate selector information in the context of the updated document
+if such information is to be used with such updated data, noting that
+any changes in the structure of the such data will cause the selectors
+to refer to the wrong parts of documents. To make updated documents
+available to XSLForms, the following call can be made on the form
object (the third parameter in the respond_to_form
method):
form.set_document(document_name, updated_document)
The updated selectors can then be obtained as usual:
selectors = form.get_selectors()
Typically, +selectors should be accessed and used before initialisation since they +refer to information that must already exist and can therefore be +manipulated without preparatory work being done on the documents +involved.