ebryant Posted April 4, 2007 Share Posted April 4, 2007 I have a series of xml files that contain named character entities (for mdashes, and other special characters). The xml file includes a small DTD containing declarations for these entities, but the structure of the xml is defined by an xml schema file (.xsd). How would I go about validating these documents in php5? If I use the schemaValidate, it appears the partial DTD causes errors. If I remove the DTD, the undeclared entities cause an error. Any suggestions? PHP script: $dom = new DomDocument; $dom->load($xmlfile); if ($dom->schemaValidate($xsdfile)) { print "$xmlfile is <font color='green'>VALID</font>.\n"; } else { print "<hr/>$xmlfile is <font color='red'>INVALID</font>.\n"; } simplified version of XML file (with DTD entity declaration): <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE case [ <!ENTITY mdash "--"> ]> <case xmlns:case="xxx"> <dockets> <docnum>05—1789<docnum> <docnum>05—1790<docnum> <docnum>05—1791<docnum> </dockets> </case> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.