Re: [xml] arguments to an XSLT transformation in Python

On Wed, May 05, 2004 at 08:17:21PM +0200, Martijn Faassen wrote:
Hi there,

I have a Python script that uses an extension function, and also uses an 
argument that is passed to this function. For example:

import libxml2
import libxslt

def f(ctx, data):
    print data
    return 'nothing'
result = style.applyStylesheet(doc, {'data':"'test'"})
I can't get this to work though. When I pass in a python object what is 
passed to f() is an empty list ([]). The only thing that seems to be 
legal to pass is an xpath expression...
If not, is there a workaround?

Try something like this:

class Data:
        def __init__(self,data):
        def f(self,ctx,data)
                return 'nothing'


data = Data({'data':"'test'"})
result = style.applyStylesheet(doc, data.f)


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