Home » XML » XML_DTD » Bug #3195
White space is considered as PCDATA
Details
| Submitted | 2005-01-13 22:53 UTC |
|---|---|
| From | ylf at xung dot org |
| Assigned | ifeghali |
| Status | Closed |
| Package | XML_DTD |
| PHP Version | 4.3.4 |
| OS | Linux Debian |
| Roadmaps | (Not assigned) |
Comments
[2005-01-13 22:53 UTC] ylf at xung dot org
Description:
------------
The reference tool xmllint (http://xmlsoft.org) does not issue a single warning when validating my files, whereas XML_DTD dumps several pages of errors.
It looks like the xml parser is not correctly set up, treating white space between tags as CDATA.
xml file : http://samalyse.com/ln/0005.php
dtd file : http://samalyse.com/ln/0006.php
Reproduce code:
---------------
<?php
require 'XML/DTD/XmlValidator.php';
$validator =& new XML_DTD_XmlValidator();
echo "Performing DTD validation : ";
$test = $validator->isValid('i18n.dtd', 'i18n.xml');
if ($test) {
echo "OK\n";
} else {
exit ("FAILED : " . $validator->getMessage() . "\n");
}
?>
Expected result:
----------------
Performing DTD validation : OK
Actual result:
--------------
Performing DTD validation : FAILED :
line 22: <#PCDATA> not allowed under <translation2>
line 78: <#PCDATA> not allowed under <translation2>
line 23: <#PCDATA> not allowed under <languages>
(repeated 8 times with different line numbers)
line 24: <#PCDATA> not allowed under <lang>
(repeated 35 times with different line numbers)
line 79: <#PCDATA> not allowed under <pages>
line 140: <#PCDATA> not allowed under <pages>
line 207: <#PCDATA> not allowed under <pages>
line 80: <#PCDATA> not allowed under <page>
(repeated 6 times with different line numbers)
line 81: <#PCDATA> not allowed under <string>
(repeated 44 times with different line numbers)
line 141: <#PCDATA> not allowed under <page>
(repeated 6 times with different line numbers)
line 142: <#PCDATA> not allowed under <string>
(repeated 51 times with different line numbers)
line 208: <#PCDATA> not allowed under <page>
(repeated 172 times with different line numbers)
line 209: <#PCDATA> not allowed under <string>
(repeated 172 times with different line numbers)
[2005-01-19 15:39 UTC] cmoulin at simplerezo dot com
Having the same behaviour, i have found how to fix.
Just apply following patch into XML/DTD directory:
--- XmlValidator.php.orig Wed Jan 19 16:37:34 2005
+++ XmlValidator.php Wed Jan 19 16:37:02 2005
@@ -99,7 +99,8 @@
foreach ($node->children as $child) {
// a text node
if (!strlen($child->name)) {
- $children[] = '#PCDATA';
+ if (strlen(trim($child->content)))
+ $children[] = '#PCDATA';
} else {
$children[] = $child->name;
}
[2005-01-23 19:38 UTC] ylf at xung dot org
Downgrading XML_Tree from 2.0.0RC2 (beta) to 1.1 (stable) seems to fix this issue.
Check the following bugs :
http://pear.php.net/bugs/1575
http://pear.php.net/bugs/2457
[2005-04-20 20:22 UTC] smith at backendmedia dot com
whats the status of this bug?
[2005-04-20 20:56 UTC] ojai at nerim dot net
Well, it looks : open.
Or in a more verbose manner, it's : waiting for XML_Tree authors to decide how they want to handle whitespace. For now just downgrade XML_Tree, you'll be fine.