title: Premature end of document qt, xml
body: <p>What is wrong with this xsd file?</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"&gt;
    &lt;xs:element name="root" type="rootType"/&gt;
    &lt;xs:complexType name="twokindType"&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:string"&gt;
          &lt;xs:attribute type="xs:string" name="name"/&gt;
          &lt;xs:attribute type="xs:int" name="n"/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="twoType"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element type="twokindType" name="twokind"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute type="xs:string" name="name"/&gt;
      &lt;xs:attribute type="xs:byte" name="number"/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="vendorType"&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:string"&gt;
          &lt;xs:attribute type="xs:string" name="name" use="optional"/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="priceType"&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:string"&gt;
          &lt;xs:attribute type="xs:string" name="name" use="optional"/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="oneType"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element type="vendorType" name="vendor"/&gt;
        &lt;xs:element type="priceType" name="price"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute type="xs:string" name="name" use="optional"/&gt;
      &lt;xs:attribute type="xs:byte" name="n" use="optional"/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="onesType"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element type="oneType" name="one" maxOccurs="unbounded" minOccurs="0"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute type="xs:string" name="name"/&gt;
      &lt;xs:attribute type="xs:byte" name="number"/&gt;
    &lt;/xs:complexType&gt;
    &lt;xs:complexType name="rootType"&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element type="twoType" name="two"/&gt;
        &lt;xs:element type="onesType" name="ones"/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>I have checked its validity on different websites and they all say it's okay. I took a code sample from qt's website to load it, and I get an error saying "Premature end of document." The error is on line 1, column 0. I don't see anything wrong there. I looked at this file using hex editor and there are no weird symbols.</p>
  
  <p>Below is the code from qt's website:</p>
  
  <pre><code>QUrl schemaUrl("file:///home/user/schema.xsd");
  
      QXmlSchema schema;
      schema.load(schemaUrl);
  
      if (schema.isValid()) {
          QFile file("test.xml");
          file.open(QIODevice::ReadOnly);
  
          QXmlSchemaValidator validator(schema);
          if (validator.validate(&amp;file, QUrl::fromLocalFile(file.fileName())))
              qDebug() &lt;&lt; "instance document is valid";
          else
              qDebug() &lt;&lt; "instance document is invalid";
      }
  </code></pre>