0

Problem statement :

I'm parsing my XML document by using the LibXSLT file. Now I've updated my service Perl version from 5.16 to 5.30. I pulled the LibXSLT version accordingly. Seems I used the "1.80" LIBXSLT version for the 5.16 perl version whereas I used the "1.99" LIBXSLT version for the 5.30 perl version. I do a recursion to parse my xml in xsl file. In the new version alone, I faced an exception below that potential infinite recursion while parsing my XML document whereas it parsed well in the older version and suggested adjusting the max_depth variable limits in the LibXSLT file. By default, max_depth is set to 250 for both versions.

[![enter image description here][1]][1]

Sample LibXSLT Code :

use XML::LibXSLT;
use XML::LibXML;

my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new();

my $source = $parser->parse_file('foo.xml'); my $style_doc = $parser->parse_file('bar.xsl');

my $stylesheet = $xslt->parse_stylesheet($style_doc);

my $results = $stylesheet->transform($source);

print $stylesheet->output_string($results);

Exception thrown in the line : $stylesheet->transform($source);

Analysis :

As per my analysis, the max_depth variable in the LibXSLT is the maximum recursion allowed in our code. I could see the difference in maximum template recursion allowed in both versions depending on max_depth and shared it below. Is there any difference made in the updated LibXSLT version internally ?.

[![enter image description here][2]][2]

I suspect adjusting the limits of max_depth causes memory and performance issues at all in our service. Could you please share the thoughts about this issue. It will be really helpful for me.

Kaushik KR
  • 11
  • 2
  • While asking an XSLT question you need to provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example): (1) Well-formed input XML. (2) Your logic, and XSLT stylesheet that tries to implement it. (3) Desired output, based on the sample XML in the #1 above. (4) XSLT processor and its conformance with the XSLT standards: 1.0, 2.0, 3.0, or 4.0. – Yitzhak Khabinsky Apr 19 '23 at 03:36
  • You seem confused as to whether the effect is caused by an increase in the size of the XML or by switching to a different software version. It should be very easy to distinguish those two possible causes. It is possible of course that both are contributory factors; if the processor is running out of stack space to handle the depth of recursion, then it's possible that the new version uses more stack space than the old for the same task. – Michael Kay Apr 19 '23 at 08:34

0 Answers0