[lxml-dev] String parameters to xslt transformation

Stefan Behnel stefan_ml at behnel.de
Thu Feb 5 21:58:15 CET 2009


Hi,

thanks for the patch.

Alexander Shigin wrote:
> lxml lacks ways to apply an external parameter containing both single
> and double quotes. 
>  
> The patch adds `transform` method to XSLT object with `params` and
> `strparams` argument. `params` works like `**kw` of `__call__` method
> (i.e. you still need to surround string literals with quotes).
> 
> `strparams` are treated literally, so you do not need to use any
> escaping or quotes.

I thought about this a bit, and I dislike the idea of adding a new
transform method only to support escaped parameters. I prefer having a
function or method that does the escaping, so that you could do

    transform = etree.XSLT(...)
    result = transform(doc, string_var = transform.strparam("'hi'"))

strparam() may return either an escaped string or a wrapper object that the
transformation code special cases internally, not sure what's better.

What do you think?

Stefan


More information about the lxml-dev mailing list