1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/NOTES_libxml2macro.txt Mon Aug 15 18:29:47 2005 +0000
1.3 @@ -0,0 +1,48 @@
1.4 +Experiments
1.5 +-----------
1.6 +
1.7 +The libxml2macro.py program, along with the libxml2dom.macrolib package
1.8 +provide support for writing DOM-style code which is then translated to
1.9 +libxml2mod-style code before being compiled to normal Python modules. This
1.10 +special translation should eliminate the need for high-level wrapper objects
1.11 +in most cases as well as low-level libxml2 objects, since the actual compiled
1.12 +code will be using the libxml2mod functions directly.
1.13 +
1.14 +To use libxml2macro.py, first write your code using the typical PyXML DOM
1.15 +style, but make sure that you use a common prefix for all node variables and
1.16 +which is not used by any other kind of variable, and make sure that you do not
1.17 +re-use node variables to refer to other kinds of object. Here is an example of
1.18 +the coding style:
1.19 +
1.20 + # My module.
1.21 +
1.22 + import libxml2macro as my_
1.23 +
1.24 + def processing_function(my_document, some_args):
1.25 +
1.26 + # Perform actions on nodes:
1.27 +
1.28 + my_node = my_document.createElementNS("namespace", "some-name")
1.29 +
1.30 + # Perform actions on other data as normal:
1.31 +
1.32 + some_function(some_args)
1.33 +
1.34 +Then, run libxml2macro.py on the module like this (using tests/macrotest.py as
1.35 +an example):
1.36 +
1.37 + tools/libxml2macro.py tests/macrotest.py
1.38 +
1.39 +This produces a compiled module that can be imported into Python; for example:
1.40 +
1.41 + cd tests
1.42 + python
1.43 + import macrotest
1.44 +
1.45 +It should be possible to run the module directly; for example:
1.46 +
1.47 + python tests/macrotest.pyc
1.48 +
1.49 +Note that running the module using the source filename will probably result in
1.50 +the compiled module being overwritten and various errors being produced. So
1.51 +don't do that!