You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by sh...@e-z.net on 2011/11/11 08:34:45 UTC
Re: [jira] [Created] (XALANC-720) Transformation can get stuck in
an infinite loop
>> Transformation can get stuck in an infinite loop
>> ------------------------------------------------
>>
>> Key: XALANC-720
>> URL: https://issues.apache.org/jira/browse/XALANC-720
>> Project: XalanC
>> Issue Type: Bug
>> Components: XalanC
>> Affects Versions: 1.10
>> Environment: Linux x86 (both 32 and 64-bit) - seen on RHEL 6,
>> Unbuntu and SLES
>> Reporter: Scott Exton
>> Assignee: Brian Minchau
>>
>>
>> The XalanTransformer::transform function will get stuck in an infinite
>> loop for certain stylesheets. This problem occurs if you execute the
>> following command (using the sample programs):
>> XalanTransform test.xml test.xsl test.out, with the following file
>> contents:
>>
>> -- test-xml
>> <?xml version="1.0"
>> encoding='UTF-8'?><HTTPResponse><ResponseLine><Version>HTTP/1.1</Version><StatusCode>401</StatusCode><Reason>Unauthorized</Reason></ResponseLine><Headers><Header
>> name="content-length">1244</Header><Header
>> name="content-type">text%2Fhtml</Header><Header
>> name="date">Thu,%2010%20Nov%202011%2004%3A21%3A08%20GMT</Header><Header
>> name="cache-control">no-cache</Header><Header
>> name="pragma">no-cache</Header></Headers><Cookies></Cookies></HTTPResponse>
>>
>> -- test.xsl
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> version="1.0">
>> <xsl:strip-space elements="*" />
>> <xsl:output method="xml" omit-xml-declaration="no"
>> encoding="UTF-8"
>> indent="yes" />
>>
>> <!-- Initially we start with a copy of the document. -->
>> <xsl:template match="@* | node()">
>> <xsl:copy>
>> <xsl:apply-templates select="@* | node()" />
>> </xsl:copy>
>> </xsl:template>
>>
>> <!-- Add a new header if it doesn't exist -->
>> <xsl:template match="//HTTPResponse/Headers/Header">
>> <xsl:choose>
>> <xsl:when test="@name='cache-control'">
>> <Header Name="hdr-2">val-2</Header>
>> </xsl:when>
>> <xsl:otherwise>
>>
>> </xsl:otherwise>
>> </xsl:choose>
>> <xsl:apply-templates
>> select="//HTTPResponse/Headers/Header"/>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>> --
>
> In your second template, the statement
> <xsl:apply-templates select="//HTTPResponse/Headers/Header"/>
> appears to invoke an unterminated recursion (See runtime memory
> allocation).
>
> If you replace the statement with
> <xsl:copy-of select='.'/>
> your stylesheet will probably work for you.
>
> - Steven J. Hathaway
>
If you replace your problem <xsl:apply-templates ...> with
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
the recursion problem will also be avoided.
- Steven J. Hathaway
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org