[xml] extension functions returning values into variables...
- From: Nic <nferrier tapsellferrier co uk>
- To: libxml <xml gnome org>
- Subject: [xml] extension functions returning values into variables...
- Date: Wed, 22 Feb 2006 21:14:06 +0000
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]