title: How can I fix an XSD import error in lxml?
body: <p>I run this validation using lxml:</p>
  
  <pre><code>parser = etree.XMLParser()
  
  try:
      root = etree.fromstring(xml_content.strip(), parser)
  except Exception as e:
      raise XMLFormatException(str(e), XMLFormatException.IN_XML)
  
  try:
      schema = etree.XMLSchema(etree.XML(xsd_content.strip()))
  except Exception as e:
      raise XMLFormatException(str(e), XMLFormatException.IN_XSD)
  
  if not schema.validate():
      raise XMLValidationException("Se produjo un error al validar el XML", schema.error_log)
  </code></pre>
  
  <p>Assume <code>xml_content</code> and <code>xsd_content</code> are correctly instantiated. Part of the xsd content is this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified"&gt;
      &lt;xsd:import namespace="http://www.w3.org/2000/09/xmldsig#"
                  schemaLocation="xmldsig-core-schema.xsd" /&gt;
      &lt;!-- more stuff here --&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>When I run the script I get an error:</p>
  
  <blockquote>
    <p>failed to load external entity "xmldsig-core-schema.xsd"</p>
  </blockquote>
  
  <p>When I hit <a href="http://www.w3.org/2000/09/xmldsig#" rel="noreferrer">http://www.w3.org/2000/09/xmldsig#</a> in a browser, I get a xsd content.</p>
  
  <p><strong>Q</strong>: What am I missing here? How can I avoid such error?</p>
  
  <p><strong>Edit</strong> Notes:</p>
  
  <ol>
  <li>This error occurs before the validation can be made (i.e. this error occurs in the XMLSchema constructor).</li>
  <li>The xsd file is provided from an external source and I'm not allowed to edit it.</li>
  </ol>