title: Invalid XML comes out as valid
body: <p>I have made an XML schema to validate incoming xml files to validate if they are an Error or not.
  I have some code that should return true when an xml file is valid, or false when it's not.
  I have also made two XML files, one of which is valid, the other invalid. However, my code returns true for both of them, aka considers them both valid. How come? Where did I go wrong?  </p>
  
  <p>The schema:<br>
  <strong>XMLSchemaError.xsd</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="XMLSchemaError"
      targetNamespace="http://tempuri.org/XMLSchemaError.xsd"
      elementFormDefault="qualified"
      xmlns="http://tempuri.org/XMLSchemaError.xsd"
      xmlns:mstns="http://tempuri.org/XMLSchemaError.xsd"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
  &gt;
    &lt;xs:element name="Error"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="Server_ID" type="xs:integer" /&gt;
          &lt;xs:element name="Prioritizing" type="xs:token" /&gt;
          &lt;xs:element name="Type" type="xs:token" /&gt;
          &lt;xs:element name="Thrown_by" type="xs:token" /&gt;
          &lt;xs:element name="Code" type="xs:string" /&gt;
          &lt;xs:element name="Text" type="xs:string" /&gt;
          &lt;xs:element name="Time_occured" type="xs:dateTime" /&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Code to validate the XML file:<br>
  <strong>XMLValidation.cs</strong></p>
  
  <pre><code>private bool isValid = false;       
  
  public bool checkValid(string fileName)
  {
      try
      {
          var reader = XmlReader.Create("../../XMLFiles/" + fileName);
          XmlDocument doc = new XmlDocument();
          doc.PreserveWhitespace = true;
          doc.Load(reader);
          doc.Schemas.Add(null, "../../Model/XMLSchemaError.xsd");
          doc.Validate(ValidationCallBack);
          isValid = true;
      }
      catch
      {
          isValid = false;
      }            
      System.Diagnostics.Debug.WriteLine("Check: " + isValid);
      return isValid;
  }
  
  private void ValidationCallBack(object sender, ValidationEventArgs e)
  {
      throw new Exception();
  }
  </code></pre>
  
  <p>The 2 XML files to validate:<br>
  <strong>Valid.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Error&gt;
      &lt;Server_ID&gt;4&lt;/Server_ID&gt;
      &lt;Prioritizing&gt;major&lt;/Prioritizing&gt;
      &lt;Type&gt;test error&lt;/Type&gt;
      &lt;Thrown_by&gt;test program&lt;/Thrown_by&gt;
      &lt;Code&gt;&lt;/Code&gt;
      &lt;Text&gt;&lt;/Text&gt;
      &lt;Time_occurred&gt;2016-02-9T12:34:56.7890&lt;/Time_occurred&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p><strong>Invalid.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;note&gt;
    &lt;to&gt;Tove&lt;/to&gt;
    &lt;from&gt;Jani&lt;/from&gt;
    &lt;heading&gt;Reminder&lt;/heading&gt;
    &lt;body&gt;Don't forget me this weekend!&lt;/body&gt;
  &lt;/note&gt;
  </code></pre>