title: xmldocument and nested schemas
body: <p>Using c# and .net 3.5 I'm trying to validate an xml document against a schema that has includes.</p>
  
  <p>The schemas and there includes are as below</p>
  
  <p>Schema1.xsd  -> include another.xsd</p>
  
  <p>another.xsd -> include base.xsd</p>
  
  <p>When i try to add the Schema1.xsd to the XmlDocument i get the following error.</p>
  
  <p>Type 'YesNoType' is not declared or is not a simple type. </p>
  
  <p>I believe i'm getting this error because the base.xsd file is not being included when i load the Schema1.xsd schema.</p>
  
  <p>I'm trying to use the XmlSchemaSet class and I'm setting the XmlResolver uri to the location of the schemas.</p>
  
  <p>NOTE : All schemas live under the same directory E:\Dev\Main\XmlSchemas</p>
  
  <p>Here is the code</p>
  
  <pre><code>string schemaPath = "E:\\Dev\\Main\\XmlSchemas";
  
  XmlDocument xmlDocSchema = new XmlDocument();
  
  XmlSchemaSet s = new XmlSchemaSet();
  
  XmlUrlResolver resolver = new XmlUrlResolver();
  
  Uri baseUri = new Uri(schemaPath);
  
  resolver.ResolveUri(null, schemaPath);
  
  s.XmlResolver = resolver;
  
  s.Add(null, XmlReader.Create(new System.IO.StreamReader(schemaPath + "\\Schema1.xsd"), new XmlReaderSettings { ValidationType = ValidationType.Schema, XmlResolver = resolver }, new Uri(schemaPath).ToString()));
  
  
  xmlDocSchema.Schemas.Add(s);
  
  ValidationEventHandler valEventHandler = new ValidationEventHandler
  (ValidateNinoDobEvent);
  
  try
  {
  xmlDocSchema.LoadXml(xml);
  xmlDocSchema.Validate(valEventHandler);
  }
  catch (XmlSchemaValidationException xmlValidationError)
  {
  // need to interogate the Validation Exception, for possible further 
  // processing.
  string message = xmlValidationError.Message;
  return false;
  }
  </code></pre>
  
  <p>Can anyone point me in the right direction regarding validating an xmldocument against a schema with nested includes.</p>