Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-857

Variable corruption when using parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.3
    • None
    • Xalan-extensions
    • None
    • Operating System: Windows NT/2K
      Platform: PC
    • 6667

    Description

      The following XSLT code is supposed to create 2 small files and write the same
      value to both but under version 2.3.1 it writes incorrect data to one of the
      files.

      ---- XSLT (test.xsl) ----
      <?xml version="1.0"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
      xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect" extension-
      element-prefixes="redirect" >

      <xsl:variable name="a"><xsl:value-of select="//Test/@a"/>x</xsl:variable>
      <xsl:variable name="b" select="//Test/@b"/>

      <xsl:template match="/">

      <redirect:open file="1.txt"/>

      <xsl:call-template name="writeTo1"/>

      <xsl:call-template name="doNothing">
      <xsl:with-param name="dummy">
      <xsl:value-of select="$b"/>y
      </xsl:with-param>
      </xsl:call-template>

      <redirect:write file="2.txt">
      <xsl:value-of select="$a"/>
      </redirect:write>

      <redirect:close file="1.txt"/>

      </xsl:template>

      <xsl:template name="writeTo1">
      <redirect:write file="1.txt">
      <xsl:value-of select="$a"/>
      </redirect:write>
      </xsl:template>

      <xsl:template name="doNothing">
      <xsl:param name="dummy"/>
      </xsl:template>

      </xsl:stylesheet>
      ---- XML (test.xml) ----
      <?xml version="1.0"?>
      <?okt-xsl-stylesheet type="text/xsl" href="test.xsl" formatter="text"?>

      <Test a="right" b="wrong"/>
      ------------------------

      It should write the value "rightx" to both files but it writes "wrongy" to file
      1 which is the value passed to a dummy template which does nothing.

      I can't remove any of the following:

      • the dummy template
      • the writeTo1 template (if I put the code in directly instead then it works)
      • the "x" character appended to the end of veriable a
      • the "y" character appended to the end of the value passed to the dummy
        template

      This example works fine under version 2.2

      Damon

      Attachments

        Activity

          People

            Unassigned Unassigned
            dhorrell@oktobor.com Damon Horrell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: