title: How to remove error in xsd while referencing xml : No declaration found elelement 'CAS'
body: <p>I have an XML that is associated with some XSD. I have included all of the elements in the XML inside the XSD, including Root element. While validating the XML from this XSD, it's saying that CAS (which's the root element) is missing.</p>
  
  <p>Anybody have an idea on how to solve this problem?</p>
  
  <p><strong>XML:</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;CAS xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="CASNamespace ..\..\CAS_backup.xsd"&gt;
      &lt;name&gt;CAS SD&lt;/name&gt;
      &lt;casBaseURL&gt;www.sws.bfh.ch/studium/vorlesungen/&lt;/casBaseURL&gt;
      &lt;course id="C-jav"&gt;
      &lt;name&gt;Java&lt;/name&gt;
      &lt;teacher ref="T-joh"/&gt;
      &lt;lessons&gt;40&lt;/lessons&gt;
      &lt;language&gt;de&lt;/language&gt;
      &lt;language&gt;en&lt;/language&gt;
      &lt;url&gt;sd-java.xhtml&lt;/url&gt;
      &lt;weight&gt;1.8&lt;/weight&gt;
      &lt;/course&gt;
  
      &lt;course id="C-xml"&gt;
      &lt;name&gt;XML Technologien&lt;/name&gt;
      &lt;teacher ref="T-exe"/&gt;
      &lt;lessons&gt;24&lt;/lessons&gt;
      &lt;project&gt;8&lt;/project&gt;
      &lt;language&gt;de&lt;/language&gt;
      &lt;language&gt;en&lt;/language&gt;
      &lt;url&gt;sd-xml.xhtml&lt;/url&gt;
      &lt;weight&gt;1.6&lt;/weight&gt;
      &lt;/course&gt;
  
      &lt;course id="C-rdb"&gt;
      &lt;name&gt;Relationale Datenbanken&lt;/name&gt;
      &lt;teacher ref="T-bas"/&gt;
      &lt;lessons&gt;24&lt;/lessons&gt;
      &lt;project&gt;8&lt;/project&gt;
      &lt;language&gt;de&lt;/language&gt;
      &lt;language&gt;en&lt;/language&gt;
      &lt;language&gt;fr&lt;/language&gt;
      &lt;url&gt;sd-rdb.xhtml&lt;/url&gt;
      &lt;weight&gt;1.6&lt;/weight&gt;
      &lt;/course&gt;
  
     &lt;course id="C-da"&gt;
     &lt;name&gt;Datenstrukturen und Algorithmen&lt;/name&gt;
     &lt;teacher ref="T-rit"/&gt;
     &lt;lessons&gt;48&lt;/lessons&gt;
     &lt;language&gt;de&lt;/language&gt;
     &lt;language&gt;en&lt;/language&gt;
     &lt;url&gt;sd-algodata.xhtml&lt;/url&gt;
     &lt;weight&gt;1.8&lt;/weight&gt;
     &lt;/course&gt;
  
     &lt;course id="C-gui"&gt;
     &lt;name&gt;GUI/Ergonomie&lt;/name&gt;
     &lt;teacher ref="T-joh"/&gt;
     &lt;teacher ref="T-nom"/&gt;
     &lt;lessons&gt;24&lt;/lessons&gt;
     &lt;project&gt;16&lt;/project&gt;
     &lt;language&gt;de&lt;/language&gt;
     &lt;language&gt;en&lt;/language&gt;
     &lt;url&gt;sd-gui.xhtml&lt;/url&gt;
     &lt;weight&gt;1.6&lt;/weight&gt;
     &lt;/course&gt;
  
     &lt;student id="P-001"&gt;
         &lt;name&gt;
             &lt;firstName&gt;Roberto&lt;/firstName&gt;
             &lt;lastName&gt;Campione&lt;/lastName&gt;
         &lt;/name&gt;
         &lt;dateOfBirth&gt;1970-12-12&lt;/dateOfBirth&gt;
         &lt;address&gt;
             &lt;street&gt;
                 &lt;name&gt;Bahnhofstrasse&lt;/name&gt;
                 &lt;number&gt;12&lt;/number&gt;
                 &lt;addition&gt;a&lt;/addition&gt;
             &lt;/street&gt;
             &lt;postalCode&gt;4000&lt;/postalCode&gt;
             &lt;city&gt;Basel&lt;/city&gt;
             &lt;country&gt;Schweiz&lt;/country&gt;
         &lt;/address&gt;
         &lt;ratings&gt;
             &lt;rating ref="C-xml"&gt;&lt;grade&gt;85&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-da"&gt;&lt;grade&gt;82&lt;/grade&gt;&lt;/rating&gt;
         &lt;/ratings&gt;
     &lt;/student&gt;
     &lt;student id="P-002"&gt;
         &lt;name&gt;
             &lt;firstName&gt;Willis&lt;/firstName&gt;
             &lt;middleName&gt;R.&lt;/middleName&gt;
             &lt;lastName&gt;Pattern&lt;/lastName&gt;
         &lt;/name&gt;
         &lt;dateOfBirth&gt;1975-10-12&lt;/dateOfBirth&gt;
         &lt;address&gt;
             &lt;street&gt;
                 &lt;name&gt;Hauptstrasse&lt;/name&gt;
                 &lt;number&gt;10&lt;/number&gt;
             &lt;/street&gt;
             &lt;postalCode&gt;6000&lt;/postalCode&gt;
             &lt;city&gt;Luzern&lt;/city&gt;
             &lt;country&gt;Schweiz&lt;/country&gt;
         &lt;/address&gt;
         &lt;ratings&gt;
             &lt;rating ref="C-da"&gt;&lt;grade&gt;45&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-xml"&gt;&lt;grade&gt;75&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-jav"&gt;&lt;grade&gt;75&lt;/grade&gt;&lt;/rating&gt;
         &lt;/ratings&gt;
     &lt;/student&gt;
     &lt;student id="P-003"&gt;
         &lt;name&gt;
             &lt;firstName&gt;Anna&lt;/firstName&gt;
             &lt;middleName&gt;Maria&lt;/middleName&gt;
             &lt;lastName&gt;Muster&lt;/lastName&gt;
         &lt;/name&gt;
         &lt;dateOfBirth&gt;1978-10-29&lt;/dateOfBirth&gt;
         &lt;address&gt;
             &lt;street&gt;
                 &lt;name&gt;Langstrasse&lt;/name&gt;
                 &lt;number&gt;8&lt;/number&gt;
             &lt;/street&gt;
             &lt;postalCode&gt;3000&lt;/postalCode&gt;
             &lt;city&gt;Bern&lt;/city&gt;
             &lt;country&gt;Schweiz&lt;/country&gt;
         &lt;/address&gt;
         &lt;ratings&gt;
             &lt;rating ref="C-da"&gt;&lt;grade&gt;75&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-rdb"&gt;&lt;grade&gt;96&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-jav"&gt;&lt;grade&gt;88&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-gui"&gt;&lt;grade&gt;78&lt;/grade&gt;&lt;/rating&gt;
         &lt;/ratings&gt;
     &lt;/student&gt;
     &lt;student id="P-004"&gt;
         &lt;name&gt;
             &lt;firstName&gt;Hans&lt;/firstName&gt;
             &lt;middleName&gt;Jochen&lt;/middleName&gt;
             &lt;lastName&gt;Musterhans&lt;/lastName&gt;
         &lt;/name&gt;
         &lt;dateOfBirth&gt;1980-08-12&lt;/dateOfBirth&gt;
         &lt;address&gt;
             &lt;street&gt;
                 &lt;name&gt;Langgasse&lt;/name&gt;
                 &lt;number&gt;4&lt;/number&gt;
             &lt;/street&gt;
             &lt;postalCode&gt;8000&lt;/postalCode&gt;
             &lt;city&gt;Winterthur&lt;/city&gt;
             &lt;country&gt;Schweiz&lt;/country&gt;
         &lt;/address&gt;
         &lt;ratings&gt;
             &lt;rating ref="C-da"&gt;&lt;grade&gt;95&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-rdb"&gt;&lt;grade&gt;92&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-jav"&gt;&lt;grade&gt;78&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-xml"&gt;&lt;grade&gt;76&lt;/grade&gt;&lt;/rating&gt;
             &lt;rating ref="C-gui"&gt;&lt;grade&gt;88&lt;/grade&gt;&lt;/rating&gt;
         &lt;/ratings&gt;
    &lt;/student&gt;
    &lt;student id="P-005"&gt;
        &lt;name&gt;
            &lt;firstName&gt;Christina&lt;/firstName&gt;
            &lt;lastName&gt;Muster&lt;/lastName&gt;
        &lt;/name&gt;
        &lt;dateOfBirth&gt;1968-04-22&lt;/dateOfBirth&gt;
        &lt;address&gt;
  &lt;/CAS&gt;
  </code></pre>
  
  <p><strong>XSD:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="NewDataSet"  xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="CASNamespace" xmlns="CASNamespace" xmlns:msdata="urn:schemas-    microsoft-com:xml-msdata"&gt; 
      &lt;xs:element name="CAS" type="CASType"/&gt;
          &lt;xs:complexType name="CASType"&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="name"/&gt;
                  &lt;!--&lt;xs:element ref="casBaseURL"/&gt;--&gt;
                  &lt;xs:element maxOccurs="unbounded" ref="course"/&gt;
                  &lt;xs:element maxOccurs="unbounded" ref="student"/&gt;
                  &lt;xs:element maxOccurs="unbounded" ref="teacher"/&gt;
                  &lt;!--&lt;xs:element ref="courseParticipants"/&gt;--&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;  
  
     &lt;xs:element name="course"&gt;
         &lt;xs:complexType&gt;
             &lt;xs:sequence&gt;
                 &lt;xs:element name="name" type="xs:string" minOccurs="0"/&gt;
                 &lt;xs:element name="lessons" type="xs:string" minOccurs="1" maxOccurs="50" /&gt;
                 &lt;xs:element name="project" type="xs:string" minOccurs="0"/&gt;
                 &lt;xs:element name="url" minOccurs="1" maxOccurs="1"&gt;
             &lt;xs:simpleType&gt;
                     &lt;xs:restriction base="xs:string"&gt;
                     &lt;xs:pattern value="[a-zA-Z].*.xhtml"/&gt;
                     &lt;/xs:restriction&gt;
             &lt;/xs:simpleType&gt;
         &lt;/xs:element&gt;
                 &lt;xs:element name="weight" minOccurs="1"&gt;
                     &lt;xs:simpleType&gt;
                         &lt;xs:restriction base="xs:float"&gt;             
                             &lt;xs:pattern value="[0-9]\.[0-9]"/&gt;
                         &lt;/xs:restriction&gt;
                     &lt;/xs:simpleType&gt;
                 &lt;/xs:element&gt;
                 &lt;xs:element ref="teacher" minOccurs="0" maxOccurs="unbounded" /&gt;
                 &lt;xs:element name="language" nillable="false" minOccurs="1" maxOccurs="4"&gt;
                     &lt;xs:complexType&gt;       
                         &lt;xs:simpleContent msdata:ColumnName="language_Text" msdata:Ordinal="0"&gt;
                             &lt;xs:extension base="xs:string" /&gt;
                         &lt;/xs:simpleContent&gt;          
                     &lt;/xs:complexType&gt;
                 &lt;/xs:element&gt;
                 &lt;xs:element ref="student" minOccurs="1" maxOccurs="unbounded" /&gt;
             &lt;/xs:sequence&gt;
             &lt;xs:attribute name="id"&gt;
                 &lt;xs:simpleType&gt;
                     &lt;xs:restriction base="xs:string"&gt;                
                         &lt;xs:pattern value="[C]-[a-z][A-Z].*"/&gt;
                     &lt;/xs:restriction&gt;
                 &lt;/xs:simpleType&gt;
             &lt;/xs:attribute&gt;
             &lt;xs:attribute name="ref" type="xs:string" /&gt;
         &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
  
     &lt;xs:element name="teacher"&gt;
         &lt;xs:complexType&gt;
             &lt;xs:sequence&gt;
                 &lt;xs:element ref="name" minOccurs="1" maxOccurs="unbounded" /&gt;
             &lt;/xs:sequence&gt;
             &lt;xs:attribute name="ref" type="xs:string" /&gt;
             &lt;xs:attribute name="id"&gt;
                 &lt;xs:simpleType&gt;
                     &lt;xs:restriction base="xs:string"&gt;                
                         &lt;xs:pattern value="[T]-[a-z][A-Z].*"/&gt;
                     &lt;/xs:restriction&gt;
                 &lt;/xs:simpleType&gt;
             &lt;/xs:attribute&gt;
         &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
  
     &lt;xs:element name="student"&gt;
         &lt;xs:complexType&gt;
             &lt;xs:sequence&gt;        
                 &lt;xs:element name="dateOfBirth" minOccurs="1" maxOccurs="1"&gt;
                     &lt;xs:complexType&gt;
                         &lt;xs:sequence&gt;
                             &lt;xs:element name="Year"&gt;
                                 &lt;xs:simpleType&gt;
                                     &lt;xs:restriction base="xs:integer"&gt;
                                         &lt;xs:minInclusive value="1920"/&gt;
                                         &lt;xs:maxInclusive value="2000"/&gt;
                                     &lt;/xs:restriction&gt;        
                                 &lt;/xs:simpleType&gt;
                             &lt;/xs:element&gt;
                             &lt;xs:element name="Month"&gt;
                                 &lt;xs:simpleType&gt;
                                     &lt;xs:restriction base="xs:integer"&gt;
                                         &lt;xs:minInclusive value="1"/&gt;
                                         &lt;xs:maxInclusive value="12"/&gt;
                                     &lt;/xs:restriction&gt;        
                                 &lt;/xs:simpleType&gt;
                             &lt;/xs:element&gt;
                             &lt;xs:element name="Day"&gt;
                                 &lt;xs:simpleType&gt;
                                     &lt;xs:restriction base="xs:integer"&gt;
                                         &lt;xs:minInclusive value="1"/&gt;
                                         &lt;xs:maxInclusive value="31"/&gt;
                                     &lt;/xs:restriction&gt;        
                                 &lt;/xs:simpleType&gt;
                             &lt;/xs:element&gt;
                         &lt;/xs:sequence&gt;
                     &lt;/xs:complexType&gt;
                 &lt;/xs:element&gt;                
                 &lt;xs:element ref="name" minOccurs="1" maxOccurs="unbounded" /&gt;
                 &lt;xs:element name="address" minOccurs="0" maxOccurs="unbounded"&gt;
                     &lt;xs:complexType&gt;
                         &lt;xs:sequence&gt;
                             &lt;xs:element name="postalCode" minOccurs="4" maxOccurs="5"&gt;
                                 &lt;xs:simpleType&gt;
                                     &lt;xs:restriction base="xs:string"&gt;
                                         &lt;xs:pattern value="[0-9].*"/&gt;
                                     &lt;/xs:restriction&gt;
                                 &lt;/xs:simpleType&gt;
                             &lt;/xs:element&gt;
                             &lt;xs:element name="city" type="xs:string" minOccurs="0" /&gt;
                             &lt;xs:element name="country" type="xs:string" minOccurs="0" /&gt;
                             &lt;xs:element name="street" minOccurs="0" maxOccurs="unbounded"&gt;
                                 &lt;xs:complexType&gt;
                                     &lt;xs:sequence&gt;
                                         &lt;xs:element name="name" minOccurs="0"&gt;
                                             &lt;xs:simpleType&gt;
                                                 &lt;xs:restriction base="xs:string"&gt;
                                                     &lt;xs:pattern value="[a-zA-Z].*"/&gt;
                                                 &lt;/xs:restriction&gt;
                                             &lt;/xs:simpleType&gt;
                                         &lt;/xs:element&gt;
                                         &lt;xs:element name="number" minOccurs="1"&gt;
                                             &lt;xs:simpleType&gt;
                                                 &lt;xs:restriction base="xs:string"&gt;
                                                     &lt;xs:pattern value="[0-9].*"/&gt;
                                                 &lt;/xs:restriction&gt;
                                             &lt;/xs:simpleType&gt;
                                         &lt;/xs:element&gt;
                                         &lt;xs:element name="addition" type="xs:string" minOccurs="0" /&gt;
                                     &lt;/xs:sequence&gt;
                                 &lt;/xs:complexType&gt;
                             &lt;/xs:element&gt;
                         &lt;/xs:sequence&gt;
                     &lt;/xs:complexType&gt;
                 &lt;/xs:element&gt;
                 &lt;xs:element name="ratings" minOccurs="0" maxOccurs="unbounded"&gt;
                     &lt;xs:complexType&gt;
                         &lt;xs:sequence&gt;
                             &lt;xs:element name="rating" minOccurs="0" maxOccurs="unbounded"&gt;
                                 &lt;xs:complexType&gt;
                                     &lt;xs:sequence&gt;
                                         &lt;xs:element name="grade" minOccurs="1" maxOccurs="1"&gt;
                                             &lt;xs:simpleType&gt;
                                                 &lt;xs:restriction base="xs:integer"&gt;
                                                     &lt;xs:minInclusive value="1"/&gt;
                                                     &lt;xs:maxInclusive value="100"/&gt;
                                                 &lt;/xs:restriction&gt;
                                             &lt;/xs:simpleType&gt;
                                         &lt;/xs:element&gt;
                                     &lt;/xs:sequence&gt;
                                     &lt;xs:attribute name="ref" type="xs:string" /&gt;
                                 &lt;/xs:complexType&gt;
                             &lt;/xs:element&gt;
                         &lt;/xs:sequence&gt;
                     &lt;/xs:complexType&gt;
                 &lt;/xs:element&gt;
             &lt;/xs:sequence&gt;
             &lt;xs:attribute name="id"&gt;
                 &lt;xs:simpleType&gt;
                     &lt;xs:restriction base="xs:string"&gt;                
                         &lt;xs:pattern value="[P]-[a-z][A-Z].*"/&gt;
                     &lt;/xs:restriction&gt;
                 &lt;/xs:simpleType&gt;
             &lt;/xs:attribute&gt;
             &lt;xs:attribute name="ref" type="xs:string" /&gt;
         &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
  
     &lt;xs:element name="name"&gt;
         &lt;xs:complexType&gt;
             &lt;xs:sequence&gt;
                 &lt;xs:element name="firstName" minOccurs="1"&gt;
                     &lt;xs:simpleType&gt;
                         &lt;xs:restriction base="xs:string"&gt;
                             &lt;xs:pattern value="[a-z].*"/&gt;
                         &lt;/xs:restriction&gt;
                     &lt;/xs:simpleType&gt;
                 &lt;/xs:element&gt;
                 &lt;xs:element name="middleName" minOccurs="1"&gt;
                     &lt;xs:simpleType&gt;
                         &lt;xs:restriction base="xs:string"&gt;
                             &lt;xs:pattern value="[a-z].*"/&gt;
                         &lt;/xs:restriction&gt;
                     &lt;/xs:simpleType&gt;
                 &lt;/xs:element&gt;
                 &lt;xs:element name="lastName" minOccurs="1"&gt;
                     &lt;xs:simpleType&gt;
                         &lt;xs:restriction base="xs:string"&gt;
                             &lt;xs:pattern value="[a-z].*"/&gt;
                         &lt;/xs:restriction&gt;
                     &lt;/xs:simpleType&gt;
                 &lt;/xs:element&gt;
             &lt;/xs:sequence&gt;
         &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Regards,</p>
  
  <p>Usman</p>