【发布时间】:2013-11-27 12:52:18
【问题描述】:
我遇到了与No matching global declaration available for the validation root 类似的问题,但它并不能帮助我解决验证 XML 的问题。 在 php.net 的 cmets 中,我读到根元素的子元素也需要命名空间之类的。我尝试了变化,但它不能解决问题也不能改变消息。有谁知道怎么回事?
libxml Version => 2.7.6
libxml
libxml2 Version => 2.7.6
libxslt compiled against libxml Version => 2.7.6
PHP:
print_r($xml->schemaValidate('customer.xsd'));
错误:
PHP Warning: DOMDocument::schemaValidate():
Element '{http://xxx.de/ecom-customer}customerExport':
No matching global declaration available for the validation root.
XML 开头:
<?xml version="1.0" encoding="UTF-8"?>
<xxx:customerExport xmlns:xxx="http://xxx.de/ecom-customer">
<datasource>PROD</datasource>
...
XSD 部分:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xxx="http://xxx.de/ecom-customer"
targetNamespace="http://xxx.de/ecom-customer"
jxb:version="2.0">
<xsd:element name="customerExport" type="xxx:customerExport"
xmlns="xxx">
<xsd:annotation>
<xsd:appinfo>
<jxb:class name="CustomerExportRoot" />
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
【问题讨论】:
-
您没有在 XSD 中定义命名空间 xxx/ecom-customer。
-
感谢您的反馈,将调查丢失的命名空间。
标签: php xml libxml2 xsd-validation