[lxml-dev] String parameters to xslt transformation
Stefan Behnel
stefan_ml at behnel.de
Fri Feb 6 17:14:54 CET 2009
Alexander Shigin wrote:
> Stefan Behnel wrote:
>> 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?
>
> I took another look at libxslt internals. There isn't any way to escape
> single or double quote in argument. A citation from libxslt/variables.c,
> xsltProcessUserParamInternal:
>
> * enclosed single quotes (double quotes). If the string which you want to
> * be treated literally contains both single and double quotes (e.g. Meet
> * at Joe's for "Twelfth Night" at 7 o'clock) then there is no suitable
> * quoting character. You cannot use ' or " inside the string
> * because the replacement of character entities with their equivalents is
> * done at a different stage of processing. The solution is to call
> * xsltQuoteUserParams or xsltQuoteOneUserParam.
>
> So, the only way is to create a special class like XSLTQuotedVariable.
> I've made a second version of the patch with `strparam()` interface.
Thanks! That looks much better. I'll fix up a couple of things and check
if I can't get Cython to support classmethods for this purpose. If all
works out, I'll add it for 2.2.
Stefan
More information about the lxml-dev
mailing list