[xml-bindings]XSLT extension functions


I've been trying to write some extension functions in python, and have a 
few questions. Firstly, I've been trying something like the example in 

| def f(ctx, str):
|     return string.upper(str)
| libxslt.registerExtModuleFunction("foo", "http://example.com/foo";, f)

This works fine when I call it like in the example:

| <xsl:value-of select="foo:foo('bar')"/>

But, if I call it with something like:

| <xsl:value-of select="foo:foo(@date)"/>

Then instead of a string, the function gets passed a list of one 
PyCObject.  What is this object, and how do I turn it into something I can 
access?  I'm currently working around this by calling foo:foo(string(@date))
but that's a little hacky...

Secondly, with this method I am only able to return strings (or, I guess, 
numbers).  How would I go about returning a node set?  What would you 
create the node set from, since you need a parent node to create a new 

Finally, is it possible to create an XSL thing instead of creating an 
XPath function? So I could do something like:

| <foo:foo select="@date">

rather than using xsl:value-of.


[ gary inauspicious org ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]