title: Schema validation for anyType element
body: <p>I'm trying to make use of Visual Studio's schema validation while editing some XML files.  The files contain serialized objects for <code>DataContractSerializer</code> to read.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;MyRoot xmlns="http://schemas.datacontract.org/2004/07/MyDomain"
          xmlns:lib="http://schemas.datacontract.org/2004/07/MyLibrary"
          xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;MyList xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt;
          &lt;a:anyType i:type="lib:MyObject"&gt;
              &lt;lib:Identifier&gt;my-identifier&lt;/lib:Identifier&gt;
              &lt;lib:MyProperty&gt;my-property-value&lt;/lib:MyProperty&gt;
          &lt;/a:anyType&gt;
          &lt;a:anyType i:type="lib:MyOtherObject"&gt;
              &lt;lib:Identifier&gt;my-identifier&lt;/lib:Identifier&gt;
              &lt;lib:MyOtherProperty&gt;my-other-property-value&lt;/lib:MyOtherProperty&gt;
          &lt;/a:anyType&gt;
      &lt;/MyList&gt;
  &lt;/MyRoot&gt;
  </code></pre>
  
  <p>I used the "Create Schema" menu option in Visual Studio to generate the XSD files, but the editor still shows this error for the <code>&lt;a:anyType</code> element:</p>
  
  <pre><code>This is an invalid xsi:type 'http://schemas.datacontract.org/2004/07/MyLibrary:MyObject'
  </code></pre>
  
  <p>I tried editing the XSD file for the "<a href="http://schemas.microsoft.com/2003/10/Serialization/Arrays" rel="nofollow">http://schemas.microsoft.com/2003/10/Serialization/Arrays</a>" namespace, but so far I haven't been able to eliminate the error.  Here is that XSD file as Visual Studio produces it.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;xs:import namespace="http://schemas.datacontract.org/2004/07/MyLibrary" /&gt;
      &lt;xs:element name="anyType"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/MyLibrary" ref="q1:MyProperty" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>