php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17596 Unable to reference external DTD with PHP DSO
Submitted: 2002-06-04 10:55 UTC Modified: 2002-11-06 01:00 UTC
From: william_moore at umanitoba dot ca Assigned:
Status: No Feedback Package: XSLT related
PHP Version: 4.1.2 OS: Solaris 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: william_moore at umanitoba dot ca
New email:
PHP Version: OS:

 

 [2002-06-04 10:55 UTC] william_moore at umanitoba dot ca
The problem I am having is in specifying an external DTD within an XSL file and having the PHP DSO parse it with the xslt_process function. The xslt_process seems to ignore the external DTD reference (as seen in the output from the output of the xslt_set_log function). If I was to add these entities into the XSL file rather then referring to an external DTD I would get the output I am looking for.

I do get the correct output from the same php script if I use the cgi version of PHP. Which aside from the --with-apxs directive to the configure script has the exact same options as the DSO.

Operating System: Solaris 2.6
     PHP Version: 4.1.2 (for both DSO and CGI)
  Apache Version: 1.3.9

Here is what I have for the two different configure scripts I use to build PHP

------Configure for PHP as an Apache DSO---------
  ./configure \
    --with-apxs=/www/server/apache/bin/apxs \
    --with-config-file-path=/www/server/apache/conf \
    --with-pear=/www/server/apache/php/pear \
    --enable-libgcc \
    --enable-ftp \
    --enable-dbase \
    --enable-yp \
    --enable-bcmath \
    --enable-c9x-inline \
    --enable-calendar \
    --enable-inline-optimization \
    --enable-trans-sid \
    --with-pdflib=/www \
    --with-zlib=/www \
    --with-tiff-dir=/www \
    --with-png-dir=/www \
    --with-jpeg-dir=/www \
    --with-gd=/www \
    --with-yaz=/www \
    --with-sybase=/usr/local/sybase/client \
    --with-fdftk=/www \
    --with-regex=system \
    --with-ndbm \
    --with-dom=/www \
    --with-mcrypt=/www \
    --with-mhash=/www \
    --with-expat-dir=/www \
    --enable-xslt \
    --with-xslt-sablot=/www \
    --with-iconv=/www \
    --with-ldap=/www \
    --with-imap=/www
------Configure for PHP as an Apache DSO---------

------Configure for PHP as a cgi program---------
  ./configure \
    --with-config-file-path=/www/server/apache/conf \
    --with-pear=/www/server/apache/php/pear \
    --enable-libgcc \
    --enable-ftp \
    --enable-dbase \
    --enable-yp \
    --enable-bcmath \
    --enable-c9x-inline \
    --enable-calendar \
    --enable-inline-optimization \
    --enable-trans-sid \
    --with-pdflib=/www \
    --with-zlib=/www \
    --with-tiff-dir=/www \
    --with-png-dir=/www \
    --with-jpeg-dir=/www \
    --with-gd=/www \
    --with-yaz=/www \
    --with-sybase=/usr/local/sybase/client \
    --with-fdftk=/www \
    --with-regex=system \
    --with-ndbm \
    --with-dom=/www \
    --with-mcrypt=/www \
    --with-mhash=/www \
    --with-expat-dir=/www \
    --enable-xslt \
    --with-xslt-sablot=/www \
    --with-iconv=/www \
    --with-ldap=/www \
    --with-imap=/www
------Configure for PHP as a cgi program---------

The following is what I use to perform a make after running either of the scripts above

-----make script for php-------
make clean

env LD_RUN_PATH=/www/lib make
-----make script for php-------

Below is the xml, xsl and php script I am using to produce the output

-------------test.xml-------------
<?xml version="1.0"?>
  <helloWorld>
    <hello>Hello</hello>
    <world>World</world>
  </helloWorld>
-------------test.xml-------------

-------------test.xsl-------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet SYSTEM "htmlent.dtd">

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:output method="html" indent="yes" encoding="US-ASCII"/>

  <xsl:template match="/helloWorld">
    <html>
      <head></head>
      <body bgcolor="#FFFFFF">
        <xsl:value-of select="hello"/>&nbsp;&nbsp;&nbsp;x&#160;x<xsl:value-of select="world"/><br/>
        <xsl:value-of select="hello"/>   &COPY;<xsl:value-of select="world"/><br/>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
-------------test.xsl-------------

-------snippet of htmlent.dtd--------
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY AElig "&#198;">
<!ENTITY AMP "&amp;#38;">
<!ENTITY Aacute "&#193;">
<!ENTITY Acirc "&#194;">
<!ENTITY Agrave "&#192;">
<!ENTITY Alpha "&#913;">
<!ENTITY Aring "&#197;">
<!ENTITY Atilde "&#195;">
<!ENTITY Auml "&#196;">
<!ENTITY Beta "&#914;">
<!ENTITY COPY "&#169;">
-------snippet of htmlent.dtd--------

-------------test.php-------------
<?
print parseXML("test.xml", "test.xsl");

