I've downloaded the official "schema of xsd" from http://www.w3.org/2001/XMLSchema.xsd.
I saved it locally and tried to validate with this code:
var sc = XmlSchema.Read(new FileStream(@"c:\temp\xsd.xsd", FileMode.Open), validate);
sc.Compile(validate);
It failed with an exception that it cannot find some DTD.
Question number 1: Why does the schema of xsd contain definition that xml validators cannot handle?
I removed the DTD definition from the top of the file and I got this (and many more) validation errors:
"Restriction of 'anySimpleType' is not allowed."
Question number 2: Why does compiling the schema of xsd fail?
I've tried the same with XmlSchemaSet using set.Add(...) and it worked.
Question number 3: What is the difference between validating an XmlSchema and XmlSchemaSet?
I then create a dummy schema that imports the xsd schema from disk:
<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="c:\temp\xsd.xsd" />
When I add this schema to the schema set it fails again with the same errors as above.
Question number 4: Why is that different then directly adding the xsd schema (which worked)?