Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to exsl in libXSLT in Perl 5.8.8 on OSX by Recker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found