Bug #14965 Updated: Sablotron XLST encoding error
ID: 14965 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Documentation problem Operating System: Windows 2000 PHP Version: 4.1.1 New Comment: To get this to work under Win2K and PHP 4.2.0, you must put have file:// prefixed to every parameter that requires a file. This includes the xml, xsl and the output files. This does NOT however require to upgrade you php_xslt dll to the version suggested by the person in bug 14499. Previous Comments: [2002-04-26 05:23:39] [EMAIL PROTECTED] Hi, the same problem here on PWS on winodws ME, the code is ?php //create processor $my_xslt=xslt_create(); //output the processing result echo xslt_process($my_xslt,getcwd().//cd_catalog.xml,getcwd().\\cd_catalog.xsl); //free the processor xslt_free($my_xslt); ? returned Warning: sablotron error on line 1, unknown encoding... using this code the problem was completely solved... ?php //create the processor $my_xslt=xslt_create(); //process the fiel and echo the result echo xslt_process($my_xslt,file://.getcwd().//cd_catalog.xml,file://.getcwd().\\cd_catalog.xsl); //free the processor xslt_free($my_xslt); ? thank u, [2002-01-18 17:25:52] [EMAIL PROTECTED] Hi folks (please be gentle, my first post to bugs.php.net). I've got exactly the same mayhem happening on my machine too. Running with Apache 1.3.22, and php as a cgi binary. Here's the example code, commented, shows all that I've found this evening. Basically the only way I can get xslt_process() to work is using the arguments array, putting file names in with getcwd(), file://, include path just doesn't work :o( ? error_reporting (E_ALL); // My include path is // include_path = .;E:\Webserver\public_html // // PHP is installed to D:\Program Files\Php $xmlFile=Php.XPathDocumentation.xml; $xslFile=Php.XPathDocumentation.xsl; echo 'hrRead filebr'; // Get the contents of the files, // Both calls work ok. $xslData = implode('',file($xslFile)); $xmlData = implode('',file($xmlFile)); echo 'hrCreate parserbr'; $hXslt = xslt_create(); echo 'hrProcess with filenames (no path)br'; // This gives me a error: // Warning: Sablotron error on line none: cannot open file // 'd:/program files/php/Php.XPathDocumentation.xml' // in e:\cvs\php.xpath\xpath-develop\doc\Php.XPathDocumentation.php on line 79 // $result contains nothing $result = xslt_process($hXslt, $xslFile, $xmlFile); echo $result; echo 'hrGet current working directorybr'; // This returns e:\cvs\php.xpath\xpath-develop\doc echo getcwd(); echo 'hrUse getcwd() and with filenames (no path)br'; // Warning: Sablotron error on line 1: unknown encoding '' in // e:\cvs\php.xpath\xpath-develop\doc\Php.XPathDocumentation.php on line 82 // $result contains nothing $result = xslt_process($hXslt, getcwd().'\\'.$xslFile, getcwd().'\\'.$xmlFile); echo $result; echo 'hrUse file:// getcwd and with filenames (no path)br'; // This call succeeds with no error. // $result contains the entire xml file unprocessed (whitespace trimmed). $result = xslt_process($hXslt, 'file://'.getcwd().'/'.$xslFile, 'file://'.getcwd().'/'.$xmlFile); echo $result; echo 'hrUse the xml and xsl as argumentsbr'; // But this works fine and produces the transformation as I expect $arguments = array( '/_xml' = $xmlData, '/_xsl' = $xslData ); $result = xslt_process($hXslt, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); if ($result) { echo $result; } else { echo There was an error that occurred in the XSL transformation...\n; echo \tError number: . xslt_errno() . \n; echo \tError string: . xslt_error() . \n; exit; } echo 'hr'; xslt_free($hXslt); ? If you want any copies of the files that I've been using, drop me a mail. I feel fairly confident that these bugs occur regardless of the xml and xsl file, given that the final version produces exactly the expected transformed output. Nigel [2002-01-14 13:17:46] [EMAIL PROTECTED] Unless the below is a typo, it's quite logical: while (!feof ($xmlfile)) { $xml_file_contents = fgets($xmlfile, 4096); //echo $xml_file_contents; } should read: while (!feof ($xmlfile)) { /notice the dot $xml_file_contents .= fgets($xmlfile, 4096); //echo $xml_file_contents; } Unless you have an xmlfile, consisting of 1 line, smaller that 4096 bytes, $xml_file_contents, will consist of the last line only. [2002-01-14 08:21:44] [EMAIL PROTECTED] Hi, I can confrim Feddy's code works fine on Windows 2000 (thanks Freddy :), however the code I submitted earlier
Bug #14965 Updated: Sablotron XLST encoding error
ID: 14965 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Documentation problem Operating System: Windows 2000 PHP Version: 4.1.1 New Comment: Hi, the same problem here on PWS on winodws ME, the code is ?php //create processor $my_xslt=xslt_create(); //output the processing result echo xslt_process($my_xslt,getcwd().//cd_catalog.xml,getcwd().\\cd_catalog.xsl); //free the processor xslt_free($my_xslt); ? returned Warning: sablotron error on line 1, unknown encoding... using this code the problem was completely solved... ?php //create the processor $my_xslt=xslt_create(); //process the fiel and echo the result echo xslt_process($my_xslt,file://.getcwd().//cd_catalog.xml,file://.getcwd().\\cd_catalog.xsl); //free the processor xslt_free($my_xslt); ? thank u, Previous Comments: [2002-01-18 17:25:52] [EMAIL PROTECTED] Hi folks (please be gentle, my first post to bugs.php.net). I've got exactly the same mayhem happening on my machine too. Running with Apache 1.3.22, and php as a cgi binary. Here's the example code, commented, shows all that I've found this evening. Basically the only way I can get xslt_process() to work is using the arguments array, putting file names in with getcwd(), file://, include path just doesn't work :o( ? error_reporting (E_ALL); // My include path is // include_path = .;E:\Webserver\public_html // // PHP is installed to D:\Program Files\Php $xmlFile=Php.XPathDocumentation.xml; $xslFile=Php.XPathDocumentation.xsl; echo 'hrRead filebr'; // Get the contents of the files, // Both calls work ok. $xslData = implode('',file($xslFile)); $xmlData = implode('',file($xmlFile)); echo 'hrCreate parserbr'; $hXslt = xslt_create(); echo 'hrProcess with filenames (no path)br'; // This gives me a error: // Warning: Sablotron error on line none: cannot open file // 'd:/program files/php/Php.XPathDocumentation.xml' // in e:\cvs\php.xpath\xpath-develop\doc\Php.XPathDocumentation.php on line 79 // $result contains nothing $result = xslt_process($hXslt, $xslFile, $xmlFile); echo $result; echo 'hrGet current working directorybr'; // This returns e:\cvs\php.xpath\xpath-develop\doc echo getcwd(); echo 'hrUse getcwd() and with filenames (no path)br'; // Warning: Sablotron error on line 1: unknown encoding '' in // e:\cvs\php.xpath\xpath-develop\doc\Php.XPathDocumentation.php on line 82 // $result contains nothing $result = xslt_process($hXslt, getcwd().'\\'.$xslFile, getcwd().'\\'.$xmlFile); echo $result; echo 'hrUse file:// getcwd and with filenames (no path)br'; // This call succeeds with no error. // $result contains the entire xml file unprocessed (whitespace trimmed). $result = xslt_process($hXslt, 'file://'.getcwd().'/'.$xslFile, 'file://'.getcwd().'/'.$xmlFile); echo $result; echo 'hrUse the xml and xsl as argumentsbr'; // But this works fine and produces the transformation as I expect $arguments = array( '/_xml' = $xmlData, '/_xsl' = $xslData ); $result = xslt_process($hXslt, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); if ($result) { echo $result; } else { echo There was an error that occurred in the XSL transformation...\n; echo \tError number: . xslt_errno() . \n; echo \tError string: . xslt_error() . \n; exit; } echo 'hr'; xslt_free($hXslt); ? If you want any copies of the files that I've been using, drop me a mail. I feel fairly confident that these bugs occur regardless of the xml and xsl file, given that the final version produces exactly the expected transformed output. Nigel [2002-01-14 13:17:46] [EMAIL PROTECTED] Unless the below is a typo, it's quite logical: while (!feof ($xmlfile)) { $xml_file_contents = fgets($xmlfile, 4096); //echo $xml_file_contents; } should read: while (!feof ($xmlfile)) { /notice the dot $xml_file_contents .= fgets($xmlfile, 4096); //echo $xml_file_contents; } Unless you have an xmlfile, consisting of 1 line, smaller that 4096 bytes, $xml_file_contents, will consist of the last line only. [2002-01-14 08:21:44] [EMAIL PROTECTED] Hi, I can confrim Feddy's code works fine on Windows 2000 (thanks Freddy :), however the code I submitted earlier still produces the error so using either file or HTTP with fopen and using the array arguments of xslt_process function still produces the error. Andrew [2002-01-14 07:32:41] [EMAIL PROTECTED] On Windows 98, Apache 1.3.22, PHP 4.1.1, Sablotron 0.71, I experienced the same problem with 'xslt_process()', which I was able to