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 &amp; 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 &amp; 
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 &#38; b' is not an element of the set {'a &
b'}. in test.php on line 38

Warning: XMLReader::read(): Element 'user', attribute 'name': 'a &#38; 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

Reply via email to