# HG changeset patch # User paulb # Date 1106564358 0 # Node ID e4c463d826cb890d0c75560043487b70551b8752 # Parent b6e6fc98dcf0759b3f291206dcff10d5f318dc96 [project @ 2005-01-24 10:59:18 by paulb] Added examples of libxml2macro usage. Added libxml2macro.py to the setup script. diff -r b6e6fc98dcf0 -r e4c463d826cb README.txt --- a/README.txt Mon Jan 24 10:37:17 2005 +0000 +++ b/README.txt Mon Jan 24 10:59:18 2005 +0000 @@ -16,7 +16,46 @@ The libxml2macro.py program, along with the libxml2dom.macrolib package provide support for writing DOM-style code which is then translated to -libxml2-style code before being compiled to normal Python modules. This +libxml2mod-style code before being compiled to normal Python modules. This special translation should eliminate the need for high-level wrapper objects -in many cases, since the actual compiled code will be manipulating the libxml2 -objects directly - the principal exception being that of attribute nodes. +in most cases as well as low-level libxml2 objects, since the actual compiled +code will be using the libxml2mod functions directly. + +To use libxml2macro.py, first write your code using the typical PyXML DOM +style, but make sure that you use a common prefix for all node variables and +which is not used by any other kind of variable, and make sure that you do not +re-use node variables to refer to other kinds of object. Here is an example of +the coding style: + + # My module. + + import libxml2macro as my_ + + def processing_function(my_document, some_args): + + # Perform actions on nodes: + + my_node = my_document.createElementNS("namespace", "some-name") + + # Perform actions on other data as normal: + + some_function(some_args) + +Then, run libxml2macro.py on the module like this (using tests/macrotest.py as +an example): + + libxml2macro.py tests/macrotest.py + +This produces a compiled module that can be imported into Python; for example: + + cd tests + python + import macrotest + +It should be possible to run the module directly; for example: + + python tests/macrotest.pyc + +Note that running the module using the source filename will probably result in +the compiled module being overwritten and various errors being produced. So +don't do that! diff -r b6e6fc98dcf0 -r e4c463d826cb setup.py --- a/setup.py Mon Jan 24 10:37:17 2005 +0000 +++ b/setup.py Mon Jan 24 10:59:18 2005 +0000 @@ -11,5 +11,6 @@ author_email = "paul@boddie.org.uk", url = "http://www.boddie.org.uk/python/libxml2dom.html", version = libxml2dom.__version__, - packages = ["libxml2dom", "libxml2dom.macrolib"] + packages = ["libxml2dom", "libxml2dom.macrolib"], + scripts = ["libxml2macro.py"] )