[xsl] libxslt 10124 detects a potential infinite template recursion whereas there is not a potential infinite template recursion

Subject: [xsl] libxslt 10124 detects a potential infinite template recursion whereas there is not a potential infinite template recursion
From: spam.spam.spam.spam@xxxxxxx
Date: Sat, 19 Feb 2011 17:06:52 +0100 (CET)
Hello,

I have these files :
-example.xsl
-example.xml

If I use:
$ xsltproc --version
Using libxml 20632, libxslt 10117 and libexslt 813
xsltproc was compiled against libxml 20632, libxslt 10124 and libexslt 813
libxslt 10117 was compiled against libxml 20632
libexslt 813 was compiled against libxml 20632

Then I run:
xsltproc --param param "'abc:def:ghi:'" example.xsl example.xml

I get:
<?xml version="1.0"?>
abcdefghi

Which is the expected result... I am happy :-)

Now If I an other libxslt version:
$ xsltproc --version
Using libxml 20632, libxslt 10124 and libexslt 813
xsltproc was compiled against libxml 20632, libxslt 10124 and libexslt 813
libxslt 10124 was compiled against libxml 20632
libexslt 813 was compiled against libxml 20632

Then I run the same command:
xsltproc --param param "'abc:def:ghi:'" example.xsl example.xml

I get:
runtime error: file example.xsl line 12 element choose
xsltApplyXSLTTemplate: A potential infinite template recursion was detected.
You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).
Templates:
#0 name myrecursivetemplate
#1 name myrecursivetemplate
#2 name myrecursivetemplate
#3 name myrecursivetemplate
#4 name myrecursivetemplate
#5 name myrecursivetemplate
#6 name myrecursivetemplate
#7 name myrecursivetemplate
#8 name myrecursivetemplate
#9 name myrecursivetemplate
#10 name myrecursivetemplate
#11 name myrecursivetemplate
#12 name myrecursivetemplate
#13 name myrecursivetemplate
#14 name myrecursivetemplate
Variables:
no result for example.xml

So the old libxslt version (10117) works better than the new libxslt version (10124) because it detects a potential infinite template recursion only when there is really a potential infinite template recursion.

Can you correct this?

Thank you.

---

$ cat example.xml 
<?xml version="1.0" encoding="UTF-8" ?>
<example>
</example>

$ cat example.xsl 
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns="http://www.w3.org/1999/xhtml";>
	<xsl:output method="xml" />
	<xsl:param name="param" />
	<xsl:strip-space elements="*" />
	<xsl:template match="/">
		<xsl:call-template name="myrecursivetemplate">
			<xsl:with-param name="param" select="$param" />
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="myrecursivetemplate">
		<xsl:choose>
			<xsl:when test="string-length($param)=0">
				<xsl:value-of select="$param" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="substring-before($param, ':')" />
				<xsl:call-template name="myrecursivetemplate">
					<xsl:with-param name="param" select="substring-after($param, ':')" />
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>

$ cat run.sh 
xsltproc --param param "'abc:def:ghi:'" example.xsl example.xml

Current Thread