title: Xml Validation error: validating against empty schema set
body: <ol>
  <li><p>I am getting the error</p>
  
  <blockquote>
    <p>The XmlSchemaSet on the document is either null or has no schemas in it. Provide schema information before calling Validate.</p>
  </blockquote>
  
  <p>But I have the schema file located in the location specified: <code>C:\InvSchema.xsd</code></p>
  
  <p>There is no specific namespace passed, so I set that to empty. </p>
  
  <p>So, why am I getting this error?</p></li>
  <li><p>I also need to know if the xml schema was successfully validated, but the validate function does no return a boolean value confirming it.</p>
  
  <p>How can I get that value from <code>InvImp.Validate(evtHandler)</code>?</p></li>
  </ol>
  
  <p>Below is the code:</p>
  
  <pre><code> Private Function ValidateSchema() As Boolean
              Try
                  Dim settings As XmlReaderSettings = New XmlReaderSettings()
                  settings.Schemas.Add("", "C:\InvSchema.xsd")
                  settings.ValidationType = ValidationType.Schema
                  Dim evtHandler As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEventHandler)
                  Dim reader As XmlReader = XmlReader.Create(_fileName, settings)
                  Dim InvImp As XmlDocument = New XmlDocument
                  InvImp.Validate(evtHandler)              
                  ValidateSchema = True
              Catch ex As Exception
                  Throw ex
                  ValidateSchema = False
              End Try
          End Function
  
  
  Shared Sub ValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)
          Select Case e.Severity
              Case XmlSeverityType.Error
                  Library.Log("Schema validation failed error " &amp; e.Message, LogType.ERRORLOG, ImportType.InvcIMP)
              Case XmlSeverityType.Warning
                  Library.Log("Schema validation warning " &amp; e.Message, LogType.EVENTLOG, ImportType.InvcIMP)
          End Select            
      End Sub
  </code></pre>