st be freed after the result of the query is used.</p><h3>xpathext.py:</h3><p>This test shows how to extend the XPath engine with functions written in
python:</p><pre>import libxml2

def foo(ctx, x):
    return x + 1

doc = libxml2.parseFile("tst.xml")
ctxt = doc.xpathNewContext()
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
res = ctxt.xpathEval("foo(1)")
if res != 2:
    print "xpath extension failure"
doc.freeDoc()
ctxt.xpathFreeContext()</pre><p>Note how the extension function is registered w