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

Every few requests my script would ISE and I tracked it down to where I pass the source xslt to a new XML::XSLT object.

First some overview:
self->{xslfile} is the xslt template
self->{template} is the data that will be parsed into the template.

Both parameters are filled in before running this snippet, and the glitch was only occassional. Here we go:

print STDERR "FIRST $self->{template}\n"; my $xslt = XML::XSLT->new(Source => $self->{xslfile}); print STDERR "SECND $self->{template}\n";
Later during the $xslt->serve(Source => $self->{template}) expat would intermittently complain about malformed XML document, always on the 56th byte, no matter what I did to the content before trying to output. Always worked fine when I ran the same content as a cgi.

The fix? instead of     my $xslt = XML::XSLT->new(Source =>  $self->{xslfile}); I changed to     my $xslt = XML::XSLT->new(Source =>  ($self->{xslfile})); That is, I wrapped $self->{xslfile} in parens.

Why did this happen? The offending version of XML::XSLT is 1.25, and it did not occur in version 1.20. There are some differences in the way internal XML::XSLT variables are set up, but I can't see anything that would be doing this outright.

My perl build:

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=freebsd, osvers=4.0-current, archname=i386-freebsd uname='FreeBSD freefall.FreeBSD.org 4.0-current FreeBSD 4.0-curren +t #0: $Date$' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='undef', gccversion=2.95.2 19991024 (release) cppflags='' ccflags ='' stdchar='char', d_stdstdio=undef, usevfork=true intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-E -lperl -lm ' libpth=/usr/lib libs=-lm -lc -lcrypt libc=, so=so, useshrplib=true, libperl=libperl.so.3 Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/ +usr/lib' cccdlflags='-DPIC -fpic', lddlflags='-Wl,-E -shared -lperl -lm ' Characteristics of this binary (from libperl): Built under freebsd Compiled at May 25 2004 21:10:23 @INC: /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503

Replies are listed 'Best First'.
Re: XML::XSLT data garbling under mod_perl
by gellyfish (Monsignor) on Dec 07, 2004 at 09:27 UTC

    Firstly, 0.25 is a very old version of XML::XSLT (the first version uploaded after I took over the maintenance) - the latest CPAN version is 0.48: you probably want to try that.

    Secondly if you believe that you have a bug in the latest release of XML::XSLT then please can you send a full report including the smallest possible code that produces the behaviour you think is wrong and both XML and XSLT that you are trying to use (again the smallest working subset is best.) You should send this directly to me or, even better, to the XML::XSLT developers list at xmlxslt-devel@lists.sourceforge.net.

    /J\

      I was looking at the version in the revision comments. 0.48 is the version I am using now.

        Okay, but can you please still send the smallest possible complete code that can replicate this problem so I can build a test case and fix the problem (if problem with XML::XSLT it is.

        /J\