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.3 (0.3.6 recommended)
40 libxml2 Tested with 2.6.17
41 libxslt Tested with 1.1.12
42
43 The example Web applications require WebStack (release 1.2.2 or later).
44 The example PyQt applications have been tested with PyQt 3.15.
45
46 New in XSLTools 0.4.5 (Changes since XSLTools 0.4.4)
47 ----------------------------------------------------
48
49 * Fixed the result of transformations in XSLOutput: proper document nodes
50 are now produced.
51
52 New in XSLTools 0.4.4 (Changes since XSLTools 0.4.3)
53 ----------------------------------------------------
54
55 * Fixed translation selection for the template:i18n annotation attribute,
56 not just for the template:i18n extension function - more apologies for
57 resulting output changes!
58 * Improved the template fixing stylesheet and added some documentation for
59 the script and the related expr-prefix attribute.
60 * Introduced WebStack 1.2.2 EncodingSelector and encoding changes.
61 * Added docstring and return value for the write_month_to_document function
62 in XSLTools.XMLCalendar.
63
64 New in XSLTools 0.4.3 (Changes since XSLTools 0.4.2)
65 ----------------------------------------------------
66
67 * Fixed translation selection when an unsupported locale is specified,
68 choosing the first locale as the default (rather than exposing the values
69 themselves as translations). Note that this is an unfortunate and subtle
70 change which may affect application output - apologies are hereby offered!
71
72 New in XSLTools 0.4.2 (Changes since XSLTools 0.4.1)
73 ----------------------------------------------------
74
75 * Added a content type check in the XSLFormsResource class, permitting
76 non-form-based resources to access the raw request data, rather than have
77 the data processed unsuccessfully and consequently discarded.
78 * Added a script and a function to fix template namespaces after editing in
79 a careless editor.
80 * Changed libxml2mod and libxsltmod import details to try libxmlmods -
81 suggested by Lucian Wischik for libxml2dom.
82
83 New in XSLTools 0.4.1 (Changes since XSLTools 0.4)
84 --------------------------------------------------
85
86 * Made translations specified using the template:i18n annotation take
87 priority over template:value annotations.
88 * Added expression-based template:i18n annotations, and provided fallback
89 output for such translations based on the value of the evaluated
90 expression.
91
92 New in XSLTools 0.4 (Changes since XSLTools 0.3.1)
93 --------------------------------------------------
94
95 * Changed the preparation of templates to produce rule-based output
96 stylesheets, thus permitting recursive templates. This requires an extra
97 expr-prefix annotation to be used in certain kinds of templates.
98 * Added a recursive template example application.
99 * Changed fragment production to use original template documents instead of
100 output stylesheets.
101 * Changed the in_page_resources attribute to provide the output identifier,
102 thus changing the prepare_fragment method in Web resources so that only
103 the fragment identifier needs to be supplied.
104 * Added the XSLForms.Resources.WebResources.prepare_resources method for the
105 preparation of initialiser and output stylesheets before an application is
106 run.
107 * Changed selectors to not automatically create elements in the form data
108 document unless requested to do so. Introduced a Form.get_selector
109 method in XSLForms.Fields.
110 * Permitted the creation of hierarchies of elements in
111 XSLForms.Utils.add_elements.
112 * Introduced dynamic parameter evaluation for multiple-choice fields in
113 order to support sources of multiple-choice values which reside in the
114 form data document itself.
115 * Added the FixNamespace.xsl stylesheet to correct documents saved by HTML
116 editors which strip namespace prefixes.
117 * Fixed filesystem encoding issues in the Candidate example; fixed language
118 preference access in the Configurator and VerySimple examples.
119 * Changed the BaseHTTPRequestHandler version of the Candidate example to
120 store data in a subdirectory of the current working directory, thus
121 allowing the demonstration application to work after package installation.
122
123 New in XSLTools 0.3.1 (Changes since XSLTools 0.3)
124 --------------------------------------------------
125
126 * Fixed copyright and licensing information.
127
128 New in XSLTools 0.3 (Changes since XSLTools 0.2)
129 ------------------------------------------------
130
131 * Introduced copying of multiple-choice value element contents so that
132 option element labels can differ from the underlying values.
133 * Added internationalisation support, providing the template:i18n annotation
134 and the template:i18n extension function.
135 * Updated the documentation to cover the above new features.
136 * Fixed non-GET/POST request method handling in WebResources.
137 * Added the xslform_preparemacro.py script.
138 * Added an experimental template:range extension function.
139
140 New in XSLTools 0.2 (Changes since XSLTools 0.1)
141 ------------------------------------------------
142
143 * Made a new XSLTools package and moved XSLOutput into it.
144 * Improved serialisation of transformation results so that output options
145 are observed (in some cases, at least).
146 * Fixed stylesheet and reference document paths so that libxslt should not
147 now become confused by ambiguous relative paths.
148 * Added expression parameters to XSLOutput.Processor so that in-document
149 data can be used to, for example, initialise multiple-choice field values.
150 * Added input/initialiser support so that input documents can be tidied or
151 initialised using information from the template.
152 * Added template:init for use with template:element in XSLForms to control
153 element initialisation where necessary.
154 * Added special high-level "macro" attributes (eg. template:attribute-field)
155 which should make templates easier to write and maintain.
156 * Added template:if to XSLForms, providing conditional output of annotated
157 elements.
158 * Added set_document to XSLForms.Fields.Form.
159 * Added prepare_parameters to the XSLFormsResource class in the
160 XSLForms.Resources.WebResources module.
161 * Added element-path, url-encode and choice XSLForms extension functions.
162 * Improved Unicode support in the XSLForms extension functions.
163 * Changed in-page requests to contain proper POST data.
164 * Fixed checkbox and radiobutton value detection in XSLForms.js.
165 * Updated the code to work with WebStack 1.0 changes and adopted the
166 new-style WebStack demonstration mechanism.
167 * Added XMLCalendar and XMLTable (to the XSLTools package).
168 * Added a dictionary (or word lookup) example application.
169 * Added a job candidate profile (or CV editor) example application.
170 * Added a template attribute reference and an XSLFormsResource guide to the
171 documentation.
172 * Added Debian package support (specifically Ubuntu package support).
173 * Added missing COPYING.txt file.
174 * Renamed the scripts to avoid naming issues in system-wide installations.
175 * Added a PyQt example based on the system configurator example, with the
176 form prepared in Qt Designer. This example runs in PyQt and in a Web
177 environment without any changes to the application code. In-page updates
178 are currently not implemented in the Web version, however.
179
180 Notes on In-Page Update Functionality
181 -------------------------------------
182
183 Special note #1: Konqueror seems in certain cases to remember replaced form
184 content (when replaceChild is used to replace regions of the page which
185 include form elements). This causes the browser to believe that more form
186 fields exist on the page than actually do so, and subsequent form submissions
187 thus include the values of such removed fields. A special hack is in place to
188 disable form fields by changing their names, thus causing Konqueror to not
189 associate such fields with the real, active fields; this hack does not seem to
190 cause problems for Mozilla. This needs some investigation to determine in
191 exactly which circumstances the problem arises.
192
193 Special note #2: Konqueror also seems to crash if asked to find elements using
194 an empty 'id' attribute string. This needs some investigation to see if it
195 really is the getElementById call that causes the crash.
196
197 Special note #3: Konqueror's XMLHttpRequest seems to append null characters to
198 the end of field values. Attempting to prune them before the request is sent
199 fails with a function like the following:
200
201 function fixValue(fieldValue) {
202 if (fieldValue.length == 0) {
203 return fieldValue;
204 } else if (fieldValue[fieldValue.length - 1] == '\0') {
205 return fieldValue.substr(0, fieldValue.length - 1);
206 } else {
207 return fieldValue;
208 }
209 }
210
211 This may be because it is the entire message that is terminated with the null
212 character, and that this happens only upon sending the message. Consequently,
213 some frameworks (notably mod_python) do not support in-page functionality when
214 used from Konqueror.
215
216 Various browsers (eg. Mozilla/Firefox, Konqueror) will not allow the
217 XMLHttpRequest in-page updates to function unless the URL used in the
218 requestUpdate JavaScript function is compatible with the URL at which the
219 browser finds the application. Currently, relative URLs are in use to avoid
220 this issue of compatibility, but should an absolute URL be deduced using the
221 WebStack API and then used, it may be possible that the values returned by
222 that API do not match the actual addresses entered into the address bar of the
223 browser.
224
225 To check the behaviour of the applications, it is possible to view the
226 document source of the pages served by applications and to verify that the
227 URLs mentioned in the JavaScript function calls (to 'requestUpdate') either be
228 a relative link or involve a URL similar to that which appears in the
229 browser's address bar. In some environments, the use of 'localhost' addresses
230 often confuses the browser and server; one workaround is to use real host
231 names or addresses instead of 'localhost'.
232
233 Choosing an element-path:
234
235 When specifying the "context" of the in-page update, one must imagine which
236 element the template fragment should operate within. If the template:id
237 attribute marks a particular section, then the element-path should be a path
238 to the applicable context element for that section in the complete template
239 document. Note that if a template:element attribute appears on the same
240 element as the template:id attribute then the element-path should refer to the
241 element specified in the template:element attribute.
242
243 Choosing where to put template:attribute, template:id and id:
244
245 When specifying the extent of a template fragment, one must be sure not to put
246 the template:id attribute on the same element as a template:attribute
247 annotation; otherwise, the generated code will be improperly extracted as a
248 fragment producing two versions of the element - one for when the specified
249 attribute is present, and one for when it is not present. Generally,
250 template:id and id can be placed on the same node, however.
251
252 Stable element ordering and element-path:
253
254 Within the element-path, the numbering of the elements will start at 1.
255 Therefore it is vital to choose a region of the form data structure with the
256 element-path which is isolated from surrounding elements whose positions would
257 otherwise be dependent on a stable ordering of elements, and whose processing
258 would be disrupted if some new elements suddenly appeared claiming the same
259 positions in the document. For example:
260
261 <item value=""> .../item$1/value
262 <type value=""/> .../item$1/type$1/value
263 <comment value=""/> .../item$1/comment$2/value
264 </item>
265
266 In-page update...
267
268 <comment value=""/> .../item$1/comment$1/value
269
270 Notes on XSL
271 ------------
272
273 libxslt seems to be quite liberal on the definition of runtime parameters, in
274 that there is no apparent need to explicitly declare the corresponding global
275 variables in stylesheets. Whilst this is nice, we may eventually need to
276 detect such variables and add them in the preparation process.
277
278 Release Procedures
279 ------------------
280
281 Update the XSLTools/__init__.py and XSLForms/__init__.py __version__
282 attributes.
283 Change the version number and package filename/directory in the documentation.
284 Change code examples in the documentation if appropriate.
285 Update the release notes (see above).
286 Check the setup.py file and ensure that all package directories are mentioned.
287 Check the release information in the PKG-INFO file and in the package
288 changelog (and other files).
289 Tag, export.
290 Generate the example resources.
291 Generate the API documentation.
292 Remove generated .pyc files: rm `find . -name "*.pyc"`
293 Archive, upload.
294 Upload the introductory documentation.
295 Update PyPI, PythonInfo Wiki, Vaults of Parnassus entries.
296
297 Generating the Example Resources
298 --------------------------------
299
300 In order to prepare the example resources, the prepare_demo.py script must be
301 run as follows:
302
303 python tools/prepare_demo.py
304
305 This will ensure that all initialiser and output stylesheets are created and
306 are thus installed by packages.
307
308 Generating the API Documentation
309 --------------------------------
310
311 In order to prepare the API documentation, it is necessary to generate some
312 Web pages from the Python source code. For this, the epydoc application must
313 be available on your system. Then, inside the distribution directory, run the
314 apidocs.sh tool script as follows:
315
316 ./tools/apidocs.sh
317
318 Some warnings may be generated by the script, but the result should be a new
319 apidocs directory within the distribution directory.
320
321 Making Packages
322 ---------------
323
324 To make Debian-based packages:
325
326 1. Create new package directories under packages if necessary.
327 2. Make a symbolic link in the distribution's root directory to keep the
328 Debian tools happy:
329
330 ln -s packages/ubuntu-hoary/python2.4-xsltools/debian/
331
332 3. Run the package builder:
333
334 dpkg-buildpackage -rfakeroot
335
336 4. Locate and tidy up the packages in the parent directory of the
337 distribution's root directory.