PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT
ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW
AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE
DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL
BE LOST SOMEWHERE.

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

*** shadow/3156 Fri Aug 17 09:42:48 2001
--- shadow/3156.tmp.19362       Fri Aug 17 09:42:48 2001
***************
*** 0 ****
--- 1,68 ----
+ +============================================================================+
+ | variable/parameter confusion with apply-templates                          |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 3156                        Product: XalanJ2                 |
+ |       Status: NEW                         Version: 2.2.x                   |
+ |   Resolution:                            Platform: All                     |
+ |     Severity: Critical                 OS/Version: Linux                   |
+ |     Priority: Other                     Component: org.apache.xalan.templa |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                     |
+ |  Reported By: [EMAIL PROTECTED]                                |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Below is a testcase that works fine in Xalan-J_2_1_0, but with the 2_2_D9 build,
+ you get the following error:
+ 
+ Line 24; Column 45; XSLT Error (javax.xml.transform.TransformerException):
+ Variable accessed before it is bound!
+ 
+ which is refering to the reference to the variable 'a2' even though a2 is bound
+ at the top of the template.  It seems to be caused by the apply-templates in the
+ first parameter.
+ 
+  In my real life scenerio, which I was trying to narrow down, the problem is
+ different.  Instead of getting an error, xalan assigns the same value to
+ multiple parameters that have different values, or the value of some previously
+ assigned variable.
+ 
+ 
+ 
+ XML:
+ <doc>
+   <elem1/>
+   <elem2/>
+ </doc>
+ 
+ XSL:
+ <xsl:stylesheet version="1.0"
+   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+ 
+   <xsl:output method="text" encoding="iso-8859-1"/>
+ 
+   <xsl:template match="elem1|elem2">
+      <xsl:param name="arg1"/>
+      <xsl:param name="arg2"/>
+      <xsl:value-of select="$arg1"/>
+      <xsl:value-of select="$arg2"/>
+   </xsl:template>
+ 
+   <xsl:template match="doc">
+      <xsl:variable name="a1">arg1</xsl:variable>
+      <xsl:variable name="a2">arg2</xsl:variable>
+ 
+      <xsl:apply-templates select="elem1">
+         <xsl:with-param name="arg1">
+            <xsl:apply-templates select="elem2">
+               <xsl:with-param name="arg1">arg1</xsl:with-param>
+               <xsl:with-param name="arg2">arg2</xsl:with-param>
+            </xsl:apply-templates>
+         </xsl:with-param>
+         <xsl:with-param name="arg2" select="$a2"/>
+      </xsl:apply-templates>
+   </xsl:template>
+ 
+ </xsl:stylesheet>

Reply via email to