title: How to disable warning produced by DOMDocument::schemaValidate() when the schema is invalid?
body: <p>To avoid PHP warnings in schema validation process, one can use <code>libxml_use_internal_errors(true);</code>, and <code>libxml_get_errors()[0] -&gt; message;</code> to "manually" administrate eventual validation error messages. This works when it is the XML that does not match a schema, but a warning is still being fired when the schema itself is invalid.</p>
  
  <p><code>libxml_use_internal_errors(true);</code> already captures the error message in the returned array of errors, the warning seems redundant to me, any way to bypass/disable this particular warning?</p>
  
  <p>I work in strict mode, so I stop the execution when a warning fires, and log the error in a database, the problem is that the PHP warning is too vague, so I want to bypass it to report the libxml error in a separate logging system, and see the detailed error afterwards.</p>
  
  <p>Is this warning a correct behavior? any chance it is a bug?</p>
  
  <hr>
  
  <p>The PHP code:</p>
  
  <pre><code>&lt;?php
      $DD = new DOMDocument('1.0', 'ISO-8859-1');
      $DD -&gt; loadXML('&lt;?xml version ="1.0" encoding="ISO-8859-1"?&gt;&lt;a&gt;&lt;/a&gt;');
      libxml_use_internal_errors(true); // NO LIBXML WARNINGS
      $DD -&gt; schemaValidate(__DIR__ . '/schema.xsd'); // Vague WARNING
      $errors = libxml_get_errors();
  
      if (isset($errors[0])) {
          echo $errors[0] -&gt; message; // Libxml detailed message
      }
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>The PHP warning:</p>
  
  <blockquote>
    <p>DOMDocument::schemaValidate(): Invalid Schema</p>
  </blockquote>
  
  <hr>
  
  <p>The libxml detailed error message:</p>
  
  <blockquote>
    <p>Element '{<a href="http://www.w3.org/2001/XMLSchema" rel="nofollow">http://www.w3.org/2001/XMLSchema</a>}complexType': The content
    is not valid. Expected is (annotation?, (simpleContent |
    complexContent | ((group | all | choice | sequence)?, ((attribute |
    attributeGroup)*, anyAttribute?))))</p>
  </blockquote>
  
  <hr>
  
  <p>The invalid schema (schema.xsd):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;xs:schema
      targetNamespace="http://www.lala.com/la"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:la="http://www.lala.com/la"
      elementFormDefault="qualified"
      attributeFormDefault="unqualified"
  &gt;
      &lt;xs:element name="foo"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:element ref="bar"/&gt;&lt;!-- lacking &lt;sequence&gt; parent --&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>