Reputation: 1
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.
Upvotes: 0
Views: 41