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 562302 - passing xml document from perl + exslt:node-set causes weird behavior
passing xml document from perl + exslt:node-set causes weird behavior
Status: RESOLVED NOTGNOME
Product: libxslt
Classification: Platform
Component: general
unspecified
Other FreeBSD
: Normal critical
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-26 05:44 UTC by Alexander Schepanovski
Modified: 2014-02-25 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alexander Schepanovski 2008-11-26 05:44:03 UTC
Perl code making trouble:

#!/usr/bin/perl

use XML::LibXML;
use XML::LibXSLT;

my $parser = new XML::LibXML;
my $xslt = new XML::LibXSLT;

# registering function
my $doc;
sub cfg {
    my $xml = q~<?xml version="1.0" encoding="utf-8"?><xml_storage></xml_storage>~;
    return $doc = $parser->parse_string($xml);
}
XML::LibXSLT->register_function("urn:perl", 'cfg', \&cfg);

# loading and parsing stylesheet
my $style_doc = $parser->parse_file("skeleton.xsl");
my $stylesheet = $xslt->parse_stylesheet($style_doc);

# performing transform
my $source = new XML::LibXML::Document;
my $results = $stylesheet->transform($source);

# writing result
open F, ">result.xml" or die;
print F $stylesheet->output_string($results);
close F;

Where skeleton.xsl is:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exslt="http://exslt.org/common"
    xmlns:perl="urn:perl"
    exclude-result-prefixes="exslt perl">

<xsl:variable name="xml_storage" select="perl:cfg()/xml_storage" />

<xsl:variable name="page-data-tree">
    <title><xsl:value-of select="$xml_storage"/></title>
    <crumbs>
        <page><url>hello</url></page>
        <page><url>bye</url></page>
    </crumbs>
</xsl:variable>
<xsl:variable name="page-data" select="exslt:node-set($page-data-tree)" />

<xsl:template match="/">
    <result><xsl:value-of select="$xml_storage"/></result>
</xsl:template>

</xsl:stylesheet>

Result is
<?xml version="1.0"?>
<result>bye</result>

It seems that value of $xml_storage varies depending on its use in diffrent part of xsl stylesheet. It also depend on its true value passed from perl.

Varying stylesheet and xml document passed from perl, you can even get segfault.
Comment 1 Nick Wellnhofer 2014-02-25 14:37:46 UTC
Works for me with libxml2 2.9.1, libxslt 1.1.28, XML::LibXML 2.0010, XML::LibXSLT 1.78. This was probably a bug in the Perl bindings.
Comment 2 Nick Wellnhofer 2014-02-25 14:47:38 UTC
Reopening. Now I can reproduce this bug.
Comment 3 Nick Wellnhofer 2014-02-25 15:35:11 UTC
This is a bug in XML::LibXSLT. Transferred to rt.cpan.org, RT #93349:

https://rt.cpan.org/Ticket/Display.html?id=93349