php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8928 xslt_process randomly fails on valid xml/xsl data (xslt_run works fine)
Submitted: 2001-01-26 02:04 UTC Modified: 2001-02-14 06:22 UTC
From: abravo at tanja dot spb dot ru Assigned:
Status: Closed Package: Sablotron XSL
PHP Version: 4.0.4pl1 OS: Linux (kernel 2.2.10,glibc-2.0.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: abravo at tanja dot spb dot ru
New email:
PHP Version: OS:

 

 [2001-01-26 02:04 UTC] abravo at tanja dot spb dot ru
This script randomly fails (on the same xml/xsl data it works or randomly fails with the only error:
    Fatal error: msgtype: error in /home/httpd/html/photo/tstxsl1.php on line 29  
, which is xslt_process call.
I can't set the user error handler while using xslt_process to get more error information, because can't pass $parser to this function.)  :


<?php
function xsl_error($parser, $code, $level, $errors)
{
        echo "Parser: $parser\n<br>\n";
        echo "Code:   $code\n<br>\n";
        echo "Level:  $level\n<br>\n";
        echo "Errors: \n<br>\n<br>\n";
        var_dump($errors);
}

$fp = fopen("pic1.xsl", "r");
$lenxsl = filesize("pic1.xsl");
$xslData = fread($fp, $lenxsl);
fclose($fp);

$fp = fopen("pic.xml", "r");
$lenxml = filesize("pic.xml");
$xmlData = fread($fp, $lenxml);
fclose($fp);

/* 
  Parser creation could be omitted, it doesn't influence on the random crashes 
*/
$parser = xslt_create();
print "Parser Handle[$parser]<br>";
xslt_set_error_handler($parser, "xsl_error");

if (xslt_process($xslData, $xmlData, $result))
{
      echo $result;
} else {
      echo "\tError number: " . xslt_errno() . "\n";
      echo "\tError string: " . xslt_error() . "\n";
      exit;
}

/* this should be omitted if xsl_creat() is commented out */
xslt_free($parser);
?>

Sablotron comand line utility sabcmd parses xml/xsl data from the files pic1.xsl and pic.xml without any errors/warnings.
The following script, which doesn't use xslt_process, works stable and without errors on the same data files:

<?php
function xsl_error($parser, $code, $level, $errors)
{
        echo "Parser: $parser\n<br>\n";
        echo "Code:   $code\n<br>\n";
        echo "Level:  $level\n<br>\n";
        echo "Errors: \n<br>\n<br>\n";
        var_dump($errors);
}

$parser = xslt_create();
print "Parser Handle[$parser]<br>";

xslt_set_error_handler($parser, "xsl_error");

xslt_run($parser, './pic1.xsl', './pic.xml');
print "<br>Here is the output:<br>".xslt_fetch_result($parser);
xslt_free($parser);
?>

But I need at least xml "in-memory" data for my application, so I can't use xslt_run for my production purposes.
Suggestion - something wrong with xslt_process :)

php.ini - standard configuration from php4.04pl1 distribution
Sablotron 0.50
Expat 1.95.1
php4 configuration:
--with-apxs --prefix=/usr --with-gd --with-gettext --with-yp --with-system-regex --with-mysql=/usr --enable-safe-mode --enable-sysvsem --enable-sysvshm --with-exec-dir=/home/httpd/php/bin --with-zlib --with-config-file-path=/etc/httpd --disable-debug --enable-magic-quotes --enable-bcmath --with-mod_charset --with-pdflib --with-cpdflib --enable-calendar --with-sablot
configure script was hacked a little to provide libexpat and libiconv (glibc-2.0.7 has no native iconv) for Sablotron
instead of old libxmlparse and libxmltok. There were no any problem with compilation of php4.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-13 01:58 UTC] abravo at tanja dot spb dot ru
It's probably just enough to remove <?xml version="1.0" encoding="utf-8"?> from XSL data to make it
working stable. Is it bug or feature ?
 [2001-02-14 06:22 UTC] sterling@php.net
you can have an xslt_error function without the parser, just omit the parser argument and it will be the global error handler.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jul 05 13:01:29 2020 UTC