title: Validate XML Document with xsd that has imports
body: <p>I've been trawling the internet for a good 24 hours and just can't find a resolution that works.</p>
  
  <p>I have a schema file that contains an import line:</p>
  
  <pre><code>&lt;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"/&gt;
  </code></pre>
  
  <p>Here is my code to validate the Xml:</p>
  
  <pre><code>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()) { }
  </code></pre>
  
  <p>When I run it I get: <code>The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared.</code></p>
  
  <p>If I change my code (as suggested by searches) to:</p>
  
  <pre><code>settings.ValidationType = ValidationType.DTD;
  settings.DtdProcessing = DtdProcessing.Parse;
  </code></pre>
  
  <p>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.</p>
  
  <p>I've tried adding the schema being imported directly:</p>
  
  <pre><code>settings.Schemas.Add(null, @"C:\TEMP\xmldsig-core-schema.xsd");
  </code></pre>
  
  <p>But receieve the error: <code>For security reasons DTD is prohibited in this XML document. To enable DTD processing...</code></p>
  
  <p>I've tried every combination of XmlReaderSettings settings I can think of and that have been suggested by searches.</p>
  
  <p>I'm really just proper stumped now.</p>