#!/usr/bin/python -u
import sys
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
import libxslt
styledoc = libxml2.parseDoc(
"""
;
str:tokenize('2001-06-03T11:40:23', '-T:')
;
str:tokenize('date math str')
;
""")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc("")
result = style.applyStylesheet(doc, None)
stringval = style.saveResultToString(result)
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
expect="""
;
str:tokenize('2001-06-03T11:40:23', '-T:')
20010603114023;
str:tokenize('date math str')
datemathstr;
"""
if stringval != expect:
print("Exslt processing failed")
sys.exit(255)
# Memory debug specific
libxslt.cleanup()
if libxml2.debugMemory(1) == 0:
print("OK")
else:
print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
libxml2.dumpMemory()
sys.exit(255)