1 Introduction
2 ------------
3
4 XSLTools is a collection of modules and packages facilitating the development
5 of applications based on XML, XSL stylesheets and transformations, notably Web
6 applications involving complicated Web forms potentially consisting of
7 editable hierarchical structures and potentially involving "live" or "in-page"
8 dynamic updates to portions of those Web forms.
9
10 Quick Start
11 -----------
12
13 Try running the demo:
14
15 python tools/demo.py
16
17 An introductory guide to creating applications can be found in the docs
18 directory - see docs/index.html for the start page.
19
20 Contact, Copyright and Licence Information
21 ------------------------------------------
22
23 The current Web page for XSLTools at the time of release is:
24
25 http://www.boddie.org.uk/python/XSLTools.html
26
27 Copyright and licence information can be found in the docs directory - see
28 docs/COPYING.txt, docs/LICENCE.txt and docs/LICENCE-Sarissa.txt for more
29 information.
30
31 Dependencies
32 ------------
33
34 XSLTools has the following basic dependencies:
35
36 Package Release Information
37 ------- -------------------
38
39 libxml2dom 0.3
40 libxml2 Tested with 2.6.17
41 libxslt Tested with 1.1.12
42
43 The example Web applications require WebStack (release 1.1.1 or later).
44 The example PyQt applications have been tested with PyQt 3.15.
45
46 New in XSLTools 0.4 (Changes since XSLTools 0.3)
47 ------------------------------------------------
48
49 * Introduced dynamic parameter evaluation for multiple-choice fields in
50 order to support sources of multiple-choice values which reside in the
51 form data document itself.
52
53 New in XSLTools 0.3 (Changes since XSLTools 0.2)
54 ------------------------------------------------
55
56 * Introduced copying of multiple-choice value element contents so that
57 option element labels can differ from the underlying values.
58 * Added internationalisation support, providing the template:i18n annotation
59 and the template:i18n extension function.
60 * Updated the documentation to cover the above new features.
61 * Fixed non-GET/POST request method handling in WebResources.
62 * Added the xslform_preparemacro.py script.
63 * Added an experimental template:range extension function.
64
65 New in XSLTools 0.2 (Changes since XSLTools 0.1)
66 ------------------------------------------------
67
68 * Made a new XSLTools package and moved XSLOutput into it.
69 * Improved serialisation of transformation results so that output options
70 are observed (in some cases, at least).
71 * Fixed stylesheet and reference document paths so that libxslt should not
72 now become confused by ambiguous relative paths.
73 * Added expression parameters to XSLOutput.Processor so that in-document
74 data can be used to, for example, initialise multiple-choice field values.
75 * Added input/initialiser support so that input documents can be tidied or
76 initialised using information from the template.
77 * Added template:init for use with template:element in XSLForms to control
78 element initialisation where necessary.
79 * Added special high-level "macro" attributes (eg. template:attribute-field)
80 which should make templates easier to write and maintain.
81 * Added template:if to XSLForms, providing conditional output of annotated
82 elements.
83 * Added set_document to XSLForms.Fields.Form.
84 * Added prepare_parameters to the XSLFormsResource class in the
85 XSLForms.Resources.WebResources module.
86 * Added element-path, url-encode and choice XSLForms extension functions.
87 * Improved Unicode support in the XSLForms extension functions.
88 * Changed in-page requests to contain proper POST data.
89 * Fixed checkbox and radiobutton value detection in XSLForms.js.
90 * Updated the code to work with WebStack 1.0 changes and adopted the
91 new-style WebStack demonstration mechanism.
92 * Added XMLCalendar and XMLTable (to the XSLTools package).
93 * Added a dictionary (or word lookup) example application.
94 * Added a job candidate profile (or CV editor) example application.
95 * Added a template attribute reference and an XSLFormsResource guide to the
96 documentation.
97 * Added Debian package support (specifically Ubuntu package support).
98 * Added missing COPYING.txt file.
99 * Renamed the scripts to avoid naming issues in system-wide installations.
100 * Added a PyQt example based on the system configurator example, with the
101 form prepared in Qt Designer. This example runs in PyQt and in a Web
102 environment without any changes to the application code. In-page updates
103 are currently not implemented in the Web version, however.
104
105 Notes on In-Page Update Functionality
106 -------------------------------------
107
108 Special note #1: Konqueror seems in certain cases to remember replaced form
109 content (when replaceChild is used to replace regions of the page which
110 include form elements). This causes the browser to believe that more form
111 fields exist on the page than actually do so, and subsequent form submissions
112 thus include the values of such removed fields. A special hack is in place to
113 disable form fields by changing their names, thus causing Konqueror to not
114 associate such fields with the real, active fields; this hack does not seem to
115 cause problems for Mozilla. This needs some investigation to determine in
116 exactly which circumstances the problem arises.
117
118 Special note #2: Konqueror also seems to crash if asked to find elements using
119 an empty 'id' attribute string. This needs some investigation to see if it
120 really is the getElementById call that causes the crash.
121
122 Special note #3: Konqueror's XMLHttpRequest seems to append null characters to
123 the end of field values. Attempting to prune them before the request is sent
124 fails with a function like the following:
125
126 function fixValue(fieldValue) {
127 if (fieldValue.length == 0) {
128 return fieldValue;
129 } else if (fieldValue[fieldValue.length - 1] == '\0') {
130 return fieldValue.substr(0, fieldValue.length - 1);
131 } else {
132 return fieldValue;
133 }
134 }
135
136 This may be because it is the entire message that is terminated with the null
137 character, and that this happens only upon sending the message. Consequently,
138 some frameworks (notably mod_python) do not support in-page functionality when
139 used from Konqueror.
140
141 Various browsers (eg. Mozilla/Firefox, Konqueror) will not allow the
142 XMLHttpRequest in-page updates to function unless the URL used in the
143 requestUpdate JavaScript function is compatible with the URL at which the
144 browser finds the application. Currently, relative URLs are in use to avoid
145 this issue of compatibility, but should an absolute URL be deduced using the
146 WebStack API and then used, it may be possible that the values returned by
147 that API do not match the actual addresses entered into the address bar of the
148 browser.
149
150 To check the behaviour of the applications, it is possible to view the
151 document source of the pages served by applications and to verify that the
152 URLs mentioned in the JavaScript function calls (to 'requestUpdate') either be
153 a relative link or involve a URL similar to that which appears in the
154 browser's address bar. In some environments, the use of 'localhost' addresses
155 often confuses the browser and server; one workaround is to use real host
156 names or addresses instead of 'localhost'.
157
158 Choosing an element-path:
159
160 When specifying the "context" of the in-page update, one must imagine which
161 element the template fragment should operate within. If the template:id
162 attribute marks a particular section, then the element-path should be a path
163 to the applicable context element for that section in the complete template
164 document. Note that if a template:element attribute appears on the same
165 element as the template:id attribute then the element-path should refer to the
166 element specified in the template:element attribute.
167
168 Choosing where to put template:attribute, template:id and id:
169
170 When specifying the extent of a template fragment, one must be sure not to put
171 the template:id attribute on the same element as a template:attribute
172 annotation; otherwise, the generated code will be improperly extracted as a
173 fragment producing two versions of the element - one for when the specified
174 attribute is present, and one for when it is not present. Generally,
175 template:id and id can be placed on the same node, however.
176
177 Stable element ordering and element-path:
178
179 Within the element-path, the numbering of the elements will start at 1.
180 Therefore it is vital to choose a region of the form data structure with the
181 element-path which is isolated from surrounding elements whose positions would
182 otherwise be dependent on a stable ordering of elements, and whose processing
183 would be disrupted if some new elements suddenly appeared claiming the same
184 positions in the document. For example:
185
186 <item value=""> .../item$1/value
187 <type value=""/> .../item$1/type$1/value
188 <comment value=""/> .../item$1/comment$2/value
189 </item>
190
191 In-page update...
192
193 <comment value=""/> .../item$1/comment$1/value
194
195 Notes on XSL
196 ------------
197
198 libxslt seems to be quite liberal on the definition of runtime parameters, in
199 that there is no apparent need to explicitly declare the corresponding global
200 variables in stylesheets. Whilst this is nice, we may eventually need to
201 detect such variables and add them in the preparation process.
202
203 Release Procedures
204 ------------------
205
206 Update the XSLTools/__init__.py and XSLForms/__init__.py __version__
207 attributes.
208 Change the version number and package filename/directory in the documentation.
209 Change code examples in the documentation if appropriate.
210 Update the release notes (see above).
211 Check the setup.py file and ensure that all package directories are mentioned.
212 Check the release information in the PKG-INFO file and in the package
213 changelog (and other files).
214 Tag, export.
215 Generate the API documentation.
216 Remove generated .pyc files: rm `find . -name "*.pyc"`
217 Archive, upload.
218 Upload the introductory documentation.
219 Update PyPI, PythonInfo Wiki, Vaults of Parnassus entries.
220
221 Generating the API Documentation
222 --------------------------------
223
224 In order to prepare the API documentation, it is necessary to generate some
225 Web pages from the Python source code. For this, the epydoc application must
226 be available on your system. Then, inside the distribution directory, run the
227 apidocs.sh tool script as follows:
228
229 ./tools/apidocs.sh
230
231 Some warnings may be generated by the script, but the result should be a new
232 apidocs directory within the distribution directory.
233
234 Making Packages
235 ---------------
236
237 To make Debian-based packages:
238
239 1. Create new package directories under packages if necessary.
240 2. Make a symbolic link in the distribution's root directory to keep the
241 Debian tools happy:
242
243 ln -s packages/ubuntu-hoary/python2.4-xsltools/debian/
244
245 3. Run the package builder:
246
247 dpkg-buildpackage -rfakeroot
248
249 4. Locate and tidy up the packages in the parent directory of the
250 distribution's root directory.