Validating OVAL XML
Been working on trying to have Sussen validate OVAL XML definition files. This should have been pretty straightforward:
public static void ValidateEventHandler (object sender, ValidationEventArgs e) { Console.WriteLine ("Bad stuff happened"); Console.WriteLine (e.Exception.Message); Console.WriteLine (e.Exception.LineNumber); Console.WriteLine ("Severity:{0}", e.Severity); } public static void Validate () { XmlTextReader reader = new XmlTextReader (filename); XmlValidatingReader vr = new XmlValidatingReader (reader); XmlSchemaCollection sc = new XmlSchemaCollection(); sc.Add ("oval", "oval-schema.xsd"); sc.Add ("redhat", "redhat-schema.xsd"); vr.Schemas.Add (sc); vr.ValidationType = ValidationType.Schema; vr.ValidationEventHandler += new ValidationEventHandler (ValidateEventHandler); Console.WriteLine ("Starting validation"); while (vr.Read()) { } Console.WriteLine ("Finished validation"); }
When I try and run this under Linux/Mono I get the following:
XmlSchema error: Referenced attribute group http://oval.mitre.org/XMLSchema/oval:subtestAttributes was not found in the corresponding schema.
Under Windows/.NET I get:
Reference to undeclared substitution group affiliation.
I’m not sure why this fails. I looked at the reference OVAL implementation source code but that offered no clues.
Back to the drawing board…