Bug #14965 Updated: Sablotron XLST encoding error
| From: | hholzgra@php.net | Date: | Thu, 10 Jan 2002 19:21:06 +0000 |
| Subject: | Bug #14965 Updated: Sablotron XLST encoding error | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-76523@lists.php.net to get a copy of this message | ||
ID: 14965
Updated by: hholzgra
Reported By: andrew.stopford@btinternet.com
Status: Open
Bug Type: Sablotron XSL
Operating System: Windows 2000
PHP Version: 4.1.1
New Comment:
your problem is
$file_path = "http://localhost/test/";
change it to
$file_path = "$DOCUMENT_ROOT/test/";
sablot will read from local filesystem only,
while within the XML it's safe to have URLs
as pathes
Previous Comments:
------------------------------------------------------------------------
[2002-01-10 14:14:19] andrew.stopford@btinternet.com
Hi,
I tried the following code.
<?php
//path
$file_path = "http://localhost/test/";
//xml file
$xml_file = $file_path . "people.xml";
//xsl file
$xsl_file = $file_path . "people.xslt";
//open xml file
$xmlfile = fopen ($xml_file, "r");
while (!feof ($xmlfile)) {
$xml_file_contents = fgets($xmlfile, 4096);
//echo $xml_file_contents;
}
fclose ($xmlfile);
//open xslt contents
$xslfile = fopen ($xsl_file, "r");
while (!feof ($xslfile)) {
$xsl_file_contents = fgets($xslfile, 4096);
//echo $xsl_file_contents;
}
fclose ($xslfile);
$arguments = array(
'/_xml' => $xml_file_contents,
'/_xsl' => $xsl_file_contents
);
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
xslt_free($xh);
?>
The paths are correct as both files are displayed. Still the same error
message. Changed the XML file to use a local file path for the DTD with
no effect.
Andrew
------------------------------------------------------------------------
[2002-01-10 12:02:19] msopacua@idg.nl
You set the path as an http:// url.
By default, Sablotron doesn't provide an http handler, nor does the
current xslt extension.
This also applies to external entities and dtd's. Use the arg:/_xml
syntax and fetch the url's first (fopen or even better with the curl
extension)
=> Should be documentation problem as the file open method is not
specified and could be interpreted as the php fopen.
------------------------------------------------------------------------
[2002-01-10 11:21:43] hholzgra@php.net
are you sure the filenames you passed are correct?
i got the same message yesterday and the reason
was an empty stylesheet due to a missing global
declaration
(i was using variables instead of files but it
looks like the same problem -> nonexistant
xslt input)
------------------------------------------------------------------------
[2002-01-10 08:35:57] andrew.stopford@btinternet.com
Dear Sirs,
I have come across an issue with the Sablotron XSLT extension. The issue
is similar to the issue reported to http://bugs.php.net/bug.php?id=14499
however my encoding has been set.
Using Windows 2000 Server SP 2, PHP 4.1.1 and IIS 5.0 I tested the
following code.
XML
<?xml version="1.0" encoding="UTF-8"?>
<PEOPLE>
<PERSON>
<NAME>Andrew</NAME>
</PERSON>
</PEOPLE>
XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="NAME">
<span style="display:list-item; font-family:Arial">
<span style="display:list-item; font-family:Arial">
<xsl:apply-templates/>
</span>
</span>
</xsl:template>
</xsl:stylesheet>
PHP
<?
//path
$file_path = "http://localhost/";
//xml file
$xml_file = $file_path . "people.xml";
//xsl file
$xsl_file = $file_path . "people.xslt";
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
$result = xslt_process($xh, $xml_file, $xsl_file);
xslt_free($xh);
?>
From this script the following error is returned:
Warning: Sablotron error on line 1: unknown encoding '' in
c:\stuff\xlst_transform.php on line 18
line 18 is the following
$result = xslt_process($xh, $xml_file, $xsl_file);
The following adapation of the XSL file also gives the same result.
<?xml version="1.0"?>
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="NAME">
<span style="display:list-item; font-family:Arial">
<xsl:apply-templates/>
</span>
</xsl:template>
</xsl:stylesheet>
I also tested the code using Apache 1.3.22 under Windows 2000 server
with the same result.
Andrew Stopford
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14965&edit=1