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=5609>.
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=5609

Global Variable Initialization across Multiple Transformations

           Summary: Global Variable Initialization across Multiple
                    Transformations
           Product: XalanJ2
           Version: 2.2.x
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Xalan
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When using a single Transformer object to transform multiple XML documents, if 
the XSLT contains a global <xsl:variable> declaration, the variable will be 
assigned a value from the first transformation that occurs. This value will 
then be applied to all subsequent transformations even though the value 
initially assigned the variable was from a separate XML document.

The following is a simple example:


Stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        
  <xsl:variable name="regionNumber" 
select="/Adjustments/PageData/HiddenForm/Region"/>
        
  <xsl:template match="/">
    <html>
      <body>
      Hello <xsl:value-of select="$regionNumber"/> World
      </body>
    </html>
  </xsl:template>
        
</xsl:stylesheet>

XML Documents:

Document 1:

<?xml version="1.0" encoding="UTF-8"?>
<Adjustments>
  <PageData>
    <HiddenForm>
      <Region>9115</Region>
    </HiddenForm>
  </PageData>
</Adjustments>

Document 2:

<?xml version="1.0" encoding="UTF-8"?>
<Adjustments>
  <PageData>
    <HiddenForm>
      <Region>9111</Region>
    </HiddenForm>
  </PageData>
</Adjustments>


If a Transformer is used to transform Document 1 and then Document 2, the 
resulting files would BOTH contain

Hello 9115 World

If transforming Document 2 then Document 1, the resulting files would both
contain

Hello 9111 World

I encountered this with version 2_2_D10 and verified it with version 2_2_D14.

Reply via email to