After switching to PHP 5.3.5 with lib XML V2.7.7 I no longer had problems.
There’s a thousand examples of how to validate an xml document against an xsd schema in C# around the web, but I had a hard time finding one that worked in Iron Ruby.
It seems that libxml will not automatically try to import referenced schemas, but simply skip the validation if the schemas were not explicitly imported.
In our example we tried to validate an XML file against a schema with the namespace "xttp://automotive-his.de/200706/rif" that contains a reference to the namespace "xttp://automotive-his.de/200706/rif-xhtml": which basically says that an xhtml-content element can contain any element from the rif-xhtml namespace.
The validator checks for well formedness first, meaning that your XML file must be parsable using a DOM/SAX parser, and only then does it validate your XML against the XML Schema.
The validator will report fatal errors, non-fatal errors and warnings.
In older versions of PHP5 this function might cause error messages when dealing with namespaces.
) DOMDocument against an existing XML Schema, I ran into a warning like the one below.
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'.
in on line 40New error message: DOMDocument::schema Validate() Generated Errors!
DOM obviously has some namespace problems with documents, that have been created manually (i.e. So my workaround is saving the DOMDocument temporarily, re-loading it and then validating the temporary DOMDocument.
Strangely enough the validation of the same document (= same content) now works.