#41041 [NEW]: Relax NG validation fails with DTD defined entities
| From: | bleathem at gmail dot com | Date: | Tue, 10 Apr 2007 15:50:45 +0000 |
| Subject: | #41041 [NEW]: Relax NG validation fails with DTD defined entities | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-111300@lists.php.net to get a copy of this message | ||
From: bleathem at gmail dot com
Operating system: Max OS/X 10.4.9
PHP version: 5.2.1
PHP Bug Type: DOM XML related
Bug description: Relax NG validation fails with DTD defined entities
Description:
------------
I've created a xml file that uses a doctype to define html entities. I've
created an accompanying Relax NG file to validate the file. If the xml
element that contains the entity follows an Relax NG <interleave> block,
the validation fails. I have demonstrated this in the accompanying source
code. The variable $xml is validated against two Relax NG schemas, where
the preceding elements are contained in an <interleave> block, and one
where the are not. The validation fails in the <interleave> case.
I have tried the validation using an online validator (java based, uses
jing), see:
http://hsivonen.iki.fi/validator/
so it is not the XML or the Relax NG, but rather the validator itself.
I have found other circumstances where the presence entities cause the
validation to fail, I can provided these if they are necessary.
Reproduce code:
---------------
<?php
$xml = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root[
<!ENTITY mu "mu">
]>
<eec:field xmlns:eec="http://www.triumf.info/common/xml/eec"
xmlns="http://www.w3.org/1999/xhtml">
<eec:title>Isotope</eec:title>
<eec:name>sec_isotope</eec:name>
<eec:type>text</eec:type>
<eec:value>μ</eec:value>
</eec:field>
EOF;
$rng = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:eec="http://www.triumf.info/common/xml/eec">
<start>
<element name="eec:field">
<interleave>
<element name="eec:title"><text/></element>
<element name="eec:name"><text/></element>
<element name="eec:type"><text/></element>
</interleave>
<element name="eec:value"><text/></element>
</element>
</start>
</grammar>
EOF;
$rng2 = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:eec="http://www.triumf.info/common/xml/eec">
<start>
<element name="eec:field">
<element name="eec:title"><text/></element>
<element name="eec:name"><text/></element>
<element name="eec:type"><text/></element>
<element name="eec:value"><text/></element>
</element>
</start>
</grammar>
EOF;
ini_set( 'track_errors', 1);
ini_set('error_reporting', E_ALL | E_STRICT);
$dom = new DOMDocument();
$dom->loadXML($xml, LIBXML_DTDLOAD|LIBXML_DTDATTR);
echo "<h3>1st Time</h3>";
if ($dom->relaxNGValidateSource($rng)) echo "Relax NG validated";
else echo $php_errormsg;
echo "<h3>2nd Time</h3>";
if ($dom->relaxNGValidateSource($rng2)) echo "Relax NG validated";
else echo $php_errormsg;
?>
Expected result:
----------------
1st Time
Relax NG validated
2nd Time
Relax NG validated
Actual result:
--------------
1st Time
Element value has extra content: mu
2nd Time
Relax NG validated
--
Edit bug report at http://bugs.php.net/?id=41041&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41041&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41041&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41041&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41041&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41041&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41041&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41041&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41041&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41041&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41041&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41041&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41041&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41041&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41041&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41041&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41041&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41041&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41041&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41041&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41041&r=mysqlcfg