5 # Memory debug specific
15 # Small check to verify the context is correcly accessed
18 pctxt = libxslt.xpathParserContext(_obj=ctx)
19 ctxt = pctxt.context()
20 tctxt = ctxt.transformContext()
21 nodeName = tctxt.insertNode().name
25 return string.upper(str)
27 libxslt.registerExtModuleFunction("foo", "http://example.com/foo", f)
29 styledoc = libxml2.parseDoc("""
30 <xsl:stylesheet version='1.0'
31 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
32 xmlns:foo='http://example.com/foo'
33 xsl:exclude-result-prefixes='foo'>
35 <xsl:param name='bar'>failure</xsl:param>
36 <xsl:template match='/'>
37 <article><xsl:value-of select='foo:foo($bar)'/></article>
41 style = libxslt.parseStylesheetDoc(styledoc)
42 doc = libxml2.parseDoc("<doc/>")
43 result = style.applyStylesheet(doc, { "bar": "'success'" })
44 style.freeStylesheet()
47 root = result.children
48 if root.name != "article":
49 print "Unexpected root node name"
51 if root.content != "SUCCESS":
52 print "Unexpected root node content, extension function failed"
54 if nodeName != 'article':
55 print "The function callback failed to access its context"
60 # Memory debug specific
62 if libxml2.debugMemory(1) == 0:
65 print "Memory leak %d bytes" % (libxml2.debugMemory(1))