14
# test that access to the XPath evaluation contexts
16
pctxt = libxml2.xpathParserContext(_obj=ctx)
17
ctxt = pctxt.context()
18
called = ctxt.function()
24
doc = libxml2.parseFile("tst.xml")
25
ctxt = doc.xpathNewContext()
26
res = ctxt.xpathEval("//*")
28
print "xpath query: wrong node set size"
30
if res[0].name != "doc" or res[1].name != "foo":
31
print "xpath query: wrong node set value"
33
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
34
libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
37
res = ctxt.xpathEval("foo(1)")
39
print "xpath extension failure"
44
res = ctxt.xpathEval("bar(1)")
46
print "xpath extension failure got %s expecting '3'"
50
ctxt.xpathFreeContext()
53
print "xpath function: failed to access the context"
54
print "xpath function: %s" % (called)
57
#memory debug specific
58
libxml2.cleanupParser()
59
if libxml2.debugMemory(1) == 0:
62
print "Memory leak %d bytes" % (libxml2.debugMemory(1))