Subject: | Registered functions cannot return supplied arguments anymore |
The attached script implements a simple registered function which just
returns the supplied argument. This used to work with XML::LibXSLT 1.62
and earlier versions, but stopped to work with change version 1.63
(specifically, it seems that the change
svn://axkit.org/XML-LibXSLT/trunk@194 is causing the problem). Note that
the sample again works if I slightly change the supplied argument, e.g.
putting it in "..." is sufficient.
Regards,
Slaven
Subject: | 10functions2.t |
#!/usr/bin/perl
use strict;
use Test::More 'no_plan';
use XML::LibXML;
use XML::LibXSLT;
my $callbackNS = "http://x/x";
my $p = XML::LibXML->new;
my $xsltproc = XML::LibXSLT->new;
$xsltproc->register_function(
$callbackNS,
"some_function",
sub {
my($format) = @_;
# return "$format"; # works
return $format; # fails
}
);
my $xsltdoc = $p->parse_string(<<'EOF');
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://x/x"
>
<xsl:template match="root">
<root>
<xsl:value-of select="x:some_function(@format)" />
</root>
</xsl:template>
</xsl:stylesheet>
EOF
my $doc = $p->parse_string(<<EOF);
<root format="foo" />
EOF
my $stylesheet = $xsltproc->parse_stylesheet($xsltdoc);
my $result = $stylesheet->transform($doc);
is($result->findvalue("/root"), "foo")
or diag $result->serialize(1);