> 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 --------------------------------------------------------------------- To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org For additional commands, e-mail: xalan-dev-h...@xml.apache.org