In navolging van het draadje \[XML/PHP] xsd geeft problemen voor xpath query's zit ik met een volgende vraag. Ik probeer xml tegen een xsd schema te verifieren. Het is een standaard xml en een standaard xsd van de EURid voor de ontwikkeling van een epp server. De xsd kan je hier inzien. Wie kan mij hierin helpen?
Het probleem is dat deze xml wel valideert:
Maar als het wat complexer wordt (zie onderstaande xml) deze niet meer valideert
Op bovenstaande xml krijg ik onderstaande error:
Ik maak gebruik van het DomDocument object binnen PHP5. Kan deze daar niet mee omgaan? Ik vind bar weinig info over de toepassing waarvan ik gebruik wil maken.
Het probleem is dat deze xml wel valideert:
XML:
1
2
3
4
| <?xml version="1.0" encoding="UTF-8"?> <epp xmlns="http://www.eurid.eu/xml/epp/epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eurid.eu/xml/epp/epp-1.0 epp-1.0.xsd"> <hello /> </epp> |
Maar als het wat complexer wordt (zie onderstaande xml) deze niet meer valideert
XML:
1
2
3
4
5
6
7
8
9
10
11
| <?xml version="1.0" encoding="UTF-8"?> <epp xmlns="http://www.eurid.eu/xml/epp/epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eurid.eu/xml/epp/epp-1.0 epp-1.0.xsd"> <command> <info> <contact:info xmlns:contact="http://www.eurid.eu/xml/epp/contact-1.0" xsi:schemaLocation="http://www.eurid.eu/xml/epp/contact-1.0 contact-1.0.xsd"> <contact:id>c1006449</contact:id> </contact:info> </info> <clTRID>info-2222</clTRID> </command> </epp> |
Op bovenstaande xml krijg ik onderstaande error:
code:
1
| Error 1845: Element 'contact:info', [strict WC]: No matching global declaration available |
Ik maak gebruik van het DomDocument object binnen PHP5. Kan deze daar niet mee omgaan? Ik vind bar weinig info over de toepassing waarvan ik gebruik wil maken.
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| <?php $request = '<?xml version="1.0" encoding="UTF-8"?> <epp xmlns="http://www.eurid.eu/xml/epp/epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eurid.eu/xml/epp/epp-1.0 epp-1.0.xsd"> <command> <info> <contact:info xmlns:contact="http://www.eurid.eu/xml/epp/contact-1.0" xsi:schemaLocation="http://www.eurid.eu/xml/epp/contact-1.0 contact-1.0.xsd"> <contact:id>c1006449</contact:id> </contact:info> </info> <clTRID>info-2222</clTRID> </command> </epp>'; $xmlrequest = new DOMDocument('1.0', 'UTF-8'); $xmlrequest -> loadXML($request); libxml_use_internal_errors(true); if (!@$xmlrequest -> schemaValidate('epp-1.0.xsd')) { $error = libxml_display_errors(); } else { $error = null; } if ($error == null) { echo 'Parsen is geslaagd...<br /><br />'; } else { echo 'Parsen is mislukt...<br /><br />error: '. $error .'<br /><br />'; } ?> |