I've been trawling the internet for a good 24 hours and just can't find a resolution that works.
I have a schema file that contains an import line:
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation=
"http://www.w3.org/TR/2001/PR-xmldsig-core-20010820/xmldsig-core-schema.xsd"/>
Here is my code to validate the Xml:
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null, @"C:\TEMP\myschema.xsd");
XmlReader xmlReader = XmlReader.Create(new StringReader(document.InnerXml), settings);
while (xmlReader.Read()) { }
When I run it I get: The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared.
If I change my code (as suggested by searches) to:
settings.ValidationType = ValidationType.DTD;
settings.DtdProcessing = DtdProcessing.Parse;
Then I receive no error but the validation doesn't work as there is I have deliberately inserted an invalid value to test that the validation is working.
I've tried adding the schema being imported directly:
settings.Schemas.Add(null, @"C:\TEMP\xmldsig-core-schema.xsd");
But receieve the error: For security reasons DTD is prohibited in this XML document. To enable DTD processing...
I've tried every combination of XmlReaderSettings settings I can think of and that have been suggested by searches.
I'm really just proper stumped now.