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.