function parseXML($xml, $xslt) {

        $objXML = xslt_create();
        xslt_set_log($objXML, true);
        xslt_set_log($objXML, "blah.log");

        $result = xslt_process($objXML, $xml, $xslt);

        if ($result) {
                $output = $result;
        }
        else {
                $output  = "Sorry, could not be transformed by xsl/$template into";
                $output .= "  the $result variable the reason is that " . xslt_error($objXML);
                $output .= " and the error code is " . xslt_errno($objXML);
        }       
        xslt_free($objXML);
        return $output;
}
?>
-------------test.php-------------

Here is the output I get when running this script

----output from the xsl log file when viewing the script via the web server---
Sablotron Message on line none, level log: Parsing 'file:/www/data/ip/bill/xsl/test.xsl'...
Sablotron Message on line none, level log: Parse done in 0.004 seconds
Sablotron Message on line none, level log: Parsing 'file:/www/data/ip/bill/xsl/test.xml'...
Sablotron Message on line none, level log: Parse done in 0.001 seconds
Sablotron Message on line none, level log: Executing stylesheet 'file:/www/data/ip/bill/xsl/test.xsl'...
Sablotron Message on line none, level log: Execution done in 0.002 seconds
----output from the xsl log file when viewing the script via the web server---

----output from test.php when viewing the script via the web server---
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  </head>
  <body bgcolor="#FFFFFF">Hello&#160;World<br>HelloWorld<br>
  </body>
</html>
----output from test.php when viewing the script via the web server---

----output from the xsl log file when using the PHP cgi program---
Sablotron Message on line none, level log: Parsing 'file:/www/data/ip/bill/xsl/test.xsl'...
Sablotron Message on line none, level log: Parsing an external entity from 'htmlent.dtd'
Sablotron Message on line none, level log: Parse done in 0.024 seconds
Sablotron Message on line none, level log: Parsing 'file:/www/data/ip/bill/xsl/test.xml'...
Sablotron Message on line none, level log: Parse done in 0.000 seconds
Sablotron Message on line none, level log: Executing stylesheet 'file:/www/data/ip/bill/xsl/test.xsl'...
Sablotron Message on line none, level log: Execution done in 0.008 seconds
----output from the xsl log file when using the PHP cgi program---

----output from test.php when using the PHP cgi program---
X-Powered-By: PHP/4.1.2
Content-type: text/html

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  </head>
  <body bgcolor="#FFFFFF">Hello&#160;&#160;&#160;&#160;World<br>Hello   &#169;World<br>
  </body>
</html>
----output from test.php when using the PHP cgi program---

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-05 07:40 UTC] msopacua at idg dot nl
Could you test:
<!DOCTYPE xsl:stylesheet SYSTEM "file:///absolute/path/to/htmlent.dtd">

I don't recall whether this was fixed in the current release - but make sure this is the bug first.

If I recall correctly moving htmlent.dtd to on of apache/libexec or apache/bin also 'fixes' the issue.
 [2002-06-05 10:27 UTC] william_moore at umanitoba dot ca
I tried specifying file:///absolute_path/htmlent.dtd as you suggested, however this did not make any difference. The PHP cgi was still able to correctly parse the XSL while the PHP DSO did not.

One thing I did notice was when I forgot to have the three slashes after file:. When I ran the script via the webserver the page was processed yet the PHP cgi had problems, specifically a Sablotron error indicating it could not find htmlent.dtd in the path I gave. It seems to me that with the PHP DSO it is ignoring the <!DOCTYPE ..> command.

Which is odd as the two should be using the same implementation of the XSLT processor right?
 [2002-06-06 06:42 UTC] msopacua at idg dot nl
It should indeed - but they are rooted differently.

Could you list your sablotron version, so I can verify if it's fixed in the current release?
 [2002-06-06 10:22 UTC] william_moore at umanitoba dot ca
The version of Sablotron I am using is 0.90, compiled via sources with the following configure script:

#!/bin/sh
env LIBRARY_PATH=/www/lib \
env CPLUS_INCLUDE_PATH=/www/include \
  ./configure \
    --prefix=/www \
    --disable-javascript
 [2002-10-03 13:24 UTC] msopacua@php.net
Does this apply with 4.3.0-dev?
 [2002-10-03 13:50 UTC] william_moore at umanitoba dot ca
I have not tried with php 4.3.0-dev we are still using 4.1.2 and have not had a chance to udgrade to 4.2.3 yet.
 [2002-10-03 14:40 UTC] msopacua@php.net
Well - 4.2.3 is the current maintenance release. If you have a testmachine available, please try it.

Also - when possible - try to rule out the DSO issue, by using a statically compiled apache.
Use --with-apache=/path_to/apache_source_tree.
Instructions are at:
http://www.php.net/manual/en/install.unix.php (example 3-4)

If the static module works (which you can also do with 4.1.2), then I would like to reclassify this as a Solaris Dynamic Loading problem.

Beware though, that you cannot 'switch' between DSO and static. You need to recompile apache both times and adjust LoadModule directives in httpd.conf.
 [2002-10-20 23:16 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-11-06 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 08:01:28 2024 UTC