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 582091 - xsl:key not working inside free variable declaration
xsl:key not working inside free variable declaration
Status: RESOLVED OBSOLETE
Product: libxslt
Classification: Platform
Component: general
1.1.22
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2009-05-10 19:05 UTC by Georg Kapeller
Modified: 2021-07-05 11:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Georg Kapeller 2009-05-10 19:05:08 UTC
Please describe the problem:
xsl:key does not work as expected when using it in a variable declaration not in the scope of xsl:template.
Original Code is PHP5 but this does not seem to be an PHP issue.
Version Info (as stated by phpinfo())
libxslt Version: 1.1.23
libxslt compiled against libxml Version: 2.6.32
libexslt Version: 0.8.13

Should be easy to reproduce without PHP.

Steps to reproduce:
transform.php:
//normal xslt

$xsl = new DOMDocument;
$xsl->substituteEntities=true;
$xsl->load("details.xsl");

$xml = new DOMDocument;
$xml->substituteEntities=true;
$xml->load("data.xml");

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
$proc->transformToXML($xml);



data.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" ?>
<page>
    <formValues>
        <value name="detailModeChange">eval</value>
    </formValues>
</page>



transform.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="iso-8859-1"/>

<xsl:key name="formValuesName" match="/page/formValues/value" use="@name"/>

<xsl:variable name="changeMode1">
    <xsl:value-of select="/page/formValues/value[@name = 'detailModeChange']" />
</xsl:variable>

<xsl:variable name="changeMode2">
    <xsl:value-of select="key('formValuesName', 'detailModeChange')" />
</xsl:variable>

<xsl:template match="/">
    <xsl:message terminate="yes">
        <xsl:text>Key in Template: </xsl:text>
        <xsl:value-of select="key('formValuesName', 'detailModeChange')" />
        <xsl:text> -- raw XPATH in variable: </xsl:text>
        <xsl:value-of select="$changeMode1" />
        <xsl:text> -- key in variable: </xsl:text>
        <xsl:value-of select="$changeMode2" />
    </xsl:message>
</xsl:template>

</xsl:stylesheet>


Actual results:
Key in Template: eval -- raw XPATH in variable: eval -- key in variable: 

Expected results:
Key in Template: eval -- raw XPATH in variable: eval -- key in variable: eval

Does this happen every time?
yes

Other information:
Comment 1 GNOME Infrastructure Team 2021-07-05 11:01:20 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxslt/-/issues/

Thank you for your understanding and your help.