[lxml-dev] Does lxml/libxslt support passing in nodes as xsl:param parameters?

Stefan Behnel stefan_ml at behnel.de
Sun Jul 20 12:44:38 CEST 2008


Hi,

Paul Everitt wrote:
> My challenge is getting at data that was in scope at the time I ran the
> transformation.  The extension element won't have access to that
> information.

Ah, right, extension elements are registered at the time of the XSLT()
instantiation, not the call. Although that's not really a strict requirement...


>  I'll be in a threaded environment (WSGI request), so I'll
> need to arrange to stash the data away in a thread local, then grab it
> from within the extension element.

I think that's a feasible option for now.

I see two clean solutions to this:

1) make the "eval_context" dict property of the XPath/XSLT context
initialisable by use code

2) support passing extensions to an XSLT call (as well as the XSLT instantiation)

Both would require changing the XSLT call signature where we currently accept
arbitrary keyword arguments. A way not to break code here would be to add the
extensions/context dict as an optional positional argument, not as a keyword
argument.

I prefer option 1), as it's the least intrusive and solves many similar
problems without much overhead.

I take patches. :)

Stefan


More information about the lxml-dev mailing list