ID:               31200
 Updated by:       [EMAIL PROTECTED]
 Reported By:      diodu at keliglia dot com
-Status:           Verified
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Linux debian
 PHP Version:      5.0.3
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is libxml behavior. DTD only output - it gets created for existing
Document if one doesnt exists - only if Entities are defined as they may
be required for the included Document. As a workaround in PHP 5.1 you
can use:
$dom->xinclude(LIBXML_NONET);

This will prevent remote files (i.e. DTD) from being loaded which will
reduce performance bottleneck, but it will still load local DTDs. Note
that not including the DTD may break the xml if any entity definitions
are required in the resulting document.


Previous Comments:
------------------------------------------------------------------------

[2004-12-20 14:10:04] [EMAIL PROTECTED]

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



------------------------------------------------------------------------

[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

Reply via email to