GNOME Bugzilla – Bug 562302
passing xml document from perl + exslt:node-set causes weird behavior
Last modified: 2014-02-25 15:35:11 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.
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.
Reopening. Now I can reproduce this bug.
This is a bug in XML::LibXSLT. Transferred to rt.cpan.org, RT #93349: https://rt.cpan.org/Ticket/Display.html?id=93349