#46978 [Asn->Bgs]: XMLReader::setRelaxNGSchema() fails
| From: | rrichards@php.net | Date: | Wed, 31 Dec 2008 00:33:56 +0000 |
| Subject: | #46978 [Asn->Bgs]: XMLReader::setRelaxNGSchema() fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-132433@lists.php.net to get a copy of this message | ||
ID: 46978
Updated by: rrichards@php.net
Reported By: remy dot damour at laposte dot net
-Status: Assigned
+Status: Bogus
Bug Type: XML Reader
Operating System: ubuntu intrepid
PHP Version: 5.2.8
Assigned To: rrichards
New Comment:
This is expected behavior - document needs to be set prior to setting
the schema. I will however add a more descriptive error for this case.
Previous Comments:
------------------------------------------------------------------------
[2008-12-31 00:30:18] remy dot damour at laposte dot net
Rob,
Thanks for your help you're 100% right, loading data prior to setting
relax-ng schema removes the error message.
Problem now is that relax-ng validation seems to fail:
<?php
$rng_schema = <<<RNG
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="node1"><text/></element>
</start>
</grammar>
RNG;
$xml_data = <<<XML
<?xml version="1.0"?>
<node2/>
XML;
$xml_reader = new XMLReader();
$xml_reader->xml($xml_data);
$xml_reader->setRelaxNGSchemaSource($rng_schema);
$xml_reader->setParserProperty(XMLReader::VALIDATE, true);
var_dump($xml_reader->isValid());
#expected output: bool(false)
#php output: bool(true)
?>
Output when calling xmllint:
node1.xml:2: element node2: Relax-NG validity error : Expecting element
node1, got node2. node1.xml fails to validate
I've commented it here too: http://www.qc4blog.com/?p=363
Regards,
Remy
------------------------------------------------------------------------
[2008-12-30 22:19:34] remy dot damour at laposte dot net
I've described my problem here too with additional details and a quick
workaround using xmllint tool: http://www.qc4blog.com/?p=363
Regards,
Remy
------------------------------------------------------------------------
[2008-12-30 21:04:30] remy dot damour at laposte dot net
Description:
------------
Each time I call XMLReader::setRelaxNGSchema() or
XMLReader::setRelaxNGSchemaSource() it ends up with an error message.
My relax-ng content looks valid, it's succefully loaded and used for
parsing xml with both xmllint (from package libxml2-utils) and
sun-microsystem "msv" (https://msv.dev.java.net/) validator.
Reproduce code:
---------------
<?php
$rng_schema = <<<RNG
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="node1"><text/></element>
</start>
</grammar>
RNG;
$xml_reader = new XMLReader();
$xml_reader->setRelaxNGSchemaSource($rng_schema);
Expected result:
----------------
no error message
Actual result:
--------------
Warning: XMLReader::setRelaxNGSchemaSource()
[xmlreader.setrelaxngschemasource]: Unable to set schema. This must be
set prior to reading or schema contains errors. in /var/www/test.php on
line 12
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46978&edit=1