I am experiencing some strange confusion with parameters to templates. 
 Below is a testcase that works fine in Xalan-J_2_1_0, but with the 
latest build, you get the following error, which is refering to the 
reference to the variable 'a2' even though a2 is bound at the top of the 
template.  If the first parameter does not have an apply-templates in 
it, the error goes away too.

Line 24; Column 45; XSLT Error 
(javax.xml.transform.TransformerException): Variable accessed before it 
is bound!

  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