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 '<hr>Read file<br>'; // Get the contents of the files, // Both calls work ok. $xslData = implode('',file($xslFile)); $xmlData = implode('',file($xmlFile)); echo '<hr>Create parser<br>'; $hXslt = xslt_create(); echo '<hr>Process 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 '<hr>Get current working directory<br>'; // This returns e:\cvs\php.xpath\xpath-develop\doc echo getcwd(); echo '<hr>Use 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 '<hr>Use 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 '<hr>Use the xml and xsl as arguments<br>'; // 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 solve using the 'file://' specifier: $result = xslt_process($xh, 'file://E:/Web/test.xml', 'file://E:/Web/test.xsl'); Strange enough, since the command: $result = xslt_process($xh, 'test.xml', 'test.xsl'); runs just fine on FreeBSD 4.4, Apache 1.3.22, PHP 4.1.1, Sablotron 0.71. On Windows however, the above command gives me error code 4: cannot open file 'd:/programs/apache/test.xsl' because Sablotron is looking for the xsl file in the Apache program directory. After specifying the full file name for the xsl file: $result = xslt_process($xh, 'test.xml', 'E:/Web/test.xsl'); I receive error code 63: unknown encoding '' After using the 'file://' prefix for the xsl file and a full file name for the xml file, I receive error code 2: XML parser error 9: junk after document element Only when using the 'file://' prefix for both the xsml and xsl file, xslt_process() seems to work fine for Windows: $result = xslt_process($xh, 'file://E:/Web/test.xml', 'file://E:/Web/test.xsl'); See also: http://archive.gingerall.cz/archives/sablot/msg01858.html HTH, Freddy Vulto ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/14965 -- Edit this bug report at http://bugs.php.net/?id=14965&edit=1