php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14499 encoding with XSLT problem
Submitted: 2001-12-13 17:52 UTC Modified: 2003-01-05 11:55 UTC
From: douglasd at iprimus dot com dot au Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.0 OS: windows 2000
Private report: No CVE-ID: None
 [2001-12-13 17:52 UTC] douglasd at iprimus dot com dot au
I got this error using XSLT in PHP-4.1.0 on Windows 2000. 

Warning: Sablotron error on line 1: unknown encoding '' in 
e:\www\htdocs\home.php on line 151 
Warning: Unknown persistent list entry type in module shutdown (11) in Unknown on line 0 

and when I add an encoding statement, 

Warning: xslt_set_encoding() is not supported in this PHP build in 
e:\www\htdocs\home.php on line 150 

My code:

$xml = $doc->dumpmem();

$arguments = array(
     '/_xml' => $xml,
);

// Allocate a new XSLT processor
$xh = xslt_create();

#xslt_set_encoding($xh, "utf-8");

// Process the document
$result = xslt_process($xh, 'arg:/_xml', $include_dir . $xslt_filename, NULL, $arguments); 

var_dump($result);

xslt_free($xh);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 11:59 UTC] sterling@php.net
In order to use utf-8 you must set the encoding from within your <?xml ?> block.. If you want to use the xslt_set_encoding() function than you must compile sablotron itself with encoding support.

not a bug.
 [2002-03-28 15:29 UTC] ax at condat dot de
i run into the same problem with the php-4.1.1/2 windows binaries. i tried to solve the problem by getting the latest sablotron binaries for windows (http://www.gingerall.com/charlie/ga/xml/d_sab.xml) - which do include encoding support - but still got the "xslt_set_encoding() is not supported in this PHP build". a look into the sources revealed the problem:

ext\xslt\sablot.c

#ifdef HAVE_SABLOT_SET_ENCODING
	PHP_FE(xslt_set_encoding,        NULL)
#else
	PHP_FALIAS(xslt_set_encoding, warn_not_available, NULL)
#endif

etc.

so i recompiled php_xslt with #define HAVE_SABLOT_SET_ENCODING - and voila - it works perfectly! (fyi: the dll is available from http://kollm.org/php_xslt/php_xslt.dll)

as windows user typically dont compile php - they get the windows binaries and expect them to work ;) - i would recommend to include the appropriate changes (sablotron dll's with encoding support; HAVE_SABLOT_SET_ENCODING defined) into the next binary release. this error is really frustrating for windows users because most of them dont have the possibility to recompile php.

thanks!
 [2002-05-02 00:19 UTC] tim at zero-interactive dot com
Same problem occurs with PHP 4.2.0 on Win2K.

Updating with the proposed dll by ax@condat.de doesn't fix it either.  Neither does setting the encoding in the xml and/or the xslt file.

Sorry Sterling, but I'd say it definitely is a bug
 [2002-06-02 16:04 UTC] k.schroeder@php.net
Same problem as #14965.

Regards, Kai
 [2002-06-27 09:41 UTC] ax at condat dot de
please note: the php_xslt.dll mentioned in my previous post only works with php-4.1.2 (or was it 4.1.1?) and the mentioned sablotron binaries (sablot.dll etc) replacing the default ones!

@ tim@zero-interactive.com: if you want xslt_set_encoding() to work on a php windows version of your choice, you have to get the mentioned sablotron binaries and recompile the php_xslt.dll with HAVE_SABLOT_SET_ENCODING set. get the php sources, open php4\ext\xslt\xslt.dsw, add "HAVE_SABLOT_SET_ENCODING" to project options > c/c++ > preprocessor definitions, and go. 

@ k.schroeder@php.net: i dont think this is the same as #14965: that one is about files not found, this one here is about HAVE_SABLOT_SET_ENCODING not compiled into the dll.

@ the php developers / windows binaries packager: again - i would highly recommend to include the
appropriate changes (sablotron dll's with encoding support;
HAVE_SABLOT_SET_ENCODING defined) into the next windows binary release. this
error is really frustrating for windows users because most of them dont
have the possibility to recompile php.
 [2003-01-05 11:19 UTC] axel_kollmorgen at hotmail dot com
this (not having xslt_set_encoding() available on windows because of HAVE_SABLOT_SET_ENCODING not defined in xslt.dsp) finally got fixed - see http://bugs.php.net/bug.php?id=20640 / http://cvs.php.net/cvs.php/php4/ext/xslt/xslt.dsp#rev1.3 . i had almost lost hope ... nice.
 [2003-01-05 11:55 UTC] derick@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-06-20 21:50 UTC] jacob at pineberry dot com dot au
After having lots and lots of problems with "encoding" error messages from Sablotron in PHP 4.2.3, in total desperation I looked back at my XSLT and XML files and started playing with them again. What I found out is as follows:

Sablotron in PHP 4.2.X looks at the <?xml version="1.0" ... ?> statement and if the statement contains any arguments, e.g. standalone="no",  it always assumes that the argument is "encoding=...", which is obviously a bug. So to make your PHP 4.2.X working with XSLT, make sure that your XML and XSLT files do not rely on the DTDs as you'd have to drop the  DOCTYPE statements as well (which need the "standalone" statement in the XML declaration).

This means that all your XML files need to be validated outside the Sablotron - but this will save you hours of work investigating silly errors of the type "unknown encoding='no'" (or something similar depending on what arguments you have included in your XML header).

This problem has now been fixed in PHP 4.3.X (at least in X >= 1).

Jacob
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 03:01:30 2024 UTC