#50201 [Opn->Bgs]: Error validating xml with namespace against xsd
| From: | rrichards@php.net | Date: | Tue, 17 Nov 2009 21:54:38 +0000 |
| Subject: | #50201 [Opn->Bgs]: Error validating xml with namespace against xsd | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-144728@lists.php.net to get a copy of this message | ||
ID: 50201
Updated by: rrichards@php.net
Reported By: a dot testa at wifisolution dot it
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: linux
PHP Version: 5.2.11
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
createElement is level 1 non-namespace aware method. Use level 2
createElementNS method for all elements and create them in the
urn:ietf:params:xml:ns:epp-1.0 namespace.
Previous Comments:
------------------------------------------------------------------------
[2009-11-17 11:30:48] a dot testa at wifisolution dot it
here sample code that can reproduce the problem
class DOMDocument_NIC extends DOMDocument{
public function isValid_onfile(){
$tempFile = time() . '-' . rand() . '-xmlvalidation.tmp';
$this->save($tempFile);
// Create temporary DOMDocument_NIC and re-load content from
file.
$tempDom = new DOMDocument();
$tempDom->load($tempFile);
// Delete temporary file.
if (is_file($tempFile)){
unlink($tempFile);
}
return
$tempDom->schemaValidate('hosting_epp_nic_it/epp-1.0.xsd');
}
public function isValid_onfly(){
return
$this->schemaValidate('hosting_epp_nic_it/epp-1.0.xsd');
}
}
$doc = new DOMDocument_NIC('1.0', 'UTF-8');
$doc->xmlStandalone='no';
$xml_epp =
$doc->createElementNS("urn:ietf:params:xml:ns:epp-1.0",'epp');
$doc->appendChild($xml_epp);
$xml_epp->setAttributeNS('http://www.w3.org/2000/xmlns/'
,'xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance');
$xml_epp->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance'
,'xsi:schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd');
$xml_command = $doc->createElement('command');
$xml_epp->appendChild($xml_command);
$xml_login = $doc->createElement('logout');
$xml_command->appendChild($xml_login);
$xml_cltrid = $doc->createElement('clTRID',"123456");
$xml_command->appendChild($xml_cltrid);
//$response = new DOMDocument_NIC();
//$response->loadXML($xml);
echo htmlentities($doc->saveXML())."<br />";
echo "Valido on File: ".$doc->isValid_onfile();
echo "Valido on Fly: ".$doc->isValid_onfly();
------------------------------------------------------------------------
[2009-11-17 10:11:27] rrichards@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2009-11-17 09:48:59] a dot testa at wifisolution dot it
Description:
------------
php fails to validate a xml against a xsd.
the xml is build with the DOM interface.
the function schemaValidate returns true if i load the document from a
file but not with the same document created on the fly.
as workaround i can create the document, write it on a file, load
againt and then validate.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50201&edit=1