Can anyone tell me why this doesn't work:
import string
import libxml2
import libxslt
def func(ctx, *str):
return "a string"
libxslt.registerExtModuleFunction("foo", "http://example.com/foo", func)
styledoc = libxml2.parseDoc("""
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:foo='http://example.com/foo'
xsl:exclude-result-prefixes='foo'>
<xsl:template match='/'>
<xsl:variable name="myvar"
select="string(//param/name['uri']/following-sibling::value)"/>
<xsl:variable name="udpated" select="foo:foo($myvar)"/>
<test><xsl:value-of select="$updated"/></test>
</xsl:template>
</xsl:stylesheet>
""")
style = libxslt.parseStylesheetDoc(styledoc)
doc =
libxml2.parseDoc("<doc><param><name>uri</name><value>xyz</value></param></doc>")
result = style.applyStylesheet(doc, {})
print result
style.freeStylesheet()
doc.freeDoc()
It should call 'func' with "xyz" and return "a string" into the
<test/> element.
But it doesn't it barfs.
If you do this:
<xsl:variable name="myvar"
select="string(//param/name['uri']/following-sibling::value)"/>
<test><xsl:value-of select="foo:foo($myvar)"/></test>
it works.
That's not right is it?
Nic
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml