1 See docs/index.html for the libxml2dom documentation.
2
3 Testing
4 -------
5
6 Some of the tests require libxml2macro.py to be run on the test source code
7 first. Read the docstrings for the various test files before attempting to run
8 any of them.
9
10 Issues
11 ------
12
13 Use of importNode seems to cause some kind of memory issue, probably related
14 to nodes being shared across documents. This was observed in libxml2 2.6.0 but
15 appears to be fixed in libxml2 2.6.16.
16
17 Even compared to minidom, importNode may seem very slow (even the
18 libxml2dom.macrolib implementation, too). A way is needed to get libxml2 to do
19 the node copying itself.
20
21 Experiments
22 -----------
23
24 The libxml2macro.py program, along with the libxml2dom.macrolib package
25 provide support for writing DOM-style code which is then translated to
26 libxml2mod-style code before being compiled to normal Python modules. This
27 special translation should eliminate the need for high-level wrapper objects
28 in most cases as well as low-level libxml2 objects, since the actual compiled
29 code will be using the libxml2mod functions directly.
30
31 To use libxml2macro.py, first write your code using the typical PyXML DOM
32 style, but make sure that you use a common prefix for all node variables and
33 which is not used by any other kind of variable, and make sure that you do not
34 re-use node variables to refer to other kinds of object. Here is an example of
35 the coding style:
36
37 # My module.
38
39 import libxml2macro as my_
40
41 def processing_function(my_document, some_args):
42
43 # Perform actions on nodes:
44
45 my_node = my_document.createElementNS("namespace", "some-name")
46
47 # Perform actions on other data as normal:
48
49 some_function(some_args)
50
51 Then, run libxml2macro.py on the module like this (using tests/macrotest.py as
52 an example):
53
54 libxml2macro.py tests/macrotest.py
55
56 This produces a compiled module that can be imported into Python; for example:
57
58 cd tests
59 python
60 import macrotest
61
62 It should be possible to run the module directly; for example:
63
64 python tests/macrotest.pyc
65
66 Note that running the module using the source filename will probably result in
67 the compiled module being overwritten and various errors being produced. So
68 don't do that!