Skip Menu |
 

This queue is for tickets about the XML-LibXSLT CPAN distribution.

Report information
The Basics
Id: 119710
Status: open
Priority: 0/
Queue: XML-LibXSLT

People
Owner: Nobody in particular
Requestors: abhinuke [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.94
Fixed in: (no value)



Subject: XML::LibXSLT-1.94 does not support EXSLT extensions
Download (untitled) / with headers
text/plain 3.5k
I have pretty recent Perl version installed on my OS X machine % uname -a Darwin X-maci 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64 as follows % /$path/perl -v This is perl 5, version 20, subversion 2 (v5.20.2) built for darwin-thread-multi-2level Copyright .... I also have recent version of libXSLT installed as follows % /$path/perl -MXML::LibXSLT -le 'print $XML::LibXSLT::VERSION' 1.94 and I also get % /$path/perl -MXML::LibXSLT -le 'print XML::LibXSLT::HAVE_EXSLT()' 1 Essentially, I am trying to access the EXSL extensions (`exsl:date-year(),exsl:document`) in my XSL file. I get this error message whenever I try to use the extension(s) xmlXPathCompOpEval: function year not found Unregistered function xmlXPathCompiledEval: evaluation failed runtime error: file trans.xsl line 14 element value-of XPath evaluation returned no result. at Transform.pl line 43. Is this a known problem with above OSX + Perl + libXSLT version combination ? Relevant Code: 1) Perl file use strict; use warnings; use File::Path; use File::Spec; use File::Basename; use XML::LibXSLT; use XML::LibXML; use Getopt::Std; my $isfile; my ($xmlfile,$xsltfile,$samplefile) = qw/ Example.xml trans.xsl sample.xml/; my %opts = (); getopts('o:',\%opts); my $outPath = $opts{'o'}; die "File not specified" if !defined($outPath); if(-f $samplefile) { $isfile = "true"; print "File is present\n"; } else { $isfile = "false"; print "File is absent\n"; } my %args = ( "isfile" => $isfile,"outpath" => $outPath, ); my $xslt = XML::LibXSLT->new; my $stylesheet = $xslt->parse_stylesheet_file($xsltfile); my $security = XML::LibXSLT::Security->new(); $security->register_callback( read_file => sub { return 1;} ); $security->register_callback( write_file => sub { return 1;} ); $security->register_callback( create_dir => sub { return 1;} ); $stylesheet->security_callbacks( $security ); XML::LibXSLT->register_function("urn:foo", "bar",\&invalue); my $results = $stylesheet->transform_file($xmlfile,XML::LibXSLT::xpath_to_string(%{args})); sub invalue { my $var = shift; return $var + 2; } 0; 2) XSL file <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xalan="http://xml.apache.org/xslt" xmlns:exsl="http://exslt.org/common" xmlns:date="http://exslt.org/dates-and-times" xmlns:foo="urn:foo" extension-element-prefixes="exsl date"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" media-type="text/xml"/> <xsl:param name="isfile"/> <xsl:param name="outpath"/> <xsl:variable name="current-year"> <xsl:value-of select="date:year()"/> </xsl:variable> <xsl:template match="/"> <xsl:if test="$isfile = 'true'"> <exsl:document href = "{$outpath}" method="xml" version="1.0" encoding="UTF-8" indent="yes"> Article:- <xsl:value-of select="exsl:node-set(/Article/Title)|exsl:node-set(/Article/Title)/@context"/> Authors:- <xsl:apply-templates select="/Article/Authors/Author"/> Perl function Output :- <xsl:value-of select="foo:bar(234)"/> </exsl:document> </xsl:if> </xsl:template> </xsl:stylesheet>
From: abhinuke [...] gmail.com
Some more code that I forgot to mention File : Example.xml <?xml version="1.0"?> <?xml-stylesheet type="xsl" href="trans.xsl"?> <Article> <Title context="This article">My Article</Title> <Authors> <Author>Mr. Foo</Author> <Author>Mr. Bar</Author> </Authors> <Body>This is my article text.</Body> </Article> And just create an empty file as sample.xml. Your full command to run this standalone example on the shell would be $user->% PerlVersionDir/bin/perl Transform.pl -o sample.xml This will produce the error on aforementioned OSX version and Perl + libXSLT set up. On Thu Jan 05 09:35:07 2017, abhinuke@gmail.com wrote: Show quoted text
> I have pretty recent Perl version installed on my > > OS X machine > > % uname -a > Darwin X-maci 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 > PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64 > > as follows > > % /$path/perl -v > This is perl 5, version 20, subversion 2 (v5.20.2) built for darwin- > thread-multi-2level > > Copyright .... > > I also have recent version of libXSLT installed as follows > > % /$path/perl -MXML::LibXSLT -le 'print $XML::LibXSLT::VERSION' > 1.94 > and I also get > > % /$path/perl -MXML::LibXSLT -le 'print XML::LibXSLT::HAVE_EXSLT()' > 1 > > Essentially, I am trying to access the EXSL extensions (`exsl:date- > year(),exsl:document`) in my XSL file. > > I get this error message whenever I try to use the extension(s) > > xmlXPathCompOpEval: function year not found > Unregistered function > xmlXPathCompiledEval: evaluation failed > runtime error: file trans.xsl line 14 element value-of > XPath evaluation returned no result. > at Transform.pl line 43. > > Is this a known problem with above OSX + Perl + libXSLT version > combination ? > > Relevant Code: > > 1) Perl file > > use strict; > use warnings; > use File::Path; > use File::Spec; > use File::Basename; > use XML::LibXSLT; > use XML::LibXML; > use Getopt::Std; > > my $isfile; > > my ($xmlfile,$xsltfile,$samplefile) = qw/ Example.xml trans.xsl > sample.xml/; > my %opts = (); > getopts('o:',\%opts); > > my $outPath = $opts{'o'}; > die "File not specified" if !defined($outPath); > > if(-f $samplefile) > { > $isfile = "true"; > print "File is present\n"; > } > else > { > $isfile = "false"; > print "File is absent\n"; > } > > my %args = ( "isfile" => $isfile,"outpath" => $outPath, ); > my $xslt = XML::LibXSLT->new; > my $stylesheet = $xslt->parse_stylesheet_file($xsltfile); > > my $security = XML::LibXSLT::Security->new(); > $security->register_callback( read_file => sub { return 1;} ); > $security->register_callback( write_file => sub { return 1;} ); > $security->register_callback( create_dir => sub { return 1;} ); > > $stylesheet->security_callbacks( $security ); > > XML::LibXSLT->register_function("urn:foo", "bar",\&invalue); > > my $results = $stylesheet-
> >transform_file($xmlfile,XML::LibXSLT::xpath_to_string(%{args}));
> > sub invalue > { > my $var = shift; > return $var + 2; > } > 0; > > 2) XSL file > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xalan="http://xml.apache.org/xslt" > xmlns:exsl="http://exslt.org/common" > xmlns:date="http://exslt.org/dates-and-times" > xmlns:foo="urn:foo" > extension-element-prefixes="exsl date"> > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" > media-type="text/xml"/> > > <xsl:param name="isfile"/> > <xsl:param name="outpath"/> > > <xsl:variable name="current-year"> > <xsl:value-of select="date:year()"/> > </xsl:variable> > > <xsl:template match="/"> > <xsl:if test="$isfile = 'true'"> > <exsl:document href = "{$outpath}" method="xml" version="1.0" > encoding="UTF-8" indent="yes"> > Article:- <xsl:value-of select="exsl:node- > set(/Article/Title)|exsl:node-set(/Article/Title)/@context"/> > Authors:- <xsl:apply-templates > select="/Article/Authors/Author"/> > Perl function Output :- <xsl:value-of > select="foo:bar(234)"/> > </exsl:document> > </xsl:if> > </xsl:template> > </xsl:stylesheet>
Download (untitled) / with headers
text/plain 220b
Works for me with stock Perl and libxslt under macOS 10.12.2, XML::LibXSLT 1.87. Version 1.94 is also known to work on with EXSLT macOS. How did you build XML::LibXSLT? Do you use a custom built libxslt/libexslt version?


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.