Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

exsl in libXSLT in Perl 5.8.8 on OSX

by Recker (Initiate)
on Sep 16, 2016 at 13:28 UTC ( #1171929=perlquestion: print w/replies, xml ) Need Help??

Recker has asked for the wisdom of the Perl Monks concerning the following question:

I want to know if libXSLT in
Perl -v This is perl, v5.8.8 built for darwin-thread-multi-2level Copyright 19 +87-2006, Larry Wall....
on following OSX's build
uname -a Darwin machine-maci 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18 +:40:58 PST 2015; root:xnu3248.30.4~1/RELEASE_X86_64 x86_64
not support the exsl extensions at all. Or is it something that I am missing in my OSX's Perl-5.8.8 build which is causing it not support it?
===UPDATE===
1) I have a transformation xsl file which is as follows
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr +ansform" xmlns:xalan="http://xml.apache.org/xslt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="ye +s" media-type="text/xml"/> <xsl:param name="isfile"/> <xsl:variable name="current-year"> <xsl:value-of select="date:year()"/> </xsl:variable> <xsl:template match="/"> <xsl:when test="$isfile = 'true'"> <exsl:document href = "outputfile1.xml" method="xml" versi +on="1.0" encoding="UTF-8" indent="yes"> Article:- <xsl:value-of select="/Article/Title"/> Authors:- <xsl:apply-templates select="/Article/Author +s/Author"/> </exsl:document> </xsl:if> </xsl:template> <xsl:template match="Author"> <exsl:document href = "outputfile2.xml" method="xml" version=" +1.0" encoding="UTF-8" indent="yes"> always Generate this output!! <xsl:value-of select="." /> </exsl:document> </xsl:template> </xsl:stylesheet>
2) I have an example file which needs to transformed and output needs to generated to output1.xml and output2.xml depending on condition in the xsl file
<?xml version="1.0"?> <?xml-stylesheet type="xsl" href="trans.xsl"?> <Article> <Title>My Article</Title> <Authors> <Author>Mr. Foo</Author> <Author>Mr. Bar</Author> </Authors> <Body>This is my article text.</Body> </Article>
3) Here is the perl script that I use for transformation
#!/usr/local/bin/perl -w use strict; use warnings; use File::Path; use File::Spec; use File::Basename; use XML::LibXSLT; use XML::LibXML; my $isfile; my ($xmlfile,$xsltfile,$samplefile) = qw/ Example.xml trans.xsl sample +.xml/; if(-f $samplefile) { $isfile = "true"; print "File is present\n"; } else { $isfile = "false"; print "File is absent\n"; } my %args = ( "isfile" => $isfile ); my $xslt = XML::LibXSLT->new; my $stylesheet = $xslt->parse_stylesheet_file($xsltfile); my $results = $stylesheet->transform_file($xmlfile,XML::LibXSLT::xpath_to_string(%{a +rgs})); 0;
When the script is ran, I get following error on OS X I get the following error.
xmlXPathCompOpEval: function year not found Unregistered function xmlXPathCompiledEval: evaluation failed runtime error: file trans.xsl line 24 element value-of XPath evaluation returned no result.
However, for the same use case when executed with Perl 5.8.8 on Win7 and Debian 8.3, I am getting no errors. This (usage of outdated Perl in production environment) is something that I can not control and I am still waiting for Perl 5.2x to arrive at my workplace.

Replies are listed 'Best First'.
Re: exsl in libXSLT in Perl 5.8.8 on OSX
by Corion (Patriarch) on Sep 16, 2016 at 13:34 UTC

    What is the error message you get?

    Also note that Perl 5.8.8 was released more than ten years ago and is unsupported.

    LibXSLT never came included with Perl, so it's hard to guess whether that external dependency still supports that old version of Perl.

      I have updated my question to add simple reproducible use case with an error message.
Re: exsl in libXSLT in Perl 5.8.8 on OSX
by derby (Abbot) on Sep 16, 2016 at 17:59 UTC

    Isn't the problem in the error message?

    runtime error: file trans.xsl line 24 element value-of

    Line 24 is

    <xsl:if test="$dotransformation = true()">

    I'm not seeing dottransformation being set anywhere in the code you posted.

    -derby

    updatenever mind ... back to brushing up on my reading comprehension skills.

      I have updated the XSLT code so that it would produce the correct error message on Perl version 5.8.8 on aforementioned version of OSX.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1171929]
Approved by marto
Front-paged by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-05-21 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?