title: libxml2 namespace prefix for schemaLocation is not defined
body: <p>Few days ago I started to learn libxml2 for parsing xml documents on Linux (Ubuntu 14.04). But unfortunately I have a lot of problems with it. </p>
  
  <p>First, I have an error message when I use function <code>xmlParseDoc()</code>:</p>
  
  <blockquote>
    <p>doc.xml:1: namespace error : Namespace prefix xsi for schemaLocation on OAI-PMH is not defined. /www.openarchives.org/OAI/2.0/  <a href="http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" rel="nofollow">http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd</a>"</p>
  </blockquote>
  
  <p>Second is an error when I try to validate xml-document via xsd. But I think this error is a result of first problem. This is an error message: </p>
  
  <blockquote>
    <p>doc.xml:1: element OAI-PMH: Schemas validity error : Element 'OAI-PMH': No matching global declaration available for the validation root.</p>
  </blockquote>
  
  <p>Please can everyone help and explain my fault?<br><br>
  There is <code>parseFile()</code> function:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>bool parseFile(xmlDocPtr&amp; doc, const char* filename) {
      doc = xmlParseFile(filename);
      if(doc == NULL) {
          std::cout &lt;&lt; "Document is not parsing successfully: " &lt;&lt; filename &lt;&lt; std::endl;
          return false;
      }
      xmlNodePtr root = xmlDocGetRootElement(doc);
      if(root == NULL) {
          std::cout &lt;&lt; "Empty document: " &lt;&lt; filename &lt;&lt; std::endl;
          return false;
      }
      if(xmlStrcmp(root-&gt;name, (const xmlChar *)"OAI-PMH")) {
          std::cout &lt;&lt; "Document of the wrong type, root node != \"OAI-PMH\"" &lt;&lt; std::endl;
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>There is <code>validateDoc()</code> function:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void validateDoc(xmlDocPtr doc) {
      std::cout &lt;&lt; "Start to validate doc func\n";
      xmlSchemaParserCtxtPtr schemaParser = xmlSchemaNewParserCtxt("http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd");
      xmlSchemaPtr schema = xmlSchemaParse(schemaParser);
      xmlSchemaValidCtxtPtr schemaValid = xmlSchemaNewValidCtxt(schema);
      int result = xmlSchemaValidateDoc(schemaValid, doc);
      std::cout &lt;&lt; "Result: " &lt;&lt; result &lt;&lt; std::endl; // result is equal to 1845!
      std::cout &lt;&lt; "End validate doc func\n";
  }
  </code></pre>
  
  <p>And this is a xml-document:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/  http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd&gt;
      &lt;responseDate&gt;2014-08-21T22:00:24.551Z&lt;/responseDate&gt;
      &lt;request verb="Identify"/&gt;
      &lt;Identify&gt;
          &lt;repositoryName&gt;Musketti KDK Data&lt;/repositoryName&gt;
          &lt;baseURL&gt;http://www.museot.fi/baseUrl&lt;/baseURL&gt;
          &lt;protocolVersion&gt;2.0&lt;/protocolVersion&gt;
          &lt;adminEmail&gt;noreply@museo.fi&lt;/adminEmail&gt;
          &lt;earliestDatestamp&gt;1900-01-01T00:00:00.000Z&lt;/earliestDatestamp&gt;
          &lt;deletedRecord&gt;no&lt;/deletedRecord&gt;
          &lt;granularity&gt;YYYY-MM-DDThh:mm:ssZ&lt;/granularity&gt;
          &lt;compression&gt;NoCompression&lt;/compression&gt;
      &lt;/Identify&gt;
  &lt;/OAI-PMH&gt;
  </code></pre>