code — insert Python code
<?xpt code # Python code inserted here ?>
The xpt builtin loadmodule command, loads a Python module MODULENAME. The processing instruction is removed from the input.
In the example below, a Python function is defined inside a XML processing-instruction and then called from an other processing-instruction. The latter will get replaced by the value returned by the Python function. ::code-start:: <?xpt code import libxml2 import xpt * def myFunction(nd,arg1): return "myFunction: nd="+nd.name+" arg1='"+arg1+"'" xpt.registerfunction("myFunction") ?> <example-code> <?xpt myFunction "an argument"?> </example-call> ::code-end::