Re: Can I change maxvars?
Stefan Behnel <stefan_ml <at> behnel.de>
2015-06-21 11:41:43 GMT
Sam Bull schrieb am 21.06.2015 um 12:12:
> On Mon, 2014-07-14 at 20:52 +0200, Stefan Behnel wrote:
>> Sam Bull, 12.07.2014 17:15:
>>> I'm trying to process some XML files, and a few of them are several
>>> thousand lines long, and with the moderately complicated XSL I'm using,
>>> I seem to be hitting recursion limits.
>>> I'm currently getting this message:
>>> lxml.etree.XSLTApplyError: xsltApplyXSLTTemplate: A potential
>>> infinite template recursion was detected.
>>> You can adjust maxTemplateVars (--maxvars) in order to raise the
>>> maximum number of variables/params (currently set to 15000).
>>> It says I can adjust the value, but doesn't explain how, nor is this
>>> value mentioned anywhere in the documentation.
>>> I've just had to change the maxdepth, which can be done with
>>> XSLT.set_global_max_depth(), but there doesn't appear to be an
>>> equivalent for maxvars. How can I change this value?
>> You can't currently. The problem is, it was new in libxslt 1.1.27, and even
>> the next lxml release will still support everything back to 1.1.23, so this
>> needs a little C level hacking to support depending on the libxslt version
>> it compiles against.
>> The upside is that libxslt 1.1.27 also introduced a per-context setting
>> (maxTemplateVars), i.e. you can define the value for each stylesheet run
>> rather than setting a global value. A new keyword argument for XSLT()
>> should work nicely here, e.g. "max_recursion_vars". The same applies to
>> "maxTemplateDepth" in 1.1.27, which could be set as "max_recursion_depth"
>> in XSLT().
> Don't suppose there's been any progress on this?
No. Pull requests still welcome.
Mailing list for the lxml Python XML toolkit - http://lxml.de/
lxml <at> lxml.de