You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/10/03 13:39:28 UTC

DO NOT REPLY [Bug 13243] New: - "Variable accessed before it is bound!" error in nested calls

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13243>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13243

"Variable accessed before it is bound!" error in nested <xsl:call-template> calls

           Summary: "Variable accessed before it is bound!" error in nested
                    <xsl:call-template> calls
           Product: XalanJ2
           Version: 2.2.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: richard.heath@fdgroup.com


In our xslt we frequently call templates with parameters that are the result 
of other templates which are then copied to output. This has worked in all 
versions of Xalan, Saxon and XT up until the latest Xalan that I have tried, 
2.2.0 (It also fails with the versions in J2SDK 1.4.1 and in Tomcat 4.1.12)

A sample stylesheet that shows the problem follows :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<xsl:call-template name="test1">
		<xsl:with-param name="param">paramval1</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template name="test1">
	<xsl:param name="param">paramval2</xsl:param>
	
	<xsl:call-template name="outer">
		<xsl:with-param name="contents">
			<xsl:call-template name="test3"/>
			<xsl:call-template name="test2">
			      <xsl:with-param name="param">
                                      <xsl:value-of select="$param"/>
                              </xsl:with-param>
			</xsl:call-template>
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template name="outer">
	<xsl:param name="contents"/>
	<xsl:copy-of select="$contents"/>
</xsl:template>


<xsl:template name="test2">
	<xsl:param name="param">paramval3</xsl:param>
	param = <xsl:value-of select="$param"/>
</xsl:template>

<xsl:template name="test3">
</xsl:template>

</xsl:stylesheet>

The problem goes away if the call to the test3 template is removed or the 
contents call-template and with-param are removed and the test3 and test2 
calls made directly.

At the end of this report is the stack produced.

I hope you can fix this problem as we use this technique throughout our 
stylesheets, which total in size to 1.5MBytes. It is a major problem for us.

Richard Heath.

javax.xml.transform.TransformerException: Variable accessed before it is bound!
	at org.apache.xpath.VariableStack.getLocalVariable
(VariableStack.java:304)
	at org.apache.xpath.operations.Variable.execute(Variable.java:172)
	at org.apache.xpath.objects.XRTreeFragSelectWrapper.execute
(XRTreeFragSelectWrapper.java:57)
	at org.apache.xpath.XPath.execute(XPath.java:318)
	at org.apache.xalan.templates.ElemWithParam.getValue
(ElemWithParam.java:240)
	at org.apache.xalan.templates.ElemCallTemplate.execute
(ElemCallTemplate.java:259)
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2182)
	at org.apache.xalan.transformer.TransformerImpl.transformToRTF
(TransformerImpl.java:1725)
	at org.apache.xalan.templates.ElemWithParam.getValue
(ElemWithParam.java:256)
	at org.apache.xalan.templates.ElemCallTemplate.execute
(ElemCallTemplate.java:259)
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2182)
	at org.apache.xalan.templates.ElemTemplate.execute
(ElemTemplate.java:430)
	at org.apache.xalan.templates.ElemCallTemplate.execute
(ElemCallTemplate.java:279)
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2182)
	at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
(TransformerImpl.java:2008)
	at org.apache.xalan.transformer.TransformerImpl.transformNode
(TransformerImpl.java:1171)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:638)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1088)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1066)
	at com.fdgroup.xml.XSLParse$Stylesheet.doTransform(XSLParse.java:245)
	at com.fdgroup.xml.XSLParse.processXMLXSL(XSLParse.java:67)
	at com.fdgroup.xml.XSLParse.processXMLXSL(XSLParse.java:108)
	at com.fdgroup.xsservlet.CachedXSServlet.transformAndWrite
(CachedXSServlet.java:208)
	at com.fdgroup.xsservlet.XSServlet.transform(XSServlet.java:560)
	at com.fdgroup.xsservlet.XSServlet.doGetPost(XSServlet.java:495)
	at com.fdgroup.xsservlet.XSServlet.doGetPost(XSServlet.java:397)
	at com.fdgroup.xsservlet.XSServlet.doGet(XSServlet.java:347)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:260)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke
(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke
(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2396)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:643)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:172)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke
(ContainerBase.java:995)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNe
xt(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke
(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service
(CoyoteAdapter.java:223)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:405)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti
on(Http11Protocol.java:380)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:508)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:533)
	at java.lang.Thread.run(Thread.java:536)