#31200 [Opn->Ver]: DOMDocument->xinclude() outputs a part of the DTD
| From: | chregu@php.net | Date: | Mon, 20 Dec 2004 13:10:05 +0000 |
| Subject: | #31200 [Opn->Ver]: DOMDocument->xinclude() outputs a part of the DTD | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70689@lists.php.net to get a copy of this message | ||
ID: 31200
Updated by: chregu@php.net
Reported By: diodu at keliglia dot com
-Status: Open
+Status: Verified
Bug Type: DOM XML related
Operating System: Linux debian
PHP Version: 5.0.3
New Comment:
libxml2 does automatically resolve external entities, and I didn't find
a way to turn that off from the php side...
We have to investigate the issue, it's not only annoying, but also a
performance bottleneck
Previous Comments:
------------------------------------------------------------------------
[2004-12-20 14:03:19] diodu at keliglia dot com
Description:
------------
When trying to xinclude an XML file with an attached DTD,
DOMDocument->xinclude() outputs a part of the DTD in the result.
Deleting the Doctype line in the included file fix the problem.
Reproduce code:
---------------
<?php
// book.xml being the XML file described here:
http://livedocs.phpdoc.info/index.php?l=en&q=ref.dom#dom.examples
$xml =<<<EOD
<?xml version="1.0" ?>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Books of the other guy..</title>
<para>
<xi:include
href="book.xml#xpointer(/book/chapter/para/informaltable/tgroup/tbody/*)"
parse="xml">
<xi:fallback>
<error>xinclude: book.xml not found</error>
</xi:fallback>
</xi:include>
</para>
</chapter>
EOD;
$dom = new DOMDocument;
$dom->loadXML($xml);
$dom->xinclude();
echo $dom->saveXML();
?>
Expected result:
----------------
<?xml version="1.0"?>
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Books of the other guy..</title>
<para>
<row xml:base="/home/didou/book.xml">
<entry>The Grapes of Wrath</entry>
<entry>John Steinbeck</entry>
<entry>en</entry>
<entry>0140186409</entry>
</row><row xml:base="/home/didou/book.xml">
<entry>The Pearl</entry>
<entry>John Steinbeck</entry>
<entry>en</entry>
<entry>014017737X</entry>
</row><row xml:base="/home/didou/book.xml">
<entry>Samarcande</entry>
<entry>Amine Maalouf</entry>
<entry>fr</entry>
<entry>2253051209</entry>
</row>
</para>
</chapter>
Actual result:
--------------
<?xml version="1.0"?>
<!DOCTYPE chapter [
<!ENTITY uArr "â">
<!ENTITY hcirc "Ä¥">
<!ENTITY icirc "î">
<!ENTITY equals "=">
<!ENTITY cong "â
">
<!ENTITY icy "Ð">
// a hundred of similar lines
<!ENTITY sstarf "â">
<!ENTITY samalg "âThe Grapes of Wrath</entry>
<entry>John Steinbeck</entry>
<entry>en</entry>
<entry>0140186409</entry>
</row><row xml:base="/home/didou/book.xml">
<entry>The Pearl</entry>
<entry>John Steinbeck</entry>
<entry>en</entry>
<entry>014017737X</entry>
</row><row xml:base="/home/didou/book.xml">
<entry>Samarcande</entry>
<entry>Amine Maalouf</entry>
<entry>fr</entry>
<entry>2253051209</entry>
</row>
</para>
</chapter>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31200&edit=1