Uploaded image for project: 'XalanC'
  1. XalanC
  2. XALANC-497

Local variables or parameters in EXSLT-functions are interpreted as global

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: CurrentCVS
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP Prof.; Xalan-C 1.9.0 (Xalan-C_1_9_0-win32-msvc_60.zip) and Xerces-C 2.6.0 (xerces-c_2_6_0-windows_nt-msvc_60.zip)

      Description

      Local variables or parameters in EXSLT-functions are interpreted as global, so we got an Error-message if we use the same parameter/variable in different functions.

      When we execute the following Stylesheet "Xalan-C_bug.xsl":

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
      xmlns:common="http://exslt.org/common"
      xmlns:math="http://exslt.org/math"
      xmlns:func="http://exslt.org/functions"
      xmlns:my="http://pfisterer.software/functions"
      exclude-result-prefixes="common math func my">
      <xsl:include href="Round.xsl"/>
      <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
      <xsl:template match="/*">
      <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
      </xsl:copy>
      </xsl:template>
      <xsl:template match="Number">
      <RoundedNumber>
      <xsl:value-of select="my:round3(.)"/>
      </RoundedNumber>
      </xsl:template>
      </xsl:stylesheet>

      witch includes the following "Round.xsl" Stylesheet:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:common="http://exslt.org/common"
      xmlns:math="http://exslt.org/math"
      xmlns:func="http://exslt.org/functions"
      xmlns:my="http://pfisterer.software/functions"
      exclude-result-prefixes="common math func my">
      <func:function name="my:round3">
      <xsl:param name="x"/>
      <xsl:variable name="result" select="round($x * 1000) div 1000"/>
      <func:result>
      <xsl:value-of select="$result"/>
      </func:result>
      </func:function>
      <func:function name="my:round6">
      <xsl:param name="x"/>
      <xsl:variable name="result" select="round($x * 1000000) div 1000000"/>
      <func:result>
      <xsl:value-of select="$result"/>
      </func:result>
      </func:function>
      </xsl:stylesheet>

      together with an xml-sourcefile with some <Number>-Elements, we got the Error:

      C:\>Xalan -o result.xml Numbers.xml Xalan-C_bug.xsl
      XSLT Error: A global variable or parameter with this name has already been declared. (file:///C:/Round.xsl, line 18, column 24.)

      The reported bug does not accur with Xalan-J 2.6.0!

        Attachments

        1. patch.txt
          0.6 kB
          David N Bertoni

          Activity

            People

            • Assignee:
              dbertoni David N Bertoni
              Reporter:
              joachim Joachim Draeger
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: