Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19168 > unrolled thread

etree/lxml/XSLT and dynamic stylesheet variables

Started byAdam Tauno Williams <awilliam@whitemice.org>
First post2012-01-20 15:38 -0500
Last post2012-01-20 15:38 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  etree/lxml/XSLT and dynamic stylesheet variables Adam Tauno Williams <awilliam@whitemice.org> - 2012-01-20 15:38 -0500

#19168 — etree/lxml/XSLT and dynamic stylesheet variables

FromAdam Tauno Williams <awilliam@whitemice.org>
Date2012-01-20 15:38 -0500
Subjectetree/lxml/XSLT and dynamic stylesheet variables
Message-ID<mailman.4896.1327093938.27778.python-list@python.org>
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
<http://lxml.de/xpathxslt.html#stylesheet-parameters> 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?

-- 
System & Network Administrator [ LPI & NCLA ]
<http://www.whitemiceconsulting.com>
OpenGroupware Developer <http://www.opengroupware.us>
Adam Tauno Williams

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web