5

I have a set of XSLT stylesheets that were working fine previously. Recently, a fellow developer upgraded our Perl to a newer version. Ever since that time, we have been getting intermittent stylesheet compilation errors where EXSLT functions are defined.

Here is an example of the error:

element param only allowed within a template, variable or param

The variable is defined within the EXSLT function. Once the error is received, I will get the error every time that I try to access my web page until I restart Apache (used in conjunction with mod_perl). After restarting, I can get the web page calling XML::LibXSLT and the EXSLT function to display properly once, but reloading the page will trigger the error again.

After reading the XML::LibXSLT docs, I have confirmed that the HAVE_EXSLT() function returns a value of 1. My current version of XML::LibXSLT is 1.79. My LibXSLT DLL is 1.1.28. My perl version is 5.14.3. The previous versions that worked were 5.8.8, 1.66, and 1.1.22, respectively.

Why am I now seeing these errors when I previously did not? Below is the beginning snippet from the stylesheet that is throwing compilation errors. Please let me know if there is any additional information that would be useful to provide.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/common"
                xmlns:func="http://exslt.org/functions"
                xmlns:dtbl="http://docbook.sourceforge.net/dtbl"
                extension-element-prefixes="func"
                exclude-result-prefixes="exsl func dtbl"
                version="1.0">

<func:function name="dtbl:convertLength">
  <xsl:param name="arbitrary.length"/>

Additional findings:

After my initial posting of this question, I discovered that I cannot reproduce the error at all if I use plain old CGI instead of mod_perl. Additionally, I found the following line in my Apache httpd.conf. When commenting it out, I saw that the frequency of the error occurrence dropped dramatically, although it did not completely remove the error.

PerlModule XML::LibXSLT;
Scott
  • 1,223
  • 2
  • 16
  • 35
  • 3
    To me, this kind of random-seeming error suggests you're using a threaded MPM with a module that isn't thread safe. You might want to consider using a FastCGI approach such as `mod_fcgid` instead of `mod_perl`, to get the reduced overhead of long lived processes without the threading issues. – Ian Roberts Nov 26 '13 at 16:07
  • The problem with ``mod_fcgid`` is that you need to write your code from, pretty much scratch, if you want to use it, while mod_perl (with its problems), allows you to use your existing code minus some changes related to concurrency – Noam Rathaus Nov 26 '13 at 17:57

1 Answers1

1

From experience mod_perl does a lot of funny things for example JSON::XS works terrible under mod_perl and causes a serious memory leak + stuck process, so I moved to JSON::Tiny which is a native and simple code - which mod_perl can handle

I have a feeling that XML::LibXSLT has the same issue, I migrated my code from XML::LibXSLT to using native xsltproc for this reason, yes it requires spawning, but if you do it right, the overhead isn't worse that what you are doing now, and it is more stable

So my suggestion is to either move from XML::LibXSLT to xsltproc (binary) which I use under mod_perl without issues, or to find some other library to do the XSLT conversion for you (maybe FOP ? )

Noam Rathaus
  • 5,405
  • 2
  • 28
  • 37