title: "The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared."
body: <p><em><strong>Sometimes</em></strong>, when validating certain XML documents using an XmlValidatingReader, I receive the following error:</p>
  
  <pre><code>System.Xml.Schema.XmlSchemaValidationException: 
  "The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared."
  </code></pre>
  
  <p>The same document sometimes succeeds. I cannot figure out why.</p>
  
  <p>My XSD imports the schema like so:</p>
  
  <pre><code>&lt;xs:schema id="myschemaId"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         targetNamespace="http://mytargetnamespace.com"
         xmlns="http://mytargetnamespace.com"
         xmlns:mm="http://mytargetnamespace.com"
         elementFormDefault="qualified"&gt;
   &lt;xs:import namespace="http://www.w3.org/XML/1998/namespace" 
              schemaLocation="http://www.w3.org/2001/xml.xsd" /&gt;
   ...
  </code></pre>
  
  <p>And in the XML document I have the following attributes:</p>
  
  <pre><code>&lt;root xmlns="http://mytargetnamespace.com"        
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://mytargetnamespace.com myschema.xsd"&gt;
  </code></pre>
  
  <p>Finally, the XmlReaderSettings:</p>
  
  <pre><code>const XmlSchemaValidationFlags validationFlags =
            XmlSchemaValidationFlags.ProcessInlineSchema |
            XmlSchemaValidationFlags.ProcessSchemaLocation |  
            XmlSchemaValidationFlags.ReportValidationWarnings |
            XmlSchemaValidationFlags.AllowXmlAttributes;
  
  // Set the validation settings.
  var settings = new XmlReaderSettings
                     {
                         ValidationType = ValidationType.Schema,
                         ValidationFlags = validationFlags,
                         DtdProcessing = DtdProcessing.Parse
                     };
  settings.ValidationEventHandler += OnValidationEventHandler;
  
  // Create the XmlReader object.
  var reader = XmlReader.Create(_xmlFilePath, settings);
  
  // Parse the file. 
  while (reader.Read()) {}
  </code></pre>
  
  <p>This is a standalone exe running .NET 4.0 on Windows 2003. </p>
  
  <p>I've noticed that there's a significant pause when it's trying to validate. Could that be related? Is it trying to download the actual "xml.xsd" schema and not succeeding?</p>