title: Is it valid to include XSD schema definition in XML file?
body: <p>When i generate a .resx file with Visual Studio, which is an xml resource file, then the XSD schema is included in the same file. (see example) Other tools are able to interprete this file and it seems to be "valid". Nevertheless i can not find any information on <a href="http://www.w3schools.com/schema/default.asp" rel="nofollow">w3schools</a> that this is valid. Theory teaches to write an xsd file and reference it in the xml file. As well for validation normally an xsd file and an xml file is provided.</p>
  
  <p>Is it valid to define the xsd schema in the xml file like in the given example? If yes, where does it apply? To the node it is included in? If you could provide a link with more explanation, it would be as well appreciated.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;root&gt;
      &lt;xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
          &lt;xsd:element name="root" msdata:IsDataSet="true"&gt;
              &lt;xsd:complexType&gt;
                  &lt;xsd:choice maxOccurs="unbounded"&gt;
                      &lt;xsd:element name="data"&gt;
                          &lt;xsd:complexType&gt;
                              &lt;xsd:sequence&gt;
                                  &lt;xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /&gt;
                                  &lt;xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /&gt;
                              &lt;/xsd:sequence&gt;
                              &lt;xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /&gt;
                              &lt;xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /&gt;
                              &lt;xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /&gt;
                          &lt;/xsd:complexType&gt;
                      &lt;/xsd:element&gt;
                      &lt;xsd:element name="resheader"&gt;
                          &lt;xsd:complexType&gt;
                              &lt;xsd:sequence&gt;
                                  &lt;xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /&gt;
                              &lt;/xsd:sequence&gt;
                              &lt;xsd:attribute name="name" type="xsd:string" use="required" /&gt;
                          &lt;/xsd:complexType&gt;
                      &lt;/xsd:element&gt;
                  &lt;/xsd:choice&gt;
              &lt;/xsd:complexType&gt;
          &lt;/xsd:element&gt;
      &lt;/xsd:schema&gt;
      &lt;resheader name="resmimetype"&gt;
          &lt;value&gt;text/microsoft-resx&lt;/value&gt;
      &lt;/resheader&gt;
      &lt;resheader name="version"&gt;
          &lt;value&gt;1.3&lt;/value&gt;
      &lt;/resheader&gt;
      &lt;resheader name="reader"&gt;
          &lt;value&gt;System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/value&gt;
      &lt;/resheader&gt;
      &lt;resheader name="writer"&gt;
          &lt;value&gt;System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/value&gt;
      &lt;/resheader&gt;
    &lt;data name="Key"&gt;
      &lt;value&gt;Value&lt;/value&gt;
    &lt;/data&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Edit in response to adrianos comments:
  I should have reviewed the W3C website indeed. It's just a lot more difficult to read and understand... I did now, but in that short time i can not get the full picture. What i found:</p>
  
  <ul>
  <li>In the <a href="http://www.w3.org/TR/xml/" rel="nofollow">Extensible Markup Language (XML) 1.0 (Fifth Edition)</a> specification is nothing written about how to include or reference xml schema. </li>
  <li>There are three specification documents about XML Schema
  <a href="http://www.w3.org/TR/xmlschema-0/" rel="nofollow">XML Schema Part 0: Primer Second Edition</a>, <a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/" rel="nofollow">XML Schema Part 1: Structures Second Edition</a> and <a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html" rel="nofollow">XML Schema Part 2: Datatypes Second Edition</a>. In Part 0 and 2 I did not find anything related to include or reference Schema. But in Part 1 there is mentioned:
  <ul>
  <li>The schemaLocation attribute <a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#Instance_Document_Constructions" rel="nofollow">2.6 Schema-Related Markup in Documents Being Validated</a>, <a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#xsi.schemaLocation" rel="nofollow">Attribute Declaration for the 'schemaLocation' attribute</a></li>
  <li>How XML Schemes are accessed in the web <a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#composition-instances" rel="nofollow">4.3 Layer 3: Schema Document Access and Web-interoperability</a></li>
  </ul></li>
  </ul>
  
  <p>I do not see any hint yet, that including a schema should be considered as valid. It seems practical to me but it's like mixing data and definition.</p>