Unable to validate XML with Schema if namespace is specified.
| From: | Dusty Bin | Date: | Sun, 31 Oct 2004 19:08:04 +0000 |
| Subject: | Unable to validate XML with Schema if namespace is specified. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-200772@lists.php.net to get a copy of this message | ||
I am trying to validate an XML document, using DomDocument::schemaValidate() as in the following code:
<?php
$txt =<<<EOT
<?xml version="1.0"?>
<Article xmlns='http://www.example.com/xml'>
<Item>ItemText</Item>
</Article>
EOT;
$dom = new DOMDocument();
$dom->loadXML($txt);
if ($dom->schemaValidate("Article.xsd")) {
print $dom->saveXML();
}
?>
The schema I am trying to validate against is:
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="Article">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This produces the following output:
Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10
Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10
If I remove the default namespace from the article tag, the XML validates correctly. I seem to recollect that namespace support is not fully implemented, so my question is, is this a bug, or just something not yet implemented, or is there an obvious blunder in what I am trying to do, which I cannot see.
Best regards. . . Dusty