After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 160400 - Compiles invalid XSLT; unbound variable accepted
Compiles invalid XSLT; unbound variable accepted
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
1.1.11
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2004-12-04 01:24 UTC by Frans Englich
Modified: 2006-07-14 16:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Frans Englich 2004-12-04 01:24:56 UTC
Please describe the problem:

Have a look at this stylesheet:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:template match="/">
        <xsl:call-template name="callee">
            <xsl:with-param name="variable">output</xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="callee">
        <!-- NOTE: no param element declaring $variable -->
        <xsl:value-of select="$variable" />
    </xsl:template>

</xsl:stylesheet>

The template callee references $variable, but it haven't been declared with
<param>. The specification says it is ok to pass a value with with-param and
that the callee do Not have a corresponding <param>, but I can't tell whether
$variable should be in callee's scope or not, according to the specification.
The current behavior is that the variable is in the scope; the result tree has
"output".

If it must not, I don't understand why one should declare <param>s inside a
template. If it's invalid, the stylesheet should fail to compile.

This was encountered by Bob Stayton, and the stylesheet failed to compile with
other processors, I was told. My MUA is down(bleeding edge), but I will return
with more details.


Cheers,
Frans

PS. bugzilla.gnome.org has 1.1.11 as latest version option, not 1.1.12.


Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 kbuchcik 2006-04-11 14:36:42 UTC
This is a bug.

11.6 Passing Parameters to Templates:
"It is not an error to pass a parameter x to a template that does not have an xsl:param element for x; the parameter is simply ignored."

The bugs here:
1) There's no binding for $variable in scope; this should raise an error
  already at compile-time.
2) The xsl:with-param value is ignored; xsl:with-param is used to
  *override* the value of a declared xsl:param (not of a xsl:variable);
  xsl:with-param does not declare a parameter binding.
Comment 2 kbuchcik 2006-04-11 14:43:44 UTC
There's at least one related bug in the regression tests: "tests\general\bug-41-.xsl".
The bugs in this test case (and in Libxslt):
1) xsl:with-param must not override an xsl:variable
2) xsl:with-param will only override the value of an xsl:param
  inside the called template.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
  <xsl:variable name="foo" select="'FAILURE'"/>

  <xsl:template name="test">		
    <xsl:value-of select="$foo"/>
  </xsl:template>

  <xsl:template match="/">
    <xsl:variable name="foo" select="'FAILURE'"/>
    <xsl:call-template name="test">
      <xsl:with-param name="foo" select="'SUCCESS'"/>
    </xsl:call-template>
  </xsl:template>
</xsl:stylesheet>

$ xsltproc tests/general/bug-41-.xsl tests/docs/bug-41-.xml
<?xml version="1.0"?>
SUCCESS

The correct result would be:
<?xml version="1.0"?>
FAILURE
Comment 3 kbuchcik 2006-07-14 16:24:24 UTC
Fixed in CVS HEAD.

(The regression test results still need to be fixed)