Reputation: 32260
I have a problem similiar to No matching global declaration available for the validation root but it does not help me in solving my issue with validating XML. In the comments from php.net I read that the child elements of the root element need a namespace too or something. I tried variations but it would not solve the problem nor change the message yet. Does anyone know what's wrong?
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'));
Error:
PHP Warning: DOMDocument::schemaValidate():
Element '{http://xxx.de/ecom-customer}customerExport':
No matching global declaration available for the validation root.
XML beginning:
<?xml version="1.0" encoding="UTF-8"?>
<xxx:customerExport xmlns:xxx="http://xxx.de/ecom-customer">
<datasource>PROD</datasource>
...
XSD partial:
<?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>
Upvotes: 0
Views: 765
Reputation: 25034
Your schema document should specify that you are declaring elements (and other things) for the namespace http://xxx/ecom-customer
. Use the targetNamespace
attribute on the root element.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="..."
>
...
<xs:element name="customerExport">...</xs:element>
...
</xs:schema>
As it is, your schema declares an element whose expanded name is {}customerExport
, not one whose expanded name is {http://xxx/ecom-customer}customerExport
.
Upvotes: 2