mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-17 18:21:05 +03:00
added more informations in the libxml2-python package including docs.
* configure.in libxml.spec.in python/Makefile.am python/TODO python/generator.py python/libxml2class.txt: added more informations in the libxml2-python package including docs. Slightly changed the class hierarchy * python/tests/*: added basic regression tests infrastructure too Daniel
This commit is contained in:
29
python/tests/tstxpath.py
Executable file
29
python/tests/tstxpath.py
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python -u
|
||||
import libxml2
|
||||
|
||||
def foo(x):
|
||||
# print "foo called %s" % (x)
|
||||
return x + 1
|
||||
|
||||
def bar(x):
|
||||
# print "foo called %s" % (x)
|
||||
return "%s" % (x + 1)
|
||||
|
||||
doc = libxml2.parseFile("tst.xml")
|
||||
ctxt = doc.xpathNewContext()
|
||||
res = ctxt.xpathEval("//*")
|
||||
print res
|
||||
|
||||
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
|
||||
libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
|
||||
i = 10000
|
||||
while i > 0:
|
||||
res = ctxt.xpathEval("foo(1)")
|
||||
i = i - 1
|
||||
print res
|
||||
i = 10000
|
||||
while i > 0:
|
||||
res = ctxt.xpathEval("bar(1)")
|
||||
i = i - 1
|
||||
print res
|
||||
doc.freeDoc()
|
Reference in New Issue
Block a user