Edit report at https://bugs.php.net/bug.php?id=61587&edit=1

 ID:                 61587
 Updated by:         m...@php.net
 Reported by:        ryan dot brothers at gmail dot com
 Summary:            XMLReader - invalid schema error using ampersands
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            XML Reader
 Operating System:   Linux
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

I'm not an (lib)xml expert, but using LIBXML_NOENT as parsing options for the 
XMLReader aligns the behaviour:

$xmlreader->xml($xml, null, LIBXML_NOENT);


Previous Comments:
------------------------------------------------------------------------
[2012-03-31 22:59:01] ryan dot brothers at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=61587&edit=1

Reply via email to