|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"/> x x<xsl:value-of select="world"/><br/>
<xsl:value-of select="hello"/> ©<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 "Æ">
<!ENTITY AMP "&#38;">
<!ENTITY Aacute "Á">
<!ENTITY Acirc "Â">
<!ENTITY Agrave "À">
<!ENTITY Alpha "Α">
<!ENTITY Aring "Å">
<!ENTITY Atilde "Ã">
<!ENTITY Auml "Ä">
<!ENTITY Beta "Β">
<!ENTITY COPY "©">
-------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 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    World<br>Hello ©World<br>
</body>
</html>
----output from test.php when using the PHP cgi program---
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 17:00:01 2025 UTC |
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