ID: 28207 User updated by: bart at mediawave dot nl Reported By: bart at mediawave dot nl Status: Open Bug Type: XML related Operating System: Windows 2000 PHP Version: 5.0.0RC2 New Comment:
I thought I remembered that I had similar problems with the new PHP5 DOM functions. I'm not really an expert on what I should be expecting. But it seems to work fine with the DTD. Some example code: <?php $htmlString = '<?xml version="1.0"?> <!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ <!ENTITY plainEntity "FOO entity"> <!ENTITY bar "bar"> <!ENTITY foo "foo"> <!ENTITY nbsp " "> <!ATTLIST form id ID #IMPLIED> ]> <chapter> <TITLE>Title &plainEntity;</TITLE> <para> <informaltable> <tgroup cols="3"> <tbody> <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row> <row><entry>a2</entry><entry>c2</entry></row> <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> </tbody> </tgroup> </informaltable> </para> </chapter>'; $doc = new DOMDocument(); $doc->loadXML($htmlString); echo 'publicId: ', $doc->doctype->publicId, "\n"; echo 'systemId: ', $doc->doctype->systemId, "\n"; echo 'name: ', $doc->doctype->name, "\n"; echo "entities: \n"; foreach ($doc->doctype->entities as $entity) { echo ' -', $entity->nodeName, ':', $entity->nodeValue, "\n"; } echo "notations: \n"; foreach ($doc->doctype->notations as $notation) { echo ' -', $notation->nodeName, ':', $notation->nodeValue, "\n"; } echo 'internalSubset: ', $doc->doctype->internalSubset, "\n"; echo htmlspecialchars($doc->saveXML()); ?> Previous Comments: ------------------------------------------------------------------------ [2005-02-05 15:23:20] bart at mediawave dot nl I'm afraid the latest CVS doesn't work on IIS. I get a "404 page not found" on all my php scripts now. :( Luckely it did work through the command line: The output has changed a tiny bit (for the better). But the main problem still persists. It's still not reading the DTD tags: (<!DOCTYPE...> and <!ENTITY...>) The code under "Example 3. External Entity Example" at http://www.php.net/manual/en/ref.xml.php uses a default handler: xml_set_default_handler($xml_parser, "defaultHandler"); On that same page it says: "xml_set_default_handler() : What goes not to another handler goes to the default handler. You will get things like the XML and document type declarations in the default handler." So the default handler should be printing the DTD sections of the XML documents. But they are not displayed. If I remember correctly I had the same problem with DOM. I wasn't able to access the DTD through DOM either. If you want I could look into providing a code example with DOM as well. Here's the output I got with the latest CVS: <CHAPTER> <TITLE>Title &plainEntity;</TITLE> <PARA> <INFORMALTABLE> <TGROUP COLS="3"> <TBODY> <ROW><ENTRY>a1</ENTRY><ENTRY MOREROWS="1">b1</ENTRY><ENTRY>c1</ENTRY></ROW> <ROW><ENTRY>a2</ENTRY><ENTRY>c2</ENTRY></ROW> <ROW><ENTRY>a3</ENTRY><ENTRY>b3</ENTRY><ENTRY>c3</ENTRY></ROW> </TBODY> </TGROUP> </INFORMALTABLE> </PARA> <FOO> <ELEMENT ATTRIB="value"></ELEMENT> &testEnt; This is some more PHP code being executed. </FOO> <SECTION ID="about"> <TITLE>About this Document</TITLE> <PARA> <!-- this is a comment --> Hi! This is PHP version 5.1.0-dev </PARA> </SECTION> </CHAPTER> parse complete ------------------------------------------------------------------------ [2005-02-03 01:00:08] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, 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". ------------------------------------------------------------------------ [2005-01-26 04:51:36] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2004-04-28 17:18:12] bart at mediawave dot nl Description: ------------ The stream-oriented XML parser (formerly Expat) produces different output in PHP 5 than it did in PHP 4. I'm unable to read the <?xml version='1.0'?> <!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ <!ENTITY plainEntity "FOO entity"> <!ENTITY systemEntity SYSTEM "xmltest2.xml"> ]> section of the XML document with PHP 5. Reproduce code: --------------- The code under "Example 3. External Entity Example" at http://www.php.net/manual/en/ref.xml.php Expected result: ---------------- <?xml version='1.0'?> <!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [ <!ENTITY plainEntity "FOO entity"> <!ENTITY systemEntity SYSTEM "xmltest2.xml"> ]> <CHAPTER> <TITLE>Title &plainEntity;</TITLE> <PARA> <INFORMALTABLE> <TGROUP COLS="3"> <TBODY> <ROW><ENTRY>a1</ENTRY><ENTRY MOREROWS="1">b1</ENTRY><ENTRY>c1</ENTRY></ROW> <ROW><ENTRY>a2</ENTRY><ENTRY>c2</ENTRY></ROW> <ROW><ENTRY>a3</ENTRY><ENTRY>b3</ENTRY><ENTRY>c3</ENTRY></ROW> </TBODY> </TGROUP> </INFORMALTABLE> </PARA> <?xml version="1.0"?> <!DOCTYPE foo [ <!ENTITY testEnt "test entity"> ]> <FOO> <ELEMENT ATTRIB="value"></ELEMENT> &testEnt; This is some more PHP code being executed. </FOO> <SECTION ID="about"> <TITLE>About this Document</TITLE> <PARA> <!-- this is a comment --> Hi! This is PHP version 4.3.6 </PARA> </SECTION> </CHAPTER> parse complete Actual result: -------------- &plainEntity;<CHAPTER> <TITLE>Title &plainEntity;</TITLE> <PARA> <INFORMALTABLE> <TGROUP COLS="3"> <TBODY> <ROW><ENTRY>a1</ENTRY><ENTRY MOREROWS="1">b1</ENTRY><ENTRY>c1</ENTRY></ROW> <ROW><ENTRY>a2</ENTRY><ENTRY>c2</ENTRY></ROW> <ROW><ENTRY>a3</ENTRY><ENTRY>b3</ENTRY><ENTRY>c3</ENTRY></ROW> </TBODY> </TGROUP> </INFORMALTABLE> </PARA> &systemEntity; <SECTION ID="about"> <TITLE>About this Document</TITLE> <PARA> <-- this is a comment --> Hi! This is PHP version 5.0.0RC2 </PARA> </SECTION> </CHAPTER>XML error: Undeclared entity warning at line 27 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28207&edit=1