title: cvc-complex-type.4: Attribute {0} must appear on element {1}
body: <p>I'm new to xml and trying to validate xml with respective xsd but facing an error:</p>
  
  <blockquote>
    <p>cvc-complex-type.4: Attribute 'Companyname' must appear on element
    'company'</p>
  </blockquote>
  
  <p>Even though I already added Companyname in xml as well as xsd. What could be causing this error. Any help/suggestion?</p>
  
  <p><strong>XML:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;company Companyname="abc" address="hj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="companyxsd.xsd" &gt;
      &lt;department dname="dfsdf" deptphoneno="1232321" deptfaxno="2323" deptemail="fefsf"&gt;
          &lt;employee empid="fsd" ename="fuehuf" emailid="fhueh" phoneno="364764"&gt; &lt;/employee&gt;
          &lt;employee empid="fsd" ename="fuehuf" emailid="fhueh" phoneno="364764"&gt; &lt;/employee&gt;
          &lt;contractEmployee name="fdsf" phoneno="12345"&gt; &lt;/contractEmployee&gt;
      &lt;/department&gt;
  &lt;/company&gt;
  </code></pre>
  
  <p><strong>companyxsd.xsd:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" &gt;
          &lt;xs:element name="company" type="comType"/&gt;
          &lt;xs:complexType name="comType"&gt;
                  &lt;xs:sequence&gt;
                      &lt;xs:element name="department" type="deptType"/&gt;
                  &lt;/xs:sequence&gt;
                  &lt;xs:attribute type="xs:string" name="Companyname" use="required"/&gt;
                  &lt;xs:attribute type="xs:string" name="address" use="required"/&gt;
          &lt;/xs:complexType&gt;
          &lt;xs:complexType name="deptType"&gt;
                  &lt;xs:sequence&gt;
                      &lt;xs:element name="employee" type="empType" minOccurs="1" maxOccurs="unbounded"/&gt;
                      &lt;xs:element name="contractEmployee" type="conType" minOccurs="0" maxOccurs="unbounded"/&gt;
                  &lt;/xs:sequence&gt;
                  &lt;xs:attribute type="xs:string" name="dname" use="required"/&gt;
                  &lt;xs:attribute type="xs:integer" name="deptphoneno" use="required"/&gt;
                  &lt;xs:attribute type="xs:integer" name="deptfaxno" use="required"/&gt;
                  &lt;xs:attribute type="xs:string" name="deptemail" use="required"/&gt;
          &lt;/xs:complexType&gt;
          &lt;xs:complexType name="empType"&gt;
                  &lt;xs:attribute type="xs:string" name="empid" use="required"/&gt;
                  &lt;xs:attribute type="xs:string" name="ename" use="required"/&gt;
                  &lt;xs:attribute type="xs:string" name="emailid" use="required"/&gt;
                  &lt;xs:attribute type="xs:integer" name="phoneno" use="required"/&gt;
          &lt;/xs:complexType&gt;
          &lt;xs:complexType name="conType"&gt;
                  &lt;xs:attribute type="xs:string" name="name" use="required"/&gt;
                  &lt;xs:attribute type="xs:integer" name="phoneno" use="required"/&gt;
          &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qktkQ.png" rel="nofollow noreferrer">ER DIAGRAM</a></p>