|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2003-07-19 15:46 UTC] el_profesorfr at yahoo dot fr
 Description:
------------
Hello,
When transforming an XML document with the DomXsltStylesheet object, references to local entities in the source XML doc do not pass through.
In the source code provided, I'm using page.xml as the source XML, sheet.xsl as the stylesheet, and transform.php as the PHP code of course.
The problem can be seen simply by issuing 'php transform.php' on the command line.
Hope I'm not missing something like an option, I'm not really an XML guru!
Environment:
- Linux SuSE 7.3
- Apache 2.0.47
- PHP 4.3.2
- libxml 2.5.8
- libxslt 1.0.31
Best regards,
Thomas
Reproduce code:
---------------
==== page.xml ====
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE old [
    <!ENTITY ccedil "ç">
]>
<old>ça marche !</old>
==== sheet.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="/">
        <new><xsl:apply-templates/></new>
    </xsl:template>
</xsl:stylesheet>
==== transform.php ====
<?
    $xml = domxml_open_file ('page.xml');
    $xsl = domxsl_xslt_stylesheet_file ('sheet.xsl');
    $out = $xsl->process ($xml, array ());
    $echo $xsl->result_dump_mem ($out);
?>
Expected result:
----------------
The output of 'php transform.php' should be:
<?xml version="1.0"?>
<new>ça marche !</new>
(ç being the UTF-8 escape sequence for ?)
That's the output of the command 'xsltproc sheet.xsl page.xml' on the same machine.
Actual result:
--------------
You only get:
<?xml version="1.0"?>
<new>a marche !</new>
The '?' got lost somewhere down on the pipe...
PHP does the same thing when running as an Apache2 module.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 23:00:01 2025 UTC | 
You need to use the undocumented flags when loading the document: $xml = domxml_open_file('page.xml',DOMXML_LOAD_SUBSTITUTE_ENTITIES);