Validating an xml schema
After switching to PHP 5.3.5 with lib XML V2.7.7 I no longer had problems.
// parse an XML document into a DOM tree Document Builder parser = Document Builder Instance()Document Builder(); Document document = parser.parse(new File("instance.xml")); // create a Schema Factory capable of understanding WXS schemas Schema Factory factory = Schema Instance(XMLConstants.
So I wrote this:public static function validate($xml)The catch here is that the function only checks for the first error is LIBXML_ERR_FATAL, which would break XSL/XML compilation.
In my experience, the errors are returned by libxml_get_errors in descending severity, so this may be an OK thing to do.
Error 1824: Element 'child_integer': 'Error condition.' is not a valid value of the atomic type 'xs:integer'.
Strangely enough the validation of the same document (= same content) now works.
All you have to do is use a parser that has DTD validation enabled: option, which loads the DTD and weaves attribute default values into the document.
Again, no validation is performed unless explicitly requested.
lxml also provides support for ISO-Schematron, based on the pure-XSLT skeleton implementation of Schematron: There is also basic support for The parser in lxml can do on-the-fly validation of a document against a DTD or an XML schema.
The DTD is retrieved automatically based on the DOCTYPE of the parsed document.
Old error message: Warning: DOMDocument::schema Validate() [function.schema Validate]: Element 'child_integer': 'Error condition.' is not a valid value of the atomic type 'xs:integer'.