Bug #61587 [NEW]: XMLReader - invalid schema error using ampersands
| From: | ryan dot brothers at gmail dot com | Date: | Sat, 31 Mar 2012 22:59:01 +0000 |
| Subject: | Bug #61587 [NEW]: XMLReader - invalid schema error using ampersands | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-169109@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.3.10
Package: XML Reader
Bug Type: Bug
Bug description:XMLReader - invalid schema error using ampersands
Description:
------------
In the following test script, the example xml is valid against the supplied
schema. DOMDocument displays no schema errors as expected, but XMLReader
displays a schema violation. I was expecting XMLReader to not report any
schema violations.
Test script:
---------------
<?php
error_reporting(E_ALL);
$xml = '<user name="a & b"/>';
$schema = '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="user">
<xs:complexType>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="a & b"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>';
// create temp file with schema
$schema_file = tempnam(sys_get_temp_dir(), '');
file_put_contents($schema_file, $schema);
// test with DOMDocument
$dom = new DOMDocument;
$dom->loadXML($xml);
$dom->schemaValidate($schema_file);
// test with XMLReader
$xmlreader = new XMLReader;
$xmlreader->xml($xml);
$xmlreader->setSchema($schema_file);
while ($xmlreader->read() == true);
$xmlreader->close();
// delete temp file
unlink($schema_file);
Expected result:
----------------
No output
Actual result:
--------------
Warning: XMLReader::read(): Element 'user', attribute 'name': [facet
'enumeration'] The value 'a & b' is not an element of the set {'a
&
b'}. in test.php on line 38
Warning: XMLReader::read(): Element 'user', attribute 'name': 'a &
b'
is not a valid value of the local atomic type. in test.php on line 38
--
Edit bug report at https://bugs.php.net/bug.php?id=61587&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61587&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61587&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61587&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=61587&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61587&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=61587&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=61587&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=61587&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=61587&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=61587&r=support
Expected behavior: https://bugs.php.net/fix.php?id=61587&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=61587&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=61587&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=61587&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61587&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61587&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=61587&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=61587&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=61587&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=61587&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=61587&r=mysqlcfg