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 this instance the XalanTransform binary will never complete.  The problem 
stems from the '<xsl:apply-templates select="//HTTPResponse/Headers/Header"/>' 
line.  If this line is removed from the XSLT everything works correctly.  So, 
the XSLT is probably malformed, but the program still shouldn't get stuck in an 
infinite loop.

Unfortunately I don't know the xalan-c code at all, but I have managed to work 
out that we get stuck in the ElemTemplateElement::execute() function.  The 
following condition,
currentElement->getInvoker(executionContext) == invoker, is never met, which 
means that we never break out of the loop.

Any help would be appreciated.



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org
For additional commands, e-mail: xalan-dev-h...@xml.apache.org

Reply via email to