etree/lxml/XSLT and dynamic stylesheet variables

  • Thread starter Adam Tauno Williams
  • Start date


Adam Tauno Williams

I'm using etree to perform XSLT transforms, such as -

from lxml import etree
source = etree.parse(self.rfile)
xslt = etree.fromstring(self._xslt)
transform = etree.XSLT(xslt)
result = transform(source)

according to the docs at
<> I can pass a
dictionary of parameters to transform, such as -

result = transform(doc_root, **{'non-python-identifier': '5'})

Can I pass a dictionary-like object? That doesn't seem to be working.
I need to perform dynamic lookup of variables for the stylesheet.

I've subclassed dictionary and overloaded [], get, has_key, and in to
perform the required lookups; these work in testing. But passing the
object to transform doesn't work.

If that isn't possible is there an alternate XSLT implementation for
python that would allow calling back for variable values?


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